diff mbox series

[v3,1/5] block: Keep subtree drained in drop_intermediate

Message ID 20190722133347.15122-2-mreitz@redhat.com
State New
Headers show
Series block: Fixes for concurrent block jobs | expand

Commit Message

Max Reitz July 22, 2019, 1:33 p.m. UTC
bdrv_drop_intermediate() calls BdrvChildRole.update_filename().  That
may poll, thus changing the graph, which potentially breaks the
QLIST_FOREACH_SAFE() loop.

Just keep the whole subtree drained.  This is probably the right thing
to do anyway (dropping nodes while the subtree is not drained seems
wrong).

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/block.c b/block.c
index 9c94f7f28a..818885d467 100644
--- a/block.c
+++ b/block.c
@@ -4499,6 +4499,7 @@  int bdrv_drop_intermediate(BlockDriverState *top, BlockDriverState *base,
     int ret = -EIO;
 
     bdrv_ref(top);
+    bdrv_subtree_drained_begin(top);
 
     if (!top->drv || !base->drv) {
         goto exit;
@@ -4570,6 +4571,7 @@  int bdrv_drop_intermediate(BlockDriverState *top, BlockDriverState *base,
 
     ret = 0;
 exit:
+    bdrv_subtree_drained_end(top);
     bdrv_unref(top);
     return ret;
 }