[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 07/13] block/linux-aio: support IO submission as bat
From: |
Ming Lei |
Subject: |
[Qemu-devel] [PATCH 07/13] block/linux-aio: support IO submission as batch in AioContext wide |
Date: |
Sun, 9 Nov 2014 15:42:52 +0800 |
This patch supports IO submission as batch in AioContext wide
by sharing 'struct qemu_laio_state' instance among all linux-aio
backend in same AioContext.
Signed-off-by: Ming Lei <address@hidden>
---
block/linux-aio.c | 36 ++++++++++++++++++++++++++++++++++--
1 file changed, 34 insertions(+), 2 deletions(-)
diff --git a/block/linux-aio.c b/block/linux-aio.c
index 17de2e3..c5c7944 100644
--- a/block/linux-aio.c
+++ b/block/linux-aio.c
@@ -52,6 +52,11 @@ typedef struct {
QEMUBH *retry;
} LaioQueue;
+typedef struct LaioTrackedBs {
+ BlockDriverState *bs;
+ QLIST_ENTRY(LaioTrackedBs) list;
+} LaioTrackedBs;
+
/* lifetime: between aio_attach and aio_detach */
struct qemu_laio_state {
io_context_t ctx;
@@ -65,6 +70,9 @@ struct qemu_laio_state {
struct io_event events[MAX_EVENTS];
int event_idx;
int event_max;
+
+ /* All BS in the list shared this 'qemu_laio_state' */
+ QLIST_HEAD(, LaioTrackedBs) tracked_bs;
};
typedef struct {
@@ -433,6 +441,23 @@ void laio_detach_aio_context(void *s_, BlockDriverState
*bs,
AioContext *old_context)
{
QemuLaioState *qs = s_;
+ LaioTrackedBs *tbs, *ntbs;
+
+ QLIST_FOREACH_SAFE(tbs, &qs->state->tracked_bs, list, ntbs) {
+ if (tbs->bs == bs) {
+ QLIST_REMOVE(tbs, list);
+ g_free(tbs);
+ }
+ }
+
+ if (!aio_detach_aio_bs(old_context, bs)) {
+ /* assign new master aio bs for the aio context */
+ if (old_context->master_aio_bs == bs) {
+ tbs = QLIST_FIRST(&qs->state->tracked_bs);
+ old_context->master_aio_bs = tbs->bs;
+ }
+ return;
+ }
laio_state_free(qs->state, old_context);
qs->state = NULL;
@@ -442,9 +467,16 @@ void laio_attach_aio_context(void *s_, BlockDriverState
*bs,
AioContext *new_context)
{
QemuLaioState *qs = s_;
- struct qemu_laio_state *s = laio_state_alloc(new_context);
+ LaioTrackedBs *tbs = g_malloc0(sizeof(*tbs));
+
+ if (aio_attach_aio_bs(new_context, bs)) {
+ new_context->opaque = qs->state = laio_state_alloc(new_context);
+ } else {
+ qs->state = new_context->opaque;
+ }
- qs->state = s;
+ tbs->bs = bs;
+ QLIST_INSERT_HEAD(&qs->state->tracked_bs, tbs, list);
}
void *laio_init(void)
--
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, 2014/11/09
- [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 <=
- [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