From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, pbonzini@redhat.com, stefanha@redhat.com,
qemu-block@nongnu.org
Subject: [Qemu-devel] [RFC PATCH 04/11] aio-win32: Implement aio_poll_clients
Date: Thu, 23 Jul 2015 14:32:11 +0800 [thread overview]
Message-ID: <1437633138-29188-5-git-send-email-famz@redhat.com> (raw)
In-Reply-To: <1437633138-29188-1-git-send-email-famz@redhat.com>
This is the counterpart of for windows.
Signed-off-by: Fam Zheng <famz@redhat.com>
---
aio-win32.c | 34 ++++++++++++++++++++++++++--------
1 file changed, 26 insertions(+), 8 deletions(-)
diff --git a/aio-win32.c b/aio-win32.c
index f5ecf57..c925085 100644
--- a/aio-win32.c
+++ b/aio-win32.c
@@ -149,7 +149,7 @@ void aio_set_event_notifier(AioContext *ctx,
aio_notify(ctx);
}
-bool aio_prepare(AioContext *ctx)
+static bool aio_prepare_clients(AioContext *ctx, int client_mask)
{
static struct timeval tv0;
AioHandler *node;
@@ -160,6 +160,9 @@ bool aio_prepare(AioContext *ctx)
FD_ZERO(&rfds);
FD_ZERO(&wfds);
QLIST_FOREACH(node, &ctx->aio_handlers, node) {
+ if ((node->type & client_mask) != node->type) {
+ continue;
+ }
if (node->io_read) {
FD_SET ((SOCKET)node->pfd.fd, &rfds);
}
@@ -170,6 +173,9 @@ bool aio_prepare(AioContext *ctx)
if (select(0, &rfds, &wfds, NULL, &tv0) > 0) {
QLIST_FOREACH(node, &ctx->aio_handlers, node) {
+ if ((node->type & client_mask) != node->type) {
+ continue;
+ }
node->pfd.revents = 0;
if (FD_ISSET(node->pfd.fd, &rfds)) {
node->pfd.revents |= G_IO_IN;
@@ -186,6 +192,11 @@ bool aio_prepare(AioContext *ctx)
return have_select_revents;
}
+bool aio_prepare(AioContext *ctx)
+{
+ return aio_prepare_clients(ctx, AIO_CLIENT_MASK_ALL);
+}
+
bool aio_pending(AioContext *ctx)
{
AioHandler *node;
@@ -206,7 +217,8 @@ bool aio_pending(AioContext *ctx)
return false;
}
-static bool aio_dispatch_handlers(AioContext *ctx, HANDLE event)
+static bool aio_dispatch_handlers(AioContext *ctx, HANDLE event,
+ int client_mask)
{
AioHandler *node;
bool progress = false;
@@ -219,10 +231,11 @@ static bool aio_dispatch_handlers(AioContext *ctx, HANDLE event)
while (node) {
AioHandler *tmp;
int revents = node->pfd.revents;
+ bool dispatch = (node->type & client_mask) == node->type;
ctx->walking_handlers++;
- if (!node->deleted &&
+ if (dispatch && !node->deleted &&
(revents || event_notifier_get_handle(node->e) == event) &&
node->io_notify) {
node->pfd.revents = 0;
@@ -234,7 +247,7 @@ static bool aio_dispatch_handlers(AioContext *ctx, HANDLE event)
}
}
- if (!node->deleted &&
+ if (dispatch && !node->deleted &&
(node->io_read || node->io_write)) {
node->pfd.revents = 0;
if ((revents & G_IO_IN) && node->io_read) {
@@ -256,6 +269,7 @@ static bool aio_dispatch_handlers(AioContext *ctx, HANDLE event)
}
}
+next:
tmp = node;
node = QLIST_NEXT(node, node);
@@ -275,12 +289,13 @@ bool aio_dispatch(AioContext *ctx)
bool progress;
progress = aio_bh_poll(ctx);
- progress |= aio_dispatch_handlers(ctx, INVALID_HANDLE_VALUE);
+ progress |= aio_dispatch_handlers(ctx, INVALID_HANDLE_VALUE,
+ AIO_CLIENT_MASK_ALL);
progress |= timerlistgroup_run_timers(&ctx->tlg);
return progress;
}
-bool aio_poll(AioContext *ctx, bool blocking)
+bool aio_poll_clients(AioContext *ctx, bool blocking, int client_mask)
{
AioHandler *node;
HANDLE events[MAXIMUM_WAIT_OBJECTS + 1];
@@ -302,13 +317,16 @@ bool aio_poll(AioContext *ctx, bool blocking)
atomic_add(&ctx->notify_me, 2);
}
- have_select_revents = aio_prepare(ctx);
+ have_select_revents = aio_prepare_clients(ctx, client_mask);
ctx->walking_handlers++;
/* fill fd sets */
count = 0;
QLIST_FOREACH(node, &ctx->aio_handlers, node) {
+ if ((node->type & client_mask) != node->type) {
+ continue;
+ }
if (!node->deleted && node->io_notify) {
events[count++] = event_notifier_get_handle(node->e);
}
@@ -360,7 +378,7 @@ bool aio_poll(AioContext *ctx, bool blocking)
have_select_revents = false;
blocking = false;
- progress |= aio_dispatch_handlers(ctx, event);
+ progress |= aio_dispatch_handlers(ctx, event, client_mask);
} while (count > 0);
progress |= timerlistgroup_run_timers(&ctx->tlg);
--
2.4.3
next prev parent reply other threads:[~2015-07-23 6:32 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-23 6:32 [Qemu-devel] [RFC PATCH 00/11] aio: Introduce handler type to fix nested aio_poll for dataplane Fam Zheng
2015-07-23 6:32 ` [Qemu-devel] [RFC PATCH 01/11] aio: Introduce "type" in aio_set_fd_handler and aio_set_event_notifier Fam Zheng
2015-07-23 6:32 ` [Qemu-devel] [RFC PATCH 02/11] aio: Save type to AioHandler Fam Zheng
2015-07-23 6:32 ` [Qemu-devel] [RFC PATCH 03/11] aio-posix: Introduce aio_poll_clients Fam Zheng
2015-07-23 6:32 ` Fam Zheng [this message]
2015-07-23 6:32 ` [Qemu-devel] [RFC PATCH 05/11] block: Mark fd handlers as "protocol" Fam Zheng
2015-07-23 6:32 ` [Qemu-devel] [RFC PATCH 06/11] nbd: Mark fd handlers client type as "nbd server" Fam Zheng
2015-07-23 6:32 ` [Qemu-devel] [RFC PATCH 07/11] aio: Mark ctx->notifier's client type as "context" Fam Zheng
2015-07-23 6:32 ` [Qemu-devel] [RFC PATCH 08/11] dataplane: Mark host notifiers' client type as "dataplane" Fam Zheng
2015-07-23 6:32 ` [Qemu-devel] [RFC PATCH 09/11] block: Introduce bdrv_aio_poll Fam Zheng
2015-07-23 6:32 ` [Qemu-devel] [RFC PATCH 10/11] block: Replace nested aio_poll with bdrv_aio_poll Fam Zheng
2015-07-23 6:32 ` [Qemu-devel] [RFC PATCH 11/11] block: Only poll block layer fds in bdrv_aio_poll Fam Zheng
2015-07-23 8:15 ` [Qemu-devel] [RFC PATCH 00/11] aio: Introduce handler type to fix nested aio_poll for dataplane Paolo Bonzini
2015-07-23 11:43 ` Fam Zheng
2015-07-24 7:35 ` Paolo Bonzini
2015-07-27 6:55 ` Fam Zheng
2015-07-27 13:23 ` Paolo Bonzini
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=1437633138-29188-5-git-send-email-famz@redhat.com \
--to=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).