From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 3/7] posix-aio: merge posix_aio_process_queue and posix_aio_read
Date: Mon, 12 Mar 2012 19:22:24 +0100 [thread overview]
Message-ID: <1331576548-23067-4-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1331576548-23067-1-git-send-email-pbonzini@redhat.com>
posix_aio_read already calls qemu_aio_process_queue, and dually
qemu_aio_process_queue is always followed by a select loop that calls
posix_aio_read.
No races are possible, so there is no need for a separate process_queue
callback.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
posix-aio-compat.c | 46 ++++++++++++++++++----------------------------
1 files changed, 18 insertions(+), 28 deletions(-)
diff --git a/posix-aio-compat.c b/posix-aio-compat.c
index d311d13..1066c60 100644
--- a/posix-aio-compat.c
+++ b/posix-aio-compat.c
@@ -468,26 +468,39 @@ static int qemu_paio_error(struct qemu_paiocb *aiocb)
return ret;
}
-static int posix_aio_process_queue(void *opaque)
+static void posix_aio_read(void *opaque)
{
PosixAioState *s = opaque;
struct qemu_paiocb *acb, **pacb;
int ret;
- int result = 0;
+ ssize_t len;
+
+ /* read all bytes from signal pipe */
+ for (;;) {
+ char bytes[16];
+
+ len = read(s->rfd, bytes, sizeof(bytes));
+ if (len == -1 && errno == EINTR) {
+ continue; /* try again */
+ }
+ if (len == sizeof(bytes)) {
+ continue; /* more to read */
+ }
+ break;
+ }
for(;;) {
pacb = &s->first_aio;
for(;;) {
acb = *pacb;
if (!acb)
- return result;
+ return;
ret = qemu_paio_error(acb);
if (ret == ECANCELED) {
/* remove the request */
*pacb = acb->next;
qemu_aio_release(acb);
- result = 1;
} else if (ret != EINPROGRESS) {
/* end of aio */
if (ret == 0) {
@@ -507,35 +518,12 @@ static int posix_aio_process_queue(void *opaque)
/* call the callback */
acb->common.cb(acb->common.opaque, ret);
qemu_aio_release(acb);
- result = 1;
break;
} else {
pacb = &acb->next;
}
}
}
-
- return result;
-}
-
-static void posix_aio_read(void *opaque)
-{
- PosixAioState *s = opaque;
- ssize_t len;
-
- /* read all bytes from signal pipe */
- for (;;) {
- char bytes[16];
-
- len = read(s->rfd, bytes, sizeof(bytes));
- if (len == -1 && errno == EINTR)
- continue; /* try again */
- if (len == sizeof(bytes))
- continue; /* more to read */
- break;
- }
-
- posix_aio_process_queue(s);
}
static int posix_aio_flush(void *opaque)
@@ -676,7 +664,7 @@ int paio_init(void)
fcntl(s->wfd, F_SETFL, O_NONBLOCK);
qemu_aio_set_fd_handler(s->rfd, posix_aio_read, NULL, posix_aio_flush,
- posix_aio_process_queue, s);
+ NULL, s);
ret = pthread_attr_init(&attr);
if (ret)
--
1.7.7.6
next prev parent reply other threads:[~2012-03-12 18:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-12 18:22 [Qemu-devel] [PATCH 0/7] AIO nested loop and bdrv_drain_all changes Paolo Bonzini
2012-03-12 18:22 ` [Qemu-devel] [PATCH 1/7] qemu-io: use main_loop_wait Paolo Bonzini
2012-03-12 18:22 ` [Qemu-devel] [PATCH 2/7] qemu-tool: map vm_clock to rt_clock Paolo Bonzini
2012-03-12 18:22 ` Paolo Bonzini [this message]
2012-03-12 18:22 ` [Qemu-devel] [PATCH 4/7] aio: remove process_queue callback and qemu_aio_process_queue Paolo Bonzini
2012-03-12 18:22 ` [Qemu-devel] [PATCH 5/7] aio: return "AIO in progress" state from qemu_aio_wait Paolo Bonzini
2012-03-12 18:22 ` [Qemu-devel] [PATCH 6/7] aio: simplify qemu_aio_wait Paolo Bonzini
2012-03-12 18:22 ` [Qemu-devel] [PATCH 7/7] block: add the support to drain throttled requests Paolo Bonzini
2012-03-13 1:38 ` Zhi Yong Wu
2012-03-13 1:46 ` Zhi Yong Wu
2012-03-13 1:56 ` Zhi Yong Wu
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=1331576548-23067-4-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.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).