提交 e6b795f3 编写于 作者: P Peter Lieven 提交者: Michael Roth

block: complete all IOs before .bdrv_truncate

bdrv_truncate() invalidates the bdrv_check_request() result for
in-flight requests, so there should better be none.

Cc: qemu-stable@nongnu.org
Signed-off-by: NPeter Lieven <pl@kamp.de>
Reported-by: NKevin Wolf <kwolf@redhat.com>
Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
(cherry picked from commit 9a665b2b)
Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
上级 51968b85
...@@ -2427,6 +2427,10 @@ int bdrv_truncate(BlockDriverState *bs, int64_t offset) ...@@ -2427,6 +2427,10 @@ int bdrv_truncate(BlockDriverState *bs, int64_t offset)
return -EACCES; return -EACCES;
if (bdrv_in_use(bs)) if (bdrv_in_use(bs))
return -EBUSY; return -EBUSY;
/* There better not be any in-flight IOs when we truncate the device. */
bdrv_drain_all();
ret = drv->bdrv_truncate(bs, offset); ret = drv->bdrv_truncate(bs, offset);
if (ret == 0) { if (ret == 0) {
ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS); ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册