Skip to content

Commit abc9b15

Browse files
Dongli ZhangBrian Maly
authored andcommitted
vhost-scsi: Fix vhost_scsi_send_status()
Although the support of VIRTIO_F_ANY_LAYOUT + VIRTIO_F_VERSION_1 was signaled by the commit 664ed90 ("vhost/scsi: Set VIRTIO_F_ANY_LAYOUT + VIRTIO_F_VERSION_1 feature bits"), vhost_scsi_send_bad_target() still assumes the response in a single descriptor. Similar issue in vhost_scsi_send_bad_target() has been fixed in previous commit. In addition, similar issue for vhost_scsi_complete_cmd_work() has been fixed by the commit 6dd88fd ("vhost-scsi: unbreak any layout for response"). Fixes: 3ca51662f818 ("vhost-scsi: Add better resource allocation failure handling") Signed-off-by: Dongli Zhang <[email protected]> Acked-by: Jason Wang <[email protected]> Reviewed-by: Mike Christie <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> (cherry picked from commit 58465d86071b61415e25fb054201f61e83d21465) Orabug: 37980690 Conflicts: - commit de4eda9 ("use less confusing names for iov_iter direction initializers") is not merged in UEK7 so we are still using READ instead of ITER_DEST. Signed-off-by: Mike Christie <[email protected]> Reviewed-by: Dongli Zhang <[email protected]> Signed-off-by: Brian Maly <[email protected]>
1 parent 27a5d52 commit abc9b15

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

drivers/vhost/scsi.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,18 +1017,22 @@ static void vhost_scsi_target_queue_cmd(struct vhost_scsi_nexus *nexus,
10171017

10181018
static void
10191019
vhost_scsi_send_status(struct vhost_scsi *vs, struct vhost_virtqueue *vq,
1020-
int head, unsigned int out, u8 status)
1020+
struct vhost_scsi_ctx *vc, u8 status)
10211021
{
1022-
struct virtio_scsi_cmd_resp __user *resp;
10231022
struct virtio_scsi_cmd_resp rsp;
1023+
struct iov_iter iov_iter;
10241024
int ret;
10251025

10261026
memset(&rsp, 0, sizeof(rsp));
10271027
rsp.status = status;
1028-
resp = vq->iov[out].iov_base;
1029-
ret = __copy_to_user(resp, &rsp, sizeof(rsp));
1030-
if (!ret)
1031-
vhost_add_used_and_signal(&vs->dev, vq, head, 0);
1028+
1029+
iov_iter_init(&iov_iter, READ, &vq->iov[vc->out], vc->in,
1030+
sizeof(rsp));
1031+
1032+
ret = copy_to_iter(&rsp, sizeof(rsp), &iov_iter);
1033+
1034+
if (likely(ret == sizeof(rsp)))
1035+
vhost_add_used_and_signal(&vs->dev, vq, vc->head, 0);
10321036
else
10331037
pr_err("Faulted on virtio_scsi_cmd_resp\n");
10341038
}
@@ -1438,7 +1442,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
14381442
else if (ret == -EIO)
14391443
vhost_scsi_send_bad_target(vs, vq, &vc, TYPE_IO_CMD);
14401444
else if (ret == -ENOMEM)
1441-
vhost_scsi_send_status(vs, vq, vc.head, vc.out,
1445+
vhost_scsi_send_status(vs, vq, &vc,
14421446
SAM_STAT_TASK_SET_FULL);
14431447
} while (likely(!vhost_exceeds_weight(vq, ++c, 0)));
14441448
out:

0 commit comments

Comments
 (0)