From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Anthony Liguori <aliguori@us.ibm.com>,
pingfank@linux.vnet.ibm.com
Subject: [Qemu-devel] [RFC 03/13] aio: stop using .io_flush()
Date: Thu, 11 Apr 2013 17:44:35 +0200 [thread overview]
Message-ID: <1365695085-27970-4-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1365695085-27970-1-git-send-email-stefanha@redhat.com>
Now that bdrv_drain_all() checks that requests are pending before
calling qemu_aio_wait(), it is no longer necessary to call .io_flush()
handlers.
Behavior of aio_poll() changes as follows:
.io_flush() is no longer invoked and file descriptors are *always*
monitored. Previously returning 0 from .io_flush() would skip this file
descriptor.
Due to these changes it is essential to check that requests are pending
before calling qemu_aio_wait(). Failure to do so means we block, for
example, waiting for an idle iSCSI socket to become readable when there
are no requests. Currently all qemu_aio_wait()/aio_poll() callers check
before calling.
The next patches will remove .io_flush() handler code until we can
finally drop the io_flush arguments to aio_set_fd_handler() and friends.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
aio-posix.c | 24 ++----------------------
aio-win32.c | 23 ++---------------------
2 files changed, 4 insertions(+), 43 deletions(-)
diff --git a/aio-posix.c b/aio-posix.c
index b68eccd..569e603 100644
--- a/aio-posix.c
+++ b/aio-posix.c
@@ -23,7 +23,6 @@ struct AioHandler
GPollFD pfd;
IOHandler *io_read;
IOHandler *io_write;
- AioFlushHandler *io_flush;
int deleted;
int pollfds_idx;
void *opaque;
@@ -84,7 +83,6 @@ void aio_set_fd_handler(AioContext *ctx,
/* Update handler with latest information */
node->io_read = io_read;
node->io_write = io_write;
- node->io_flush = io_flush;
node->opaque = opaque;
node->pollfds_idx = -1;
@@ -173,7 +171,7 @@ bool aio_poll(AioContext *ctx, bool blocking)
{
AioHandler *node;
int ret;
- bool busy, progress;
+ bool progress;
progress = false;
@@ -200,20 +198,8 @@ bool aio_poll(AioContext *ctx, bool blocking)
g_array_set_size(ctx->pollfds, 0);
/* fill pollfds */
- busy = false;
QLIST_FOREACH(node, &ctx->aio_handlers, node) {
node->pollfds_idx = -1;
-
- /* If there aren't pending AIO operations, don't invoke callbacks.
- * Otherwise, if there are no AIO requests, qemu_aio_wait() would
- * wait indefinitely.
- */
- if (!node->deleted && node->io_flush) {
- if (node->io_flush(node->opaque) == 0) {
- continue;
- }
- busy = true;
- }
if (!node->deleted && node->pfd.events) {
GPollFD pfd = {
.fd = node->pfd.fd,
@@ -226,11 +212,6 @@ bool aio_poll(AioContext *ctx, bool blocking)
ctx->walking_handlers--;
- /* No AIO operations? Get us out of here */
- if (!busy) {
- return progress;
- }
-
/* wait until next event */
ret = g_poll((GPollFD *)ctx->pollfds->data,
ctx->pollfds->len,
@@ -250,6 +231,5 @@ bool aio_poll(AioContext *ctx, bool blocking)
}
}
- assert(progress || busy);
- return true;
+ return progress;
}
diff --git a/aio-win32.c b/aio-win32.c
index 38723bf..0980d08 100644
--- a/aio-win32.c
+++ b/aio-win32.c
@@ -23,7 +23,6 @@
struct AioHandler {
EventNotifier *e;
EventNotifierHandler *io_notify;
- AioFlushEventNotifierHandler *io_flush;
GPollFD pfd;
int deleted;
QLIST_ENTRY(AioHandler) node;
@@ -73,7 +72,6 @@ void aio_set_event_notifier(AioContext *ctx,
}
/* Update handler with latest information */
node->io_notify = io_notify;
- node->io_flush = io_flush;
}
aio_notify(ctx);
@@ -96,7 +94,7 @@ bool aio_poll(AioContext *ctx, bool blocking)
{
AioHandler *node;
HANDLE events[MAXIMUM_WAIT_OBJECTS + 1];
- bool busy, progress;
+ bool progress;
int count;
progress = false;
@@ -147,19 +145,8 @@ bool aio_poll(AioContext *ctx, bool blocking)
ctx->walking_handlers++;
/* fill fd sets */
- busy = false;
count = 0;
QLIST_FOREACH(node, &ctx->aio_handlers, node) {
- /* If there aren't pending AIO operations, don't invoke callbacks.
- * Otherwise, if there are no AIO requests, qemu_aio_wait() would
- * wait indefinitely.
- */
- if (!node->deleted && node->io_flush) {
- if (node->io_flush(node->e) == 0) {
- continue;
- }
- busy = true;
- }
if (!node->deleted && node->io_notify) {
events[count++] = event_notifier_get_handle(node->e);
}
@@ -167,11 +154,6 @@ bool aio_poll(AioContext *ctx, bool blocking)
ctx->walking_handlers--;
- /* No AIO operations? Get us out of here */
- if (!busy) {
- return progress;
- }
-
/* wait until next event */
while (count > 0) {
int timeout = blocking ? INFINITE : 0;
@@ -214,6 +196,5 @@ bool aio_poll(AioContext *ctx, bool blocking)
events[ret - WAIT_OBJECT_0] = events[--count];
}
- assert(progress || busy);
- return true;
+ return progress;
}
--
1.8.1.4
next prev parent reply other threads:[~2013-04-11 15:45 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-11 15:44 [Qemu-devel] [RFC 00/13] aio: drop io_flush() Stefan Hajnoczi
2013-04-11 15:44 ` [Qemu-devel] [RFC 01/13] block: stop relying on io_flush() in bdrv_drain_all() Stefan Hajnoczi
2013-04-11 15:44 ` [Qemu-devel] [RFC 02/13] dataplane/virtio-blk: check exit conditions before aio_poll() Stefan Hajnoczi
2013-04-11 15:44 ` Stefan Hajnoczi [this message]
2013-04-11 15:44 ` [Qemu-devel] [RFC 04/13] block/curl: drop curl_aio_flush() Stefan Hajnoczi
2013-04-11 15:44 ` [Qemu-devel] [RFC 05/13] block/gluster: drop qemu_gluster_aio_flush_cb() Stefan Hajnoczi
2013-04-11 15:44 ` [Qemu-devel] [RFC 06/13] block/iscsi: drop iscsi_process_flush() Stefan Hajnoczi
2013-04-11 15:44 ` [Qemu-devel] [RFC 07/13] block/linux-aio: drop qemu_laio_completion_cb() Stefan Hajnoczi
2013-04-11 15:44 ` [Qemu-devel] [RFC 08/13] block/nbd: drop nbd_have_request() Stefan Hajnoczi
2013-04-11 15:44 ` [Qemu-devel] [RFC 09/13] block/rbd: drop qemu_rbd_aio_flush_cb() Stefan Hajnoczi
2013-04-11 15:44 ` [Qemu-devel] [RFC 10/13] block/sheepdog: drop have_co_req() and aio_flush_request() Stefan Hajnoczi
2013-04-11 15:44 ` [Qemu-devel] [RFC 11/13] dataplane/virtio-blk: drop flush_true() and flush_io() Stefan Hajnoczi
2013-04-11 15:44 ` [Qemu-devel] [RFC 12/13] thread-pool: drop thread_pool_active() Stefan Hajnoczi
2013-04-11 15:44 ` [Qemu-devel] [RFC 13/13] aio: drop io_flush argument Stefan Hajnoczi
2013-04-12 8:02 ` [Qemu-devel] [RFC 00/13] aio: drop io_flush() Kevin Wolf
2013-04-12 9:49 ` Stefan Hajnoczi
2013-04-12 10:04 ` Kevin Wolf
2013-04-12 10:27 ` Paolo Bonzini
2013-04-12 12:06 ` Stefan Hajnoczi
2013-04-12 12:22 ` Kevin Wolf
2013-04-12 13:41 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1365695085-27970-4-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=pingfank@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).