From 7376eda7c2e0451e819e81bd05fabc56a9deb946 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Wed, 7 Mar 2018 12:46:19 +0000 Subject: block: make BDRV_POLL_WHILE() re-entrancy safe Nested BDRV_POLL_WHILE() calls can occur. Currently assert(!wait_->wakeup) fails in AIO_WAIT_WHILE() when this happens. This patch converts the bool wait_->need_kick flag to an unsigned wait_->num_waiters counter. Nesting works correctly because outer AIO_WAIT_WHILE() callers evaluate the condition again after the inner caller completes (invoking the inner caller counts as aio_poll() progress). Reported-by: "fuweiwei (C)" Reviewed-by: Eric Blake Signed-off-by: Stefan Hajnoczi Message-id: 20180307124619.6218-1-stefanha@redhat.com Cc: Paolo Bonzini Signed-off-by: Stefan Hajnoczi --- util/aio-wait.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util') diff --git a/util/aio-wait.c b/util/aio-wait.c index 975afdd..b8a8f86 100644 --- a/util/aio-wait.c +++ b/util/aio-wait.c @@ -34,7 +34,7 @@ static void dummy_bh_cb(void *opaque) void aio_wait_kick(AioWait *wait) { /* The barrier (or an atomic op) is in the caller. */ - if (atomic_read(&wait->need_kick)) { + if (atomic_read(&wait->num_waiters)) { aio_bh_schedule_oneshot(qemu_get_aio_context(), dummy_bh_cb, NULL); } } -- cgit v1.1