Skip to contentSkip to conversation

blockdev: use drained_begin/end for qmp_block_resize

PATCH Applied John Snow 4 participants 4 messages May 10, 2017 – May 11, 2017

lore
Share & tools
lore

John Snow

author
#0 lore raw

PATCH 1/1 blockdev: use drained_begin/end for qmp_block_resize

If one tries to issue a block_resize while a guest is busy accessing the disk, it is possible that qemu may deadlock when invoking aio_poll from both the main loop and the iothread.

Replace another instance of bdrv_drain_all that doesn't quite belong.

---
 blockdev.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
blockdev.c +2 -3
index 0b38c3d..9ff06f3 100644
@@ -2923,10 +2923,9 @@ void qmp_block_resize(bool has_device, const char *device,
         goto out;
     }
 
-    /* complete all in-flight operations before resizing the device */
-    bdrv_drain_all();
-
+    bdrv_drained_begin(bs);
     ret = blk_truncate(blk, size, errp);
+    bdrv_drained_end(bs);
 
 out:
     blk_unref(blk);
Signature · 1 line
2.9.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · John Snow

If one tries to issue a block_resize while a guest is busy accessing the disk, it is possible that qemu may deadlock when invoking aio_poll from both the main loop and the iothread.

Quoted 9 lines

Replace another instance of bdrv_drain_all that doesn't quite belong.

---
 blockdev.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
Quoted 18 lines
blockdev.c +2 -3
index 0b38c3d..9ff06f3 100644
@@ -2923,10 +2923,9 @@ void qmp_block_resize(bool has_device, const char *device,
         goto out;
     }
 
-    /* complete all in-flight operations before resizing the device */
-    bdrv_drain_all();
-
+    bdrv_drained_begin(bs);
     ret = blk_truncate(blk, size, errp);
+    bdrv_drained_end(bs);
 
 out:
     blk_unref(blk);
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
Reviewed-by on v1 1/1
#2 lore raw
In reply to John Snow
Quoted 23 lines · John Snow

If one tries to issue a block_resize while a guest is busy accessing the disk, it is possible that qemu may deadlock when invoking aio_poll from both the main loop and the iothread.

Replace another instance of bdrv_drain_all that doesn't quite belong.

---
 blockdev.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
blockdev.c +0 -0
index 0b38c3d..9ff06f3 100644
@@ -2923,10 +2923,9 @@ void qmp_block_resize(bool has_device, const char *device,
         goto out;
     }

blockdev.c void qmp_block_resize(bool has_device, const char *device, · line 2931

Quoted 10 lines
blockdev.c +2 -3
 
-    /* complete all in-flight operations before resizing the device */
-    bdrv_drain_all();
-
+    bdrv_drained_begin(bs);
     ret = blk_truncate(blk, size, errp);
+    bdrv_drained_end(bs);
 
 out:
     blk_unref(blk);
Applied
#3 lore raw
In reply to John Snow

Am 10.05.2017 um 19:39 hat John Snow geschrieben:

Quoted 11 lines

If one tries to issue a block_resize while a guest is busy accessing the disk, it is possible that qemu may deadlock when invoking aio_poll from both the main loop and the iothread.

Replace another instance of bdrv_drain_all that doesn't quite belong.

Thanks, applied to the block branch.

Kevin