Patchwork [2/3] block: complete all IOs before resizing a device

login
register
mail settings
Submitter Peter Lieven
Date March 11, 2013, 10:04 a.m.
Message ID <513DAC28.8090303@dlhnet.de>
Download mbox | patch
Permalink /patch/226510/
State New
Headers show

Comments

Peter Lieven - March 11, 2013, 10:04 a.m.
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>
---
  blockdev.c |    3 +++
  1 file changed, 3 insertions(+)
Kevin Wolf - March 19, 2013, 1:11 p.m.
Am 11.03.2013 um 11:04 hat Peter Lieven geschrieben:
> 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>

Thanks, applied to the block branch.

Kevin

Patch

diff --git a/blockdev.c b/blockdev.c
index 0e67d06..be36ed7 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1062,6 +1062,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;