]> Git Repo - qemu.git/commitdiff
block: Quiesce old aio context during bdrv_set_aio_context
authorFam Zheng <[email protected]>
Wed, 5 Apr 2017 06:44:24 +0000 (14:44 +0800)
committerFam Zheng <[email protected]>
Tue, 11 Apr 2017 12:07:15 +0000 (20:07 +0800)
The fact that the bs->aio_context is changing can confuse the dataplane
iothread, because of the now fine granularity aio context lock.
bdrv_drain should rather be a bdrv_drained_begin/end pair, but since
bs->aio_context is changing, we can just use aio_disable_external and
bdrv_parent_drained_begin.

Reported-by: Ed Swierk <[email protected]>
Signed-off-by: Fam Zheng <[email protected]>
Acked-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
block.c

diff --git a/block.c b/block.c
index b8a30115e185ccd579a62d1d00089ff993ae19e4..a995a8ec00f6df675ee60820c7d9bd1042db5c2b 100644 (file)
--- a/block.c
+++ b/block.c
@@ -4396,11 +4396,12 @@ void bdrv_attach_aio_context(BlockDriverState *bs,
 
 void bdrv_set_aio_context(BlockDriverState *bs, AioContext *new_context)
 {
-    AioContext *ctx;
+    AioContext *ctx = bdrv_get_aio_context(bs);
 
+    aio_disable_external(ctx);
+    bdrv_parent_drained_begin(bs);
     bdrv_drain(bs); /* ensure there are no in-flight requests */
 
-    ctx = bdrv_get_aio_context(bs);
     while (aio_poll(ctx, false)) {
         /* wait for all bottom halves to execute */
     }
@@ -4412,6 +4413,8 @@ void bdrv_set_aio_context(BlockDriverState *bs, AioContext *new_context)
      */
     aio_context_acquire(new_context);
     bdrv_attach_aio_context(bs, new_context);
+    bdrv_parent_drained_end(bs);
+    aio_enable_external(ctx);
     aio_context_release(new_context);
 }
 
This page took 0.031797 seconds and 4 git commands to generate.