From: "Michael S. Tsirkin" <mst@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] virtio-scsi: fix "written length" field in the used ring
Date: Mon, 27 Apr 2015 15:23:54 +0200 [thread overview]
Message-ID: <20150427152255-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <1430137765-13771-1-git-send-email-pbonzini@redhat.com>
On Mon, Apr 27, 2015 at 02:29:25PM +0200, Paolo Bonzini wrote:
> qsgl->size is the size of the data field after the request or
> response header (virtio-scsi currently supports only one such
> field; bidirectional requests are not supported). However,
> the used ring's len field is not concerned about the field
> after the request header, so do not count it unless req->mode
> signals the request was a read.
>
> Also, do not report that anything was written if the request
> failed, and subtract any residual bytes in case of buffer underrun.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Pls merge through the storage tree.
Also, can you pls fix up blk similarly?
> ---
> hw/scsi/virtio-scsi.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
> index c9bea06..4995f6e 100644
> --- a/hw/scsi/virtio-scsi.c
> +++ b/hw/scsi/virtio-scsi.c
> @@ -65,6 +65,19 @@ void virtio_scsi_free_req(VirtIOSCSIReq *req)
> g_slice_free1(sizeof(*req) + vs->cdb_size, req);
> }
>
> +static size_t virtio_scsi_written_length(VirtIODevice *vdev, VirtIOSCSIReq *req)
> +{
> + size_t sz = req->resp_iov.size;
> +
> + if (req->sreq &&
> + req->mode == SCSI_XFER_FROM_DEV &&
> + req->resp.cmd.response == VIRTIO_SCSI_S_OK) {
> + sz += req->qsgl.size - virtio_tswap32(vdev, req->resp.cmd.resid);
> + }
> +
> + return sz;
> +}
> +
> static void virtio_scsi_complete_req(VirtIOSCSIReq *req)
> {
> VirtIOSCSI *s = req->dev;
> @@ -76,7 +89,7 @@ static void virtio_scsi_complete_req(VirtIOSCSIReq *req)
> assert(req->vq == NULL);
> virtio_scsi_vring_push_notify(req);
> } else {
> - virtqueue_push(vq, &req->elem, req->qsgl.size + req->resp_iov.size);
> + virtqueue_push(vq, &req->elem, virtio_scsi_written_length(vdev, req));
> virtio_notify(vdev, vq);
> }
>
> --
> 2.3.5
next prev parent reply other threads:[~2015-04-27 13:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-27 12:29 [Qemu-devel] [PATCH] virtio-scsi: fix "written length" field in the used ring Paolo Bonzini
2015-04-27 13:23 ` Michael S. Tsirkin [this message]
2015-04-27 13:28 ` Paolo Bonzini
2015-04-27 14:04 ` Michael S. Tsirkin
2015-04-27 14:18 ` Paolo Bonzini
2015-04-27 14:20 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150427152255-mutt-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.