[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 31/40] qed: introduce qed_aio_start_io and qed_aio_n
From: |
Paolo Bonzini |
Subject: |
[Qemu-block] [PATCH 31/40] qed: introduce qed_aio_start_io and qed_aio_next_io_cb |
Date: |
Tue, 24 Nov 2015 19:01:22 +0100 |
qed_aio_start_io and qed_aio_next_io will not have to acquire/release
the AioContext, while qed_aio_next_io_cb will. Split the functionality
and gain a little type-safety in the process.
Signed-off-by: Paolo Bonzini <address@hidden>
---
block/qed.c | 39 +++++++++++++++++++++++++--------------
1 file changed, 25 insertions(+), 14 deletions(-)
diff --git a/block/qed.c b/block/qed.c
index 9b88895..3d6aa07 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -270,7 +270,19 @@ static CachedL2Table *qed_new_l2_table(BDRVQEDState *s)
return l2_table;
}
-static void qed_aio_next_io(void *opaque, int ret);
+static void qed_aio_next_io(QEDAIOCB *acb, int ret);
+
+static void qed_aio_start_io(QEDAIOCB *acb)
+{
+ qed_aio_next_io(acb, 0);
+}
+
+static void qed_aio_next_io_cb(void *opaque, int ret)
+{
+ QEDAIOCB *acb = opaque;
+
+ qed_aio_next_io(acb, ret);
+}
static void qed_plug_allocating_write_reqs(BDRVQEDState *s)
{
@@ -289,7 +301,7 @@ static void qed_unplug_allocating_write_reqs(BDRVQEDState
*s)
acb = QSIMPLEQ_FIRST(&s->allocating_write_reqs);
if (acb) {
- qed_aio_next_io(acb, 0);
+ qed_aio_start_io(acb);
}
}
@@ -956,7 +968,7 @@ static void qed_aio_complete(QEDAIOCB *acb, int ret)
QSIMPLEQ_REMOVE_HEAD(&s->allocating_write_reqs, next);
acb = QSIMPLEQ_FIRST(&s->allocating_write_reqs);
if (acb) {
- qed_aio_next_io(acb, 0);
+ qed_aio_start_io(acb);
} else if (s->header.features & QED_F_NEED_CHECK) {
qed_start_need_check_timer(s);
}
@@ -981,7 +993,7 @@ static void qed_commit_l2_update(void *opaque, int ret)
acb->request.l2_table = qed_find_l2_cache_entry(&s->l2_cache, l2_offset);
assert(acb->request.l2_table != NULL);
- qed_aio_next_io(opaque, ret);
+ qed_aio_next_io(acb, ret);
}
/**
@@ -1029,11 +1041,11 @@ static void qed_aio_write_l2_update(QEDAIOCB *acb, int
ret, uint64_t offset)
if (need_alloc) {
/* Write out the whole new L2 table */
qed_write_l2_table(s, &acb->request, 0, s->table_nelems, true,
- qed_aio_write_l1_update, acb);
+ qed_aio_write_l1_update, acb);
} else {
/* Write out only the updated part of the L2 table */
qed_write_l2_table(s, &acb->request, index, acb->cur_nclusters, false,
- qed_aio_next_io, acb);
+ qed_aio_next_io_cb, acb);
}
return;
@@ -1085,7 +1097,7 @@ static void qed_aio_write_main(void *opaque, int ret)
}
if (acb->find_cluster_ret == QED_CLUSTER_FOUND) {
- next_fn = qed_aio_next_io;
+ next_fn = qed_aio_next_io_cb;
} else {
if (s->bs->backing) {
next_fn = qed_aio_write_flush_before_l2_update;
@@ -1198,7 +1210,7 @@ static void qed_aio_write_alloc(QEDAIOCB *acb, size_t len)
if (acb->flags & QED_AIOCB_ZERO) {
/* Skip ahead if the clusters are already zero */
if (acb->find_cluster_ret == QED_CLUSTER_ZERO) {
- qed_aio_next_io(acb, 0);
+ qed_aio_start_io(acb);
return;
}
@@ -1318,18 +1330,18 @@ static void qed_aio_read_data(void *opaque, int ret,
/* Handle zero cluster and backing file reads */
if (ret == QED_CLUSTER_ZERO) {
qemu_iovec_memset(&acb->cur_qiov, 0, 0, acb->cur_qiov.size);
- qed_aio_next_io(acb, 0);
+ qed_aio_start_io(acb);
return;
} else if (ret != QED_CLUSTER_FOUND) {
qed_read_backing_file(s, acb->cur_pos, &acb->cur_qiov,
- &acb->backing_qiov, qed_aio_next_io, acb);
+ &acb->backing_qiov, qed_aio_next_io_cb, acb);
return;
}
BLKDBG_EVENT(bs->file, BLKDBG_READ_AIO);
bdrv_aio_readv(bs->file->bs, offset / BDRV_SECTOR_SIZE,
&acb->cur_qiov, acb->cur_qiov.size / BDRV_SECTOR_SIZE,
- qed_aio_next_io, acb);
+ qed_aio_next_io_cb, acb);
return;
err:
@@ -1339,9 +1351,8 @@ err:
/**
* Begin next I/O or complete the request
*/
-static void qed_aio_next_io(void *opaque, int ret)
+static void qed_aio_next_io(QEDAIOCB *acb, int ret)
{
- QEDAIOCB *acb = opaque;
BDRVQEDState *s = acb_to_s(acb);
QEDFindClusterFunc *io_fn = (acb->flags & QED_AIOCB_WRITE) ?
qed_aio_write_data : qed_aio_read_data;
@@ -1397,7 +1408,7 @@ static BlockAIOCB *qed_aio_setup(BlockDriverState *bs,
qemu_iovec_init(&acb->cur_qiov, qiov->niov);
/* Start request */
- qed_aio_next_io(acb, 0);
+ qed_aio_start_io(acb);
return &acb->common;
}
--
1.8.3.1
- [Qemu-block] [PATCH 22/40] aio: make ctx->list_lock a QemuLockCnt, subsuming ctx->walking_bh, (continued)
- [Qemu-block] [PATCH 22/40] aio: make ctx->list_lock a QemuLockCnt, subsuming ctx->walking_bh, Paolo Bonzini, 2015/11/24
- [Qemu-block] [PATCH 21/40] qemu-thread: introduce QemuLockCnt, Paolo Bonzini, 2015/11/24
- [Qemu-block] [PATCH 23/40] qemu-thread: optimize QemuLockCnt with futexes on Linux, Paolo Bonzini, 2015/11/24
- [Qemu-block] [PATCH 24/40] aio: tweak walking in dispatch phase, Paolo Bonzini, 2015/11/24
- [Qemu-block] [PATCH 26/40] aio-win32: remove walking_handlers, protecting AioHandler list with list_lock, Paolo Bonzini, 2015/11/24
- [Qemu-block] [PATCH 27/40] aio: document locking, Paolo Bonzini, 2015/11/24
- [Qemu-block] [PATCH 25/40] aio-posix: remove walking_handlers, protecting AioHandler list with list_lock, Paolo Bonzini, 2015/11/24
- [Qemu-block] [PATCH 29/40] quorum: use atomics for rewrite_count, Paolo Bonzini, 2015/11/24
- [Qemu-block] [PATCH 30/40] quorum: split quorum_fifo_aio_cb from quorum_aio_cb, Paolo Bonzini, 2015/11/24
- [Qemu-block] [PATCH 28/40] aio: push aio_context_acquire/release down to dispatching, Paolo Bonzini, 2015/11/24
- [Qemu-block] [PATCH 31/40] qed: introduce qed_aio_start_io and qed_aio_next_io_cb,
Paolo Bonzini <=
- [Qemu-block] [PATCH 34/40] block: explicitly acquire aiocontext in timers that need it, Paolo Bonzini, 2015/11/24
- [Qemu-block] [PATCH 33/40] block: explicitly acquire aiocontext in bottom halves that need it, Paolo Bonzini, 2015/11/24
- [Qemu-block] [PATCH 32/40] block: explicitly acquire aiocontext in callbacks that need it, Paolo Bonzini, 2015/11/24
- [Qemu-block] [PATCH 37/40] async: optimize aio_bh_poll, Paolo Bonzini, 2015/11/24
- [Qemu-block] [PATCH 36/40] aio: update locking documentation, Paolo Bonzini, 2015/11/24
- [Qemu-block] [PATCH 35/40] block: explicitly acquire aiocontext in aio callbacks that need it, Paolo Bonzini, 2015/11/24
- [Qemu-block] [PATCH 38/40] aio-posix: partially inline aio_dispatch into aio_poll, Paolo Bonzini, 2015/11/24
- [Qemu-block] [PATCH 40/40] dma-helpers: avoid lock inversion with AioContext, Paolo Bonzini, 2015/11/24
- [Qemu-block] [PATCH 39/40] async: remove unnecessary inc/dec pairs, Paolo Bonzini, 2015/11/24
- Re: [Qemu-block] [Qemu-devel] [RFC PATCH 00/40] Sneak peek of virtio and dataplane changes for 2.6, Christian Borntraeger, 2015/11/26