From patchwork Sun Jan 17 11:32:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: block: fix cache flushing in bdrv_commit From: Christoph Hellwig X-Patchwork-Id: 43022 Message-Id: <20100117113230.GB18966@lst.de> To: Kevin Wolf Cc: Christoph Hellwig , qemu-devel@nongnu.org Date: Sun, 17 Jan 2010 12:32:30 +0100 On Thu, Jan 14, 2010 at 11:21:15AM +0100, Kevin Wolf wrote: > Anthony, you seem to have missed the v2 patch that considered my review > comments. Can you please apply the diff between v1 and v2 on top? Here is the differences in patch form: --- From: Christoph Hellwig Subject: block: fix cache flushing in bdrv_commit As pointed out by Kevin Wolf the previous patch returned early if we there is a bdrv_make_empty method and it missed a cache flush for the frontend device after the bdev_make_empty call. This patch fixes it up. Signed-off-by: Christoph Hellwig Index: qemu/block.c =================================================================== --- qemu.orig/block.c 2010-01-17 12:27:03.589006970 +0100 +++ qemu/block.c 2010-01-17 12:27:55.718008519 +0100 @@ -589,6 +589,7 @@ int bdrv_commit(BlockDriverState *bs) BlockDriver *drv = bs->drv; int64_t i, total_sectors; int n, j; + int ret = 0; unsigned char sector[512]; if (!drv) @@ -620,8 +621,10 @@ int bdrv_commit(BlockDriverState *bs) } } - if (drv->bdrv_make_empty) - return drv->bdrv_make_empty(bs); + if (drv->bdrv_make_empty) { + ret = drv->bdrv_make_empty(bs); + bdrv_flush(bs); + } /* * Make sure all data we wrote to the backing device is actually @@ -629,7 +632,7 @@ int bdrv_commit(BlockDriverState *bs) */ if (bs->backing_hd) bdrv_flush(bs->backing_hd); - return 0; + return ret; } /*