aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2010-01-12 13:49:23 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2010-01-13 17:14:15 -0600
commit3f5075ae63b6dc1de9428d028a4d28fc98e7fdff (patch)
tree5c8fc9ec0ded501b335360a4d58be1478d8beabf /block.c
parent2da69c8d122570832971ee4bb5b6b4395ec97280 (diff)
block: flush backing_hd in the right place
The backing device is only modified from bdrv_commit. So instead of flushing it every time bdrv_flush is called for the front-end device only flush it after we're written data to it in bdrv_commit. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/block.c b/block.c
index c7bc83773a..115e5913eb 100644
--- a/block.c
+++ b/block.c
@@ -594,6 +594,12 @@ int bdrv_commit(BlockDriverState *bs)
if (drv->bdrv_make_empty)
return drv->bdrv_make_empty(bs);
+ /*
+ * Make sure all data we wrote to the backing device is actually
+ * stable on disk.
+ */
+ if (bs->backing_hd)
+ bdrv_flush(bs->backing_hd);
return 0;
}
@@ -1115,12 +1121,8 @@ const char *bdrv_get_device_name(BlockDriverState *bs)
void bdrv_flush(BlockDriverState *bs)
{
- if (!bs->drv)
- return;
- if (bs->drv->bdrv_flush)
+ if (bs->drv && bs->drv->bdrv_flush)
bs->drv->bdrv_flush(bs);
- if (bs->backing_hd)
- bdrv_flush(bs->backing_hd);
}
void bdrv_flush_all(void)
@@ -1797,11 +1799,6 @@ BlockDriverAIOCB *bdrv_aio_flush(BlockDriverState *bs,
if (!drv)
return NULL;
-
- /*
- * Note that unlike bdrv_flush the driver is reponsible for flushing a
- * backing image if it exists.
- */
return drv->bdrv_aio_flush(bs, cb, opaque);
}