]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
vhost scsi: fix lun reset completion handling
authorMike Christie <michael.christie@oracle.com>
Fri, 20 Nov 2020 15:50:59 +0000 (09:50 -0600)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 25 Nov 2020 09:22:13 +0000 (04:22 -0500)
vhost scsi owns the scsi se_cmd but lio frees the se_cmd->se_tmr
before calling release_cmd, so while with normal cmd completion we
can access the se_cmd from the vhost work, we can't do the same with
se_cmd->se_tmr. This has us copy the tmf response in
vhost_scsi_queue_tm_rsp to our internal vhost-scsi tmf struct for
when it gets sent to the guest from our worker thread.

Fixes: efd838fec17b ("vhost scsi: Add support for LUN resets.")
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Link: https://lore.kernel.org/r/1605887459-3864-1-git-send-email-michael.christie@oracle.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/vhost/scsi.c

index f22fce54986263ee94662e5f607ba23fa9c7d435..6ff8a509669154e04b4a8d1b85d99e2a586781a2 100644 (file)
@@ -220,6 +220,7 @@ struct vhost_scsi_tmf {
        struct list_head queue_entry;
 
        struct se_cmd se_cmd;
+       u8 scsi_resp;
        struct vhost_scsi_inflight *inflight;
        struct iovec resp_iov;
        int in_iovs;
@@ -426,6 +427,7 @@ static void vhost_scsi_queue_tm_rsp(struct se_cmd *se_cmd)
        struct vhost_scsi_tmf *tmf = container_of(se_cmd, struct vhost_scsi_tmf,
                                                  se_cmd);
 
+       tmf->scsi_resp = se_cmd->se_tmr_req->response;
        transport_generic_free_cmd(&tmf->se_cmd, 0);
 }
 
@@ -1183,7 +1185,7 @@ static void vhost_scsi_tmf_resp_work(struct vhost_work *work)
                                                  vwork);
        int resp_code;
 
-       if (tmf->se_cmd.se_tmr_req->response == TMR_FUNCTION_COMPLETE)
+       if (tmf->scsi_resp == TMR_FUNCTION_COMPLETE)
                resp_code = VIRTIO_SCSI_S_FUNCTION_SUCCEEDED;
        else
                resp_code = VIRTIO_SCSI_S_FUNCTION_REJECTED;