]> Git Repo - linux.git/commitdiff
vhost_scsi: flush IO vqs then send TMF rsp
authorMike Christie <[email protected]>
Mon, 26 Jun 2023 23:23:01 +0000 (18:23 -0500)
committerMichael S. Tsirkin <[email protected]>
Mon, 3 Jul 2023 16:15:14 +0000 (12:15 -0400)
With one worker we will always send the scsi cmd responses then send the
TMF rsp, because LIO will always complete the scsi cmds first then call
into us to send the TMF response.

With multiple workers, the IO vq workers could be running while the
TMF/ctl vq worker is running so this has us do a flush before completing
the TMF to make sure cmds are completed when it's work is later queued
and run.

Signed-off-by: Mike Christie <[email protected]>
Message-Id: <20230626232307[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
drivers/vhost/scsi.c

index 1668009bd4891bcf326a6f28bf9aa5d07cda989f..2c3cf487cc713aa23cd3ffd4cb28634f638d8bd8 100644 (file)
@@ -1133,12 +1133,27 @@ static void vhost_scsi_tmf_resp_work(struct vhost_work *work)
 {
        struct vhost_scsi_tmf *tmf = container_of(work, struct vhost_scsi_tmf,
                                                  vwork);
-       int resp_code;
+       struct vhost_virtqueue *ctl_vq, *vq;
+       int resp_code, i;
+
+       if (tmf->scsi_resp == TMR_FUNCTION_COMPLETE) {
+               /*
+                * Flush IO vqs that don't share a worker with the ctl to make
+                * sure they have sent their responses before us.
+                */
+               ctl_vq = &tmf->vhost->vqs[VHOST_SCSI_VQ_CTL].vq;
+               for (i = VHOST_SCSI_VQ_IO; i < tmf->vhost->dev.nvqs; i++) {
+                       vq = &tmf->vhost->vqs[i].vq;
+
+                       if (vhost_vq_is_setup(vq) &&
+                           vq->worker != ctl_vq->worker)
+                               vhost_vq_flush(vq);
+               }
 
-       if (tmf->scsi_resp == TMR_FUNCTION_COMPLETE)
                resp_code = VIRTIO_SCSI_S_FUNCTION_SUCCEEDED;
-       else
+       } else {
                resp_code = VIRTIO_SCSI_S_FUNCTION_REJECTED;
+       }
 
        vhost_scsi_send_tmf_resp(tmf->vhost, &tmf->svq->vq, tmf->in_iovs,
                                 tmf->vq_desc, &tmf->resp_iov, resp_code);
This page took 0.046629 seconds and 4 git commands to generate.