From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35836) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yq2Og-0006SF-P6 for qemu-devel@nongnu.org; Wed, 06 May 2015 12:42:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yq2Ob-0004jx-LS for qemu-devel@nongnu.org; Wed, 06 May 2015 12:42:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34422) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yq2Ob-0004jr-Dl for qemu-devel@nongnu.org; Wed, 06 May 2015 12:42:05 -0400 Message-ID: <554A4458.7090901@redhat.com> Date: Wed, 06 May 2015 18:42:00 +0200 From: Max Reitz MIME-Version: 1.0 References: In-Reply-To: Content-Type: multipart/alternative; boundary="------------060607020306090400020405" Subject: Re: [Qemu-devel] [PATCH] use bdrv_flush to provide barrier semantic in block/vdi.c for metadata updates List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: phoeagon , qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------060607020306090400020405 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit @subject: It's a bit long, and it's missing a prefix telling what this patch is about. I would have probably used "block/vdi: Use bdrv_flush after metadata updates" or something like that. On 01.05.2015 17:03, phoeagon wrote: > Looks like VDI is the only writable image format that does not use > write-with-barrier(sync) when updating the metadata. A sequence of > commits b0ad5a455d~078a458e077d6b0db2 fixes this for > QCOW/COW/QCOW2/VPC/VMDK, but the VDI does not issue a barrier by sync > after updating the metadata. > > This commit adds a `bdrv_flush` after updating block map. > > > Signed-off-by: Zhe Qiu Hm, this doesn't look quite right. :-) > --------------- These should be only "---", I guess, so the block below is omitted from the commit message. > From 2ea36d9a0e676b534483dc54c191f421f9889dc6 Mon Sep 17 00:00:00 2001 > From: phoeagon > Date: Fri, 1 May 2015 19:00:22 +0800 > Subject: [PATCH] use bdrv_flush to provide barrier semantic in block/vdi.c > > In reference to > b0ad5a455d7e5352d4c86ba945112011dbeadfb8~078a458e077d6b0db262c4b05fee51d01de2d1d2, > metadata writes to qcow2/cow/qcow/vpc/vmdk are all synced prior to > succeeding writes. > --- > block/vdi.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/block/vdi.c b/block/vdi.c > index 7642ef3..5d09b36 100644 > --- a/block/vdi.c > +++ b/block/vdi.c > @@ -713,6 +713,7 @@ static int vdi_co_write(BlockDriverState *bs, > logout("will write %u block map sectors starting from entry > %u\n", > n_sectors, bmap_first); > ret = bdrv_write(bs->file, offset, base, n_sectors); > + ret = bdrv_flush(bs->file); This overwrites the return value from bdrv_write(), which I don't think is right. We could either ignore bdrv_flush()'s return value, or make it something like "if (ret < 0) { bdrv_flush(bs->file); } else { ret = bdrv_flush(bs->file); }" or "ret_flush = bdrv_flush(bs->file); if (!(ret < 0)) { ret = ret_flush; }". Or skip the flush in case bdrv_write() failed ("if (ret < 0) { return ret; } ret = bdrv_flush(bs->file);"), like bdrv_pwrite_sync() does. The idea of the change (adding the flush) looks good, though. Max > } > return ret; > -- > 2.3.7 > --------------060607020306090400020405 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by mx1.redhat.com id t46Gg3oX024633
@subject: It's a bit long, and it's missing a prefix telling what this patch is about. I would have probably used "block/vdi: Use bdrv_flush after metadata updates" or something like that.

On 01.05.2015 17:03, phoeagon wrote:
Looks like VDI is the only writable image format that does not use write-with-barrier(sync) when updating the metadata. A sequence of commits b0ad5a455d~078a458e077d6b0db2 fixes this for QCOW/COW/QCOW2/VPC/VMDK, but the VDI does not issue a barrier by sync after updating the metadata.

This commit adds a `bdrv_flush` after updating block map.


Signed-off-= by: Zhe Qiu <address@hidden>

Hm, this doesn't look quite right. :-)

---------------

These should be only "---", I guess, so the block below is omitted from the commit message.

From 2ea36d9a0e676b534483dc54c191f421f9889dc6 Mon Sep 17 00:00:00 2001
From: phoeagon <address@hidden<= /span>>
Date: Fri, 1 May 2015 19:00:22 +0800
Subject: [PATCH] use bdrv_flush to provide barrier semantic in block/vdi.c

In reference to b0ad5a455d7e5352d4c86ba945112011dbeadfb8~078a458e077d6b0db262c4= b05fee51d01de2d1d2, metadata writes to qcow2/cow/qcow/vpc/vmdk are all synced prior to succeeding writes.
---
=C2=A0block/vdi.c | 1 +
=C2=A01 file changed, 1 insertion(+)

diff --git a/block/vdi.c b/block/vdi.c
index 7642ef3..5d09b36 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -713,6 +713,7 @@ static int vdi_co_write(BlockDriverState *bs,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0logout("will write %u bloc= k map sectors starting from entry %u\n",
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 n_se= ctors, bmap_first);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ret =3D bdrv_write(bs->= file, offset, base, n_sectors);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0ret =3D bdrv_flush(bs->file)= ;

This overwrites the return value from bdrv_write(), which I don't think is right. We could either ignore bdrv_flush()'s return value, or make it something like "if (ret < 0) { bdrv_flush(bs->file); } else { ret =3D bdrv_flush(bs->file); }" or "ret_flush =3D bdrv_flush(bs->file); if (!(ret < 0)) { ret =3D ret_flush; }". Or skip the flush in case bdrv_write() failed ("if (ret < 0) { return ret; } ret =3D bdrv_flush(bs->file);"), like bdrv_pwrite_sync() does.

The idea of the change (adding the flush) looks good, though.

Max

=C2=A0 =C2=A0 =C2=A0}
=C2=A0
=C2=A0 =C2=A0 =C2=A0return ret;
--=C2=A0
2.3.7


--------------060607020306090400020405--