[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 04/13] block/linux-aio: do more things in laio_state
From: |
Ming Lei |
Subject: |
[Qemu-devel] [PATCH 04/13] block/linux-aio: do more things in laio_state_alloc() and its pair |
Date: |
Sun, 9 Nov 2014 15:42:49 +0800 |
Now lifetime of 'completion_bh', io queue and io context is same,
so move their allocation into laio_state_alloc() and their
releasing into laio_state_free().
Signed-off-by: Ming Lei <address@hidden>
---
block/linux-aio.c | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/block/linux-aio.c b/block/linux-aio.c
index 5fa3c1e..95cd0dc 100644
--- a/block/linux-aio.c
+++ b/block/linux-aio.c
@@ -388,7 +388,7 @@ static void laio_free_ioq(struct qemu_laio_state *s,
LaioQueue *ioq)
s->io_q = NULL;
}
-static struct qemu_laio_state *laio_state_alloc(void)
+static struct qemu_laio_state *laio_state_alloc(AioContext *context)
{
struct qemu_laio_state *s;
@@ -401,6 +401,10 @@ static struct qemu_laio_state *laio_state_alloc(void)
goto out_close_efd;
}
+ s->io_q = laio_alloc_ioq(context, s);
+ s->completion_bh = aio_bh_new(context, qemu_laio_completion_bh, s);
+ aio_set_event_notifier(context, &s->e, qemu_laio_completion_cb);
+
return s;
out_close_efd:
@@ -410,8 +414,12 @@ out_free_state:
return NULL;
}
-static void laio_state_free(struct qemu_laio_state *s)
+static void laio_state_free(struct qemu_laio_state *s, AioContext *context)
{
+ aio_set_event_notifier(context, &s->e, NULL);
+ qemu_bh_delete(s->completion_bh);
+
+ laio_free_ioq(s, s->io_q);
event_notifier_cleanup(&s->e);
if (io_destroy(s->ctx) != 0) {
@@ -424,25 +432,15 @@ static void laio_state_free(struct qemu_laio_state *s)
void laio_detach_aio_context(void *s_, AioContext *old_context)
{
QemuLaioState *qs = s_;
- struct qemu_laio_state *s = qs->state;
- aio_set_event_notifier(old_context, &s->e, NULL);
- qemu_bh_delete(s->completion_bh);
-
- laio_free_ioq(s, s->io_q);
- laio_state_free(s);
+ laio_state_free(qs->state, old_context);
qs->state = NULL;
}
void laio_attach_aio_context(void *s_, AioContext *new_context)
{
QemuLaioState *qs = s_;
- struct qemu_laio_state *s = laio_state_alloc();
-
- s->io_q = laio_alloc_ioq(new_context, s);
-
- s->completion_bh = aio_bh_new(new_context, qemu_laio_completion_bh, s);
- aio_set_event_notifier(new_context, &s->e, qemu_laio_completion_cb);
+ struct qemu_laio_state *s = laio_state_alloc(new_context);
qs->state = s;
}
--
1.7.9.5
- [Qemu-devel] [PATCH 00/13] linux-aio/virtio-scsi: support AioContext wide IO submission as batch, Ming Lei, 2014/11/09
- [Qemu-devel] [PATCH 01/13] block/linux-aio: allocate io queue dynamically, Ming Lei, 2014/11/09
- [Qemu-devel] [PATCH 02/13] block: linux-aio: rename 'ctx' of qemu_laiocb as 'laio_state', Ming Lei, 2014/11/09
- [Qemu-devel] [PATCH 03/13] block/linux-aio: allocate 'struct qemu_laio_state' dynamically, Ming Lei, 2014/11/09
- [Qemu-devel] [PATCH 04/13] block/linux-aio: do more things in laio_state_alloc() and its pair,
Ming Lei <=
- [Qemu-devel] [PATCH 05/13] block/linux-aio: pass 'BlockDriverState' to laio_attach_aio_context and its pair, Ming Lei, 2014/11/09
- [Qemu-devel] [PATCH 06/13] AioContext: introduce aio_attach_aio_bs() and its pair, Ming Lei, 2014/11/09
- [Qemu-devel] [PATCH 07/13] block/linux-aio: support IO submission as batch in AioContext wide, Ming Lei, 2014/11/09
- [Qemu-devel] [PATCH 08/13] block/linux-aio.c: allocate events dynamically, Ming Lei, 2014/11/09
- [Qemu-devel] [PATCH 09/13] block/linux-aio.c: introduce laio_alloc_resource(), Ming Lei, 2014/11/09
- [Qemu-devel] [PATCH 10/13] block/linux-aio.c: prepare for elastical resource's allocation, Ming Lei, 2014/11/09
- [Qemu-devel] [PATCH 11/13] block/linux-aio: reallocate I/O resources when aio attached, Ming Lei, 2014/11/09
- [Qemu-devel] [PATCH 12/13] block: introduce bdrv_aio_io_plug() and its pair, Ming Lei, 2014/11/09
- [Qemu-devel] [PATCH 13/13] virtio-scsi-dataplane: support AioContext wide IO submission as batch, Ming Lei, 2014/11/09
- Re: [Qemu-devel] [PATCH 00/13] linux-aio/virtio-scsi: support AioContext wide IO submission as batch, Paolo Bonzini, 2014/11/18