From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PULL 10/24] qed: introduce qed_aio_start_io and qed_aio_next_io_cb
Date: Mon, 20 Feb 2017 09:32:50 +0000 [thread overview]
Message-ID: <20170220093304.20515-11-stefanha@redhat.com> (raw)
In-Reply-To: <20170220093304.20515-1-stefanha@redhat.com>
From: Paolo Bonzini <pbonzini@redhat.com>
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.
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Message-id: 20170213135235.12274-11-pbonzini@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
block/qed.c | 39 +++++++++++++++++++++++++--------------
1 file changed, 25 insertions(+), 14 deletions(-)
diff --git a/block/qed.c b/block/qed.c
index 1a7ef0a..7f1c508 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -273,7 +273,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)
{
@@ -292,7 +304,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);
}
}
@@ -959,7 +971,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);
}
@@ -984,7 +996,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);
}
/**
@@ -1032,11 +1044,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;
@@ -1088,7 +1100,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;
@@ -1201,7 +1213,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;
}
@@ -1321,18 +1333,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, 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:
@@ -1342,9 +1354,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;
@@ -1400,7 +1411,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;
}
--
2.9.3
next prev parent reply other threads:[~2017-02-20 9:33 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-20 9:32 [Qemu-devel] [PULL 00/24] Block patches Stefan Hajnoczi
2017-02-20 9:32 ` [Qemu-devel] [PULL 01/24] block: move AioContext, QEMUTimer, main-loop to libqemuutil Stefan Hajnoczi
2017-02-20 9:32 ` [Qemu-devel] [PULL 02/24] aio: introduce aio_co_schedule and aio_co_wake Stefan Hajnoczi
2017-02-20 9:32 ` [Qemu-devel] [PULL 03/24] block-backend: allow blk_prw from coroutine context Stefan Hajnoczi
2017-02-20 9:32 ` [Qemu-devel] [PULL 04/24] test-thread-pool: use generic AioContext infrastructure Stefan Hajnoczi
2017-02-20 9:32 ` [Qemu-devel] [PULL 05/24] io: add methods to set I/O handlers on AioContext Stefan Hajnoczi
2017-02-20 9:32 ` [Qemu-devel] [PULL 06/24] io: make qio_channel_yield aware of AioContexts Stefan Hajnoczi
2017-02-20 9:32 ` [Qemu-devel] [PULL 07/24] nbd: convert to use qio_channel_yield Stefan Hajnoczi
2017-02-20 9:32 ` [Qemu-devel] [PULL 08/24] coroutine-lock: reschedule coroutine on the AioContext it was running on Stefan Hajnoczi
2017-02-20 9:32 ` [Qemu-devel] [PULL 09/24] blkdebug: reschedule coroutine on the AioContext it is " Stefan Hajnoczi
2017-02-20 9:32 ` Stefan Hajnoczi [this message]
2017-02-20 9:32 ` [Qemu-devel] [PULL 11/24] aio: push aio_context_acquire/release down to dispatching Stefan Hajnoczi
2017-02-20 9:32 ` [Qemu-devel] [PULL 12/24] block: explicitly acquire aiocontext in timers that need it Stefan Hajnoczi
2017-02-20 9:32 ` [Qemu-devel] [PULL 13/24] block: explicitly acquire aiocontext in callbacks " Stefan Hajnoczi
2017-02-20 9:32 ` [Qemu-devel] [PULL 14/24] block: explicitly acquire aiocontext in bottom halves " Stefan Hajnoczi
2017-02-20 9:32 ` [Qemu-devel] [PULL 15/24] block: explicitly acquire aiocontext in aio callbacks " Stefan Hajnoczi
2017-02-20 9:32 ` [Qemu-devel] [PULL 16/24] aio-posix: partially inline aio_dispatch into aio_poll Stefan Hajnoczi
2017-02-20 9:32 ` [Qemu-devel] [PULL 17/24] async: remove unnecessary inc/dec pairs Stefan Hajnoczi
2017-02-20 9:32 ` [Qemu-devel] [PULL 18/24] block: document fields protected by AioContext lock Stefan Hajnoczi
2017-02-20 9:32 ` [Qemu-devel] [PULL 19/24] coroutine-lock: make CoMutex thread-safe Stefan Hajnoczi
2017-02-20 9:33 ` [Qemu-devel] [PULL 20/24] coroutine-lock: add limited spinning to CoMutex Stefan Hajnoczi
2017-02-20 9:33 ` [Qemu-devel] [PULL 21/24] test-aio-multithread: add performance comparison with thread-based mutexes Stefan Hajnoczi
2017-02-20 9:33 ` [Qemu-devel] [PULL 22/24] coroutine-lock: place CoMutex before CoQueue in header Stefan Hajnoczi
2017-02-20 9:33 ` [Qemu-devel] [PULL 23/24] coroutine-lock: add mutex argument to CoQueue APIs Stefan Hajnoczi
2017-02-20 9:33 ` [Qemu-devel] [PULL 24/24] coroutine-lock: make CoRwlock thread-safe and fair Stefan Hajnoczi
2017-02-20 13:37 ` [Qemu-devel] [PULL 00/24] Block patches Peter Maydell
2017-02-20 13:53 ` Paolo Bonzini
2017-02-21 11:16 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170220093304.20515-11-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).