summaryrefslogtreecommitdiff
path: root/block/linux-aio.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2016-07-04 18:33:20 +0200
committerStefan Hajnoczi <stefanha@redhat.com>2016-07-18 15:09:31 +0100
commit0187f5c9cb172771ba85c66e3bf61f8cde6d6561 (patch)
tree18529868935e436847aa696c35792c116d24af0e /block/linux-aio.c
parent4e90ccc28e53eb92ecbd0cdb67da454d783ea828 (diff)
downloadqemu-0187f5c9cb172771ba85c66e3bf61f8cde6d6561.tar.gz
linux-aio: share one LinuxAioState within an AioContext
This has better performance because it executes fewer system calls and does not use a bottom half per disk. Originally proposed by Ming Lei. [Changed #include "raw-aio.h" to "block/raw-aio.h" in win32-aio.c to fix build error as reported by Peter Maydell <peter.maydell@linaro.org>. --Stefan] Acked-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 1467650000-51385-1-git-send-email-pbonzini@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> squash! linux-aio: share one LinuxAioState within an AioContext
Diffstat (limited to 'block/linux-aio.c')
-rw-r--r--block/linux-aio.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/block/linux-aio.c b/block/linux-aio.c
index 5c104bd3cd..1d702a5fc6 100644
--- a/block/linux-aio.c
+++ b/block/linux-aio.c
@@ -50,6 +50,8 @@ typedef struct {
} LaioQueue;
struct LinuxAioState {
+ AioContext *aio_context;
+
io_context_t ctx;
EventNotifier e;
@@ -227,15 +229,14 @@ static void ioq_submit(LinuxAioState *s)
void laio_io_plug(BlockDriverState *bs, LinuxAioState *s)
{
- assert(!s->io_q.plugged);
- s->io_q.plugged = 1;
+ s->io_q.plugged++;
}
void laio_io_unplug(BlockDriverState *bs, LinuxAioState *s)
{
assert(s->io_q.plugged);
- s->io_q.plugged = 0;
- if (!s->io_q.blocked && !QSIMPLEQ_EMPTY(&s->io_q.pending)) {
+ if (--s->io_q.plugged == 0 &&
+ !s->io_q.blocked && !QSIMPLEQ_EMPTY(&s->io_q.pending)) {
ioq_submit(s);
}
}
@@ -325,6 +326,7 @@ void laio_detach_aio_context(LinuxAioState *s, AioContext *old_context)
void laio_attach_aio_context(LinuxAioState *s, AioContext *new_context)
{
+ s->aio_context = new_context;
s->completion_bh = aio_bh_new(new_context, qemu_laio_completion_bh, s);
aio_set_event_notifier(new_context, &s->e, false,
qemu_laio_completion_cb);