[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 06/13] AioContext: introduce aio_attach_aio_bs() and
From: |
Ming Lei |
Subject: |
[Qemu-devel] [PATCH 06/13] AioContext: introduce aio_attach_aio_bs() and its pair |
Date: |
Sun, 9 Nov 2014 15:42:51 +0800 |
This patch introduces aio_attach_aio_bs() and its pair
for supporting IO submission as batch in AioContext wide,
and one typical use case is multi-lun SCSI.
aio_attach_aio_bs() will attach one 'bs' which is capable
of IO submission as batch, then all I/O submission in
this AioContext will borrow the io queue from this 'bs',
so that we can maximum IO submission as batch.
aio_detach_aio_bs() will detach the 'bs' when all 'bs'
in the AioContext is detached.
Signed-off-by: Ming Lei <address@hidden>
---
async.c | 1 +
include/block/aio.h | 27 +++++++++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/async.c b/async.c
index 6e1b282..0f4b530 100644
--- a/async.c
+++ b/async.c
@@ -305,6 +305,7 @@ AioContext *aio_context_new(Error **errp)
event_notifier_test_and_clear);
ctx->pollfds = g_array_new(FALSE, FALSE, sizeof(GPollFD));
ctx->thread_pool = NULL;
+ ctx->bs_refcnt = 0;
qemu_mutex_init(&ctx->bh_lock);
rfifolock_init(&ctx->lock, aio_rfifolock_cb, ctx);
timerlistgroup_init(&ctx->tlg, aio_timerlist_notify, ctx);
diff --git a/include/block/aio.h b/include/block/aio.h
index 6bf0e04..e34a21f 100644
--- a/include/block/aio.h
+++ b/include/block/aio.h
@@ -90,6 +90,11 @@ struct AioContext {
/* TimerLists for calling timers - one per clock type */
QEMUTimerListGroup tlg;
+
+ /* IO submit as batch in AioContext wide */
+ BlockDriverState *master_aio_bs;
+ int bs_refcnt;
+ void *opaque;
};
/* Used internally to synchronize aio_poll against qemu_bh_schedule. */
@@ -325,4 +330,26 @@ static inline void aio_timer_init(AioContext *ctx,
*/
int64_t aio_compute_timeout(AioContext *ctx);
+static inline bool aio_attach_aio_bs(AioContext *ctx,
+ BlockDriverState *bs)
+{
+ if (!ctx->bs_refcnt++) {
+ ctx->master_aio_bs = bs;
+ return true;
+ }
+
+ return false;
+}
+
+static inline bool aio_detach_aio_bs(AioContext *ctx,
+ BlockDriverState *bs)
+{
+ if (!--ctx->bs_refcnt) {
+ ctx->master_aio_bs = NULL;
+ return true;
+ }
+
+ return false;
+}
+
#endif
--
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 <=
- [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