>From main loop, bdrv_set_aio_context() can call IOThread's aio_poll(). That breaks aio_notify() because the ctx->notifier event can get cleared too early by this which causes IOThread hanging.
See https://bugzilla.redhat.com/show_bug.cgi?id=1562750 for details. Signed-off-by: Fam Zheng <f...@redhat.com> --- util/async.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/util/async.c b/util/async.c index 05979f8014..c6e8aebc3a 100644 --- a/util/async.c +++ b/util/async.c @@ -355,7 +355,11 @@ void aio_notify(AioContext *ctx) void aio_notify_accept(AioContext *ctx) { - if (atomic_xchg(&ctx->notified, false)) { + /* If ctx->notify_me >= 2, another aio_poll() is waiting which may need the + * ctx->notifier event to wake up, so don't already clear it just because "we" are + * done iterating. */ + if (atomic_read(&ctx->notify_me) < 2 + && atomic_xchg(&ctx->notified, false)) { event_notifier_test_and_clear(&ctx->notifier); } } -- 2.17.1