From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCl0i-00016O-BY for qemu-devel@nongnu.org; Thu, 31 Jul 2014 03:42:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XCl0d-00047Z-95 for qemu-devel@nongnu.org; Thu, 31 Jul 2014 03:42:48 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:56449 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCl0d-00047V-3G for qemu-devel@nongnu.org; Thu, 31 Jul 2014 03:42:43 -0400 Date: Thu, 31 Jul 2014 09:41:57 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140731074157.GC707@irqsave.net> References: <1406710411-26373-1-git-send-email-stefanha@redhat.com> <1406710411-26373-2-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1406710411-26373-2-git-send-email-stefanha@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 1/2] block: fix overlapping multiwrite requests List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , andrey@xdel.ru, Fam Zheng , qemu-devel@nongnu.org, sviatoslav.pestov@gmail.com The Wednesday 30 Jul 2014 =E0 09:53:30 (+0100), Stefan Hajnoczi wrote : > When request A is a strict superset of request B: >=20 > AAAAAAAA > BBBB >=20 > multiwrite_merge() merges them as follows: >=20 > AABBBB >=20 > The tail of request A should have been included: >=20 > AABBBBAA >=20 > 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. >=20 > Reported-by: Slava Pestov > Signed-off-by: Stefan Hajnoczi > --- > block.c | 6 ++++++ > 1 file changed, 6 insertions(+) >=20 > 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->siz= e); > =20 > + // 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 =3D qiov->size >> 9; > reqs[outidx].qiov =3D qiov; > =20 > --=20 > 1.9.3 >=20 >=20 Seems to make sense. Reviewed-by: Benoit Canet