Patchwork [02/14] block: complete all IOs before resizing a device

login
register
mail settings
Submitter Kevin Wolf
Date March 22, 2013, 5:41 p.m.
Message ID <1363974083-28440-3-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/230217/
State New
Headers show

Comments

Kevin Wolf - March 22, 2013, 5:41 p.m.
From: Peter Lieven <pl@dlhnet.de>

this patch ensures that all pending IOs are completed
before a device is resized. this is especially important
if a device is shrinked as it the bdrv_check_request()
result is invalidated.

Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 blockdev.c | 3 +++
 1 file changed, 3 insertions(+)

Patch

diff --git a/blockdev.c b/blockdev.c
index 09f76b7..6f2b759 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1127,6 +1127,9 @@  void qmp_block_resize(const char *device, int64_t size, Error **errp)
         return;
     }
 
+    /* complete all in-flight operations before resizing the device */
+    bdrv_drain_all();
+
     switch (bdrv_truncate(bs, size)) {
     case 0:
         break;