All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH 2/2] virtio-blk: fix length calculations for write operations.
Date: Wed, 11 Mar 2015 07:48:43 +0100	[thread overview]
Message-ID: <20150311074415-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <1426053572-21326-3-git-send-email-rusty@rustcorp.com.au>

On Wed, Mar 11, 2015 at 04:29:32PM +1030, Rusty Russell wrote:
> We only fill in the 'req->qiov.size' bytes on a (successful) read,
> not on a write.
> 
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> ---
>  hw/block/virtio-blk.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
> index 258bb4c..98d87a9 100644
> --- a/hw/block/virtio-blk.c
> +++ b/hw/block/virtio-blk.c
> @@ -50,11 +50,19 @@ static void virtio_blk_complete_request(VirtIOBlockReq *req,
>  {
>      VirtIOBlock *s = req->dev;
>      VirtIODevice *vdev = VIRTIO_DEVICE(s);
> +    int type = virtio_ldl_p(VIRTIO_DEVICE(req->dev), &req->out.type);
>  
>      trace_virtio_blk_req_complete(req, status);
>  
>      stb_p(&req->in->status, status);
> -    virtqueue_push(s->vq, &req->elem, req->qiov.size + sizeof(*req->in));
> +
> +    /* If we didn't succeed, we *may* have written more, but don't
> +     * count on it. */

I wonder about this.
So length as you specify it is <= actually written length.
What are the advantages of this approach?
How about we do the reverse, specify that the length in descriptor
is >= the size actually written?

If we do this, all these buggy hosts suddenly become correct,
which seems better.


> +    if (type == VIRTIO_BLK_T_IN && status == VIRTIO_BLK_S_OK) {
> +        virtqueue_push(s->vq, &req->elem, req->qiov.size + sizeof(*req->in));
> +    } else {
> +        virtqueue_push(s->vq, &req->elem, sizeof(*req->in));
> +    }
>      virtio_notify(vdev, s->vq);
>  }
>  
> -- 
> 2.1.0

  reply	other threads:[~2015-03-11  6:48 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-11  5:59 [Qemu-devel] [PATCH 0/2] virtio len fixes for qemu Rusty Russell
2015-03-11  5:59 ` [Qemu-devel] [PATCH 1/2] virtio: make it clear that "len" for a used descriptor is len written Rusty Russell
2015-03-11  5:59 ` [Qemu-devel] [PATCH 2/2] virtio-blk: fix length calculations for write operations Rusty Russell
2015-03-11  6:48   ` Michael S. Tsirkin [this message]
2015-03-11 11:34     ` Rusty Russell
2015-03-11  6:19 ` [Qemu-devel] [PATCH 0/2] virtio len fixes for qemu Michael S. Tsirkin
2015-03-11  6:47   ` Fam Zheng
2015-03-11  6:50     ` Michael S. Tsirkin
2015-03-11 11:36       ` Rusty Russell
2015-03-11 12:39         ` Michael S. Tsirkin
2015-03-12  1:04           ` Rusty Russell
2015-03-12  6:35             ` Michael S. Tsirkin
2015-03-13  1:17               ` Rusty Russell
2015-03-13 13:49                 ` Michael S. Tsirkin
2015-03-16  3:14                   ` Rusty Russell
2015-03-16  5:03                     ` Michael S. Tsirkin
2015-03-16 15:37                       ` Cornelia Huck
2015-03-20  0:59                       ` Rusty Russell
2015-03-18 12:32 ` 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=20150311074415-mutt-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rusty@rustcorp.com.au \
    /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.