aio: make aio_poll(ctx, true) block with no fds
This patch drops a special case where aio_poll(ctx, true) returns false
instead of blocking if no file descriptors are waiting on I/O. Now it
is possible to block in aio_poll() to wait for aio_notify().
This change eliminates busy waiting. bdrv_drain_all() used to rely on
busy waiting to completed throttled I/O requests but this is no longer
required so we can simplify aio_poll().
Note that aio_poll() still returns false when aio_notify() was used. In
other words, stopping a blocking aio_poll() wait is not considered
making progress.
Adjust test-aio /aio/bh/callback-delete/one which assumed aio_poll(ctx,
true) would immediately return false instead of blocking.
Reviewed-by: Alex Bligh <alex@alex.org.uk>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
diff --git a/aio-posix.c b/aio-posix.c
index bd06f33..f921d4f 100644
--- a/aio-posix.c
+++ b/aio-posix.c
@@ -217,11 +217,6 @@
ctx->walking_handlers--;
- /* early return if we only have the aio_notify() fd */
- if (ctx->pollfds->len == 1) {
- return progress;
- }
-
/* wait until next event */
ret = qemu_poll_ns((GPollFD *)ctx->pollfds->data,
ctx->pollfds->len,
diff --git a/aio-win32.c b/aio-win32.c
index f9cfbb7..23f4e5b 100644
--- a/aio-win32.c
+++ b/aio-win32.c
@@ -161,11 +161,6 @@
ctx->walking_handlers--;
- /* early return if we only have the aio_notify() fd */
- if (count == 1) {
- return progress;
- }
-
/* wait until next event */
while (count > 0) {
int ret;
diff --git a/tests/test-aio.c b/tests/test-aio.c
index c4fe0fc..592721e 100644
--- a/tests/test-aio.c
+++ b/tests/test-aio.c
@@ -195,7 +195,6 @@
g_assert(data1.bh == NULL);
g_assert(!aio_poll(ctx, false));
- g_assert(!aio_poll(ctx, true));
}
static void test_bh_delete_from_cb_many(void)