提交 3f5075ae 编写于 作者: C Christoph Hellwig 提交者: Anthony Liguori

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: NChristoph Hellwig <hch@lst.de>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 2da69c8d
...@@ -594,6 +594,12 @@ int bdrv_commit(BlockDriverState *bs) ...@@ -594,6 +594,12 @@ int bdrv_commit(BlockDriverState *bs)
if (drv->bdrv_make_empty) if (drv->bdrv_make_empty)
return drv->bdrv_make_empty(bs); 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; return 0;
} }
...@@ -1115,12 +1121,8 @@ const char *bdrv_get_device_name(BlockDriverState *bs) ...@@ -1115,12 +1121,8 @@ const char *bdrv_get_device_name(BlockDriverState *bs)
void bdrv_flush(BlockDriverState *bs) void bdrv_flush(BlockDriverState *bs)
{ {
if (!bs->drv) if (bs->drv && bs->drv->bdrv_flush)
return;
if (bs->drv->bdrv_flush)
bs->drv->bdrv_flush(bs); bs->drv->bdrv_flush(bs);
if (bs->backing_hd)
bdrv_flush(bs->backing_hd);
} }
void bdrv_flush_all(void) void bdrv_flush_all(void)
...@@ -1797,11 +1799,6 @@ BlockDriverAIOCB *bdrv_aio_flush(BlockDriverState *bs, ...@@ -1797,11 +1799,6 @@ BlockDriverAIOCB *bdrv_aio_flush(BlockDriverState *bs,
if (!drv) if (!drv)
return NULL; 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); return drv->bdrv_aio_flush(bs, cb, opaque);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册