mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
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
This commit is contained in:
parent
4e90ccc28e
commit
0187f5c9cb
7 changed files with 58 additions and 111 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue