qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Benoît Canet" <benoit.canet@irqsave.net>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	andrey@xdel.ru, Fam Zheng <famz@redhat.com>,
	qemu-devel@nongnu.org, sviatoslav.pestov@gmail.com
Subject: Re: [Qemu-devel] [PATCH v2 1/2] block: fix overlapping multiwrite requests
Date: Thu, 31 Jul 2014 09:41:57 +0200	[thread overview]
Message-ID: <20140731074157.GC707@irqsave.net> (raw)
In-Reply-To: <1406710411-26373-2-git-send-email-stefanha@redhat.com>

The Wednesday 30 Jul 2014 à 09:53:30 (+0100), Stefan Hajnoczi wrote :
> When request A is a strict superset of request B:
> 
>   AAAAAAAA
>     BBBB
> 
> multiwrite_merge() merges them as follows:
> 
>   AABBBB
> 
> The tail of request A should have been included:
> 
>   AABBBBAA
> 
> This patch fixes data loss but this code path is probably rare.  Since
> guests cannot assume ordering between in-flight requests, few
> applications submit overlapping write requests.
> 
> Reported-by: Slava Pestov <sviatoslav.pestov@gmail.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  block.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/block.c b/block.c
> index 8cf519b..0a3ac43 100644
> --- a/block.c
> +++ b/block.c
> @@ -4498,6 +4498,12 @@ static int multiwrite_merge(BlockDriverState *bs, BlockRequest *reqs,
>              // Add the second request
>              qemu_iovec_concat(qiov, reqs[i].qiov, 0, reqs[i].qiov->size);
>  
> +            // Add tail of first request, if necessary
> +            if (qiov->size < reqs[outidx].qiov->size) {
> +                qemu_iovec_concat(qiov, reqs[outidx].qiov, qiov->size,
> +                                  reqs[outidx].qiov->size - qiov->size);
> +            }
> +
>              reqs[outidx].nb_sectors = qiov->size >> 9;
>              reqs[outidx].qiov = qiov;
>  
> -- 
> 1.9.3
> 
> 

Seems to make sense.

Reviewed-by: Benoit Canet <benoit@irqsave.net>

  parent reply	other threads:[~2014-07-31  7:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-30  8:53 [Qemu-devel] [PATCH v2 0/2] block: fix multiwrite_merge() overlapping requests Stefan Hajnoczi
2014-07-30  8:53 ` [Qemu-devel] [PATCH v2 1/2] block: fix overlapping multiwrite requests Stefan Hajnoczi
2014-07-30 11:23   ` Eric Blake
2014-07-31  7:41   ` Benoît Canet [this message]
2014-07-30  8:53 ` [Qemu-devel] [PATCH v2 2/2] qemu-iotests: add multiwrite test cases Stefan Hajnoczi
2014-07-30 11:19   ` Eric Blake
2014-07-31  7:46   ` Benoît Canet
2014-08-29 13:10 ` [Qemu-devel] [PATCH v2 0/2] block: fix multiwrite_merge() overlapping requests Stefan Hajnoczi

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=20140731074157.GC707@irqsave.net \
    --to=benoit.canet@irqsave.net \
    --cc=andrey@xdel.ru \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=sviatoslav.pestov@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).