[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 02/11] block: Quiesce old aio context during bdrv_set
From: |
Fam Zheng |
Subject: |
[Qemu-devel] [PULL 02/11] block: Quiesce old aio context during bdrv_set_aio_context |
Date: |
Tue, 11 Apr 2017 20:26:23 +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 <address@hidden>
Signed-off-by: Fam Zheng <address@hidden>
Acked-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
---
block.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/block.c b/block.c
index b8a3011..a995a8e 100644
--- 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);
}
--
2.9.3
- [Qemu-devel] [PULL 00/11] Block patches for 2.9-rc4, Fam Zheng, 2017/04/11
- [Qemu-devel] [PULL 01/11] block: Make bdrv_parent_drained_begin/end public, Fam Zheng, 2017/04/11
- [Qemu-devel] [PULL 02/11] block: Quiesce old aio context during bdrv_set_aio_context,
Fam Zheng <=
- [Qemu-devel] [PULL 03/11] tests/block-job-txn: Don't start block job before adding to txn, Fam Zheng, 2017/04/11
- [Qemu-devel] [PULL 04/11] coroutine: Extract qemu_aio_coroutine_enter, Fam Zheng, 2017/04/11
- [Qemu-devel] [PULL 05/11] async: Introduce aio_co_enter, Fam Zheng, 2017/04/11
- [Qemu-devel] [PULL 06/11] block: Introduce bdrv_coroutine_enter, Fam Zheng, 2017/04/11
- [Qemu-devel] [PULL 07/11] blockjob: Use bdrv_coroutine_enter to start coroutine, Fam Zheng, 2017/04/11
- [Qemu-devel] [PULL 08/11] qemu-io-cmds: Use bdrv_coroutine_enter, Fam Zheng, 2017/04/11
- [Qemu-devel] [PULL 09/11] block: Use bdrv_coroutine_enter to start I/O coroutines, Fam Zheng, 2017/04/11
- [Qemu-devel] [PULL 11/11] sheepdog: Use bdrv_coroutine_enter before BDRV_POLL_WHILE, Fam Zheng, 2017/04/11
- [Qemu-devel] [PULL 10/11] block: Fix bdrv_co_flush early return, Fam Zheng, 2017/04/11