qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] use bdrv_flush to provide barrier semantic in b


From: Max Reitz
Subject: Re: [Qemu-devel] [PATCH] use bdrv_flush to provide barrier semantic in block/vdi.c for metadata updates
Date: Wed, 06 May 2015 18:42:00 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

@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>
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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]