Skip to content

Commit 0a3eac5

Browse files
mikechristiemstsirkin
authored andcommitted
vhost_scsi: flush IO vqs then send TMF rsp
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 <michael.christie@oracle.com> Message-Id: <20230626232307.97930-12-michael.christie@oracle.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent 78af31c commit 0a3eac5

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

drivers/vhost/scsi.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,12 +1133,27 @@ static void vhost_scsi_tmf_resp_work(struct vhost_work *work)
11331133
{
11341134
struct vhost_scsi_tmf *tmf = container_of(work, struct vhost_scsi_tmf,
11351135
vwork);
1136-
int resp_code;
1136+
struct vhost_virtqueue *ctl_vq, *vq;
1137+
int resp_code, i;
1138+
1139+
if (tmf->scsi_resp == TMR_FUNCTION_COMPLETE) {
1140+
/*
1141+
* Flush IO vqs that don't share a worker with the ctl to make
1142+
* sure they have sent their responses before us.
1143+
*/
1144+
ctl_vq = &tmf->vhost->vqs[VHOST_SCSI_VQ_CTL].vq;
1145+
for (i = VHOST_SCSI_VQ_IO; i < tmf->vhost->dev.nvqs; i++) {
1146+
vq = &tmf->vhost->vqs[i].vq;
1147+
1148+
if (vhost_vq_is_setup(vq) &&
1149+
vq->worker != ctl_vq->worker)
1150+
vhost_vq_flush(vq);
1151+
}
11371152

1138-
if (tmf->scsi_resp == TMR_FUNCTION_COMPLETE)
11391153
resp_code = VIRTIO_SCSI_S_FUNCTION_SUCCEEDED;
1140-
else
1154+
} else {
11411155
resp_code = VIRTIO_SCSI_S_FUNCTION_REJECTED;
1156+
}
11421157

11431158
vhost_scsi_send_tmf_resp(tmf->vhost, &tmf->svq->vq, tmf->in_iovs,
11441159
tmf->vq_desc, &tmf->resp_iov, resp_code);

0 commit comments

Comments
 (0)