Patchwork [17/22] block: complete all IOs before .bdrv_truncate

login
register
mail settings
Submitter Kevin Wolf
Date Feb. 22, 2013, 9:23 p.m.
Message ID <1361568231-18198-18-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/222679/
State New
Headers show

Comments

Kevin Wolf - Feb. 22, 2013, 9:23 p.m.
From: Peter Lieven <pl@dlhnet.de>

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: Peter Lieven <pl@kamp.de>
Reported-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c | 4 ++++
 1 file changed, 4 insertions(+)

Patch

diff --git a/block.c b/block.c
index a4d7125..f184b37 100644
--- a/block.c
+++ b/block.c
@@ -2427,6 +2427,10 @@  int bdrv_truncate(BlockDriverState *bs, int64_t offset)
         return -EACCES;
     if (bdrv_in_use(bs))
         return -EBUSY;
+
+    /* There better not be any in-flight IOs when we truncate the device. */
+    bdrv_drain_all();
+
     ret = drv->bdrv_truncate(bs, offset);
     if (ret == 0) {
         ret = refresh_total_sectors(bs, offset >> BDRV_SECTOR_BITS);