[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v2 24/31] qed: Remove recursion in qed_aio_next_io()
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PATCH v2 24/31] qed: Remove recursion in qed_aio_next_io() |
Date: |
Fri, 16 Jun 2017 19:37:09 +0200 |
Instead of calling itself recursively as the last thing, just convert
qed_aio_next_io() into a loop.
This patch is best reviewed with 'git show -w' because most of it is
just whitespace changes.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
---
block/qed.c | 63 +++++++++++++++++++++++++++++++------------------------------
1 file changed, 32 insertions(+), 31 deletions(-)
diff --git a/block/qed.c b/block/qed.c
index db80987..e762169 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -1280,45 +1280,46 @@ static void qed_aio_next_io(QEDAIOCB *acb)
size_t len;
int ret;
- trace_qed_aio_next_io(s, acb, 0, acb->cur_pos + acb->cur_qiov.size);
+ while (1) {
+ trace_qed_aio_next_io(s, acb, 0, acb->cur_pos + acb->cur_qiov.size);
- if (acb->backing_qiov) {
- qemu_iovec_destroy(acb->backing_qiov);
- g_free(acb->backing_qiov);
- acb->backing_qiov = NULL;
- }
+ if (acb->backing_qiov) {
+ qemu_iovec_destroy(acb->backing_qiov);
+ g_free(acb->backing_qiov);
+ acb->backing_qiov = NULL;
+ }
- acb->qiov_offset += acb->cur_qiov.size;
- acb->cur_pos += acb->cur_qiov.size;
- qemu_iovec_reset(&acb->cur_qiov);
+ acb->qiov_offset += acb->cur_qiov.size;
+ acb->cur_pos += acb->cur_qiov.size;
+ qemu_iovec_reset(&acb->cur_qiov);
- /* Complete request */
- if (acb->cur_pos >= acb->end_pos) {
- qed_aio_complete(acb, 0);
- return;
- }
+ /* Complete request */
+ if (acb->cur_pos >= acb->end_pos) {
+ qed_aio_complete(acb, 0);
+ return;
+ }
- /* Find next cluster and start I/O */
- len = acb->end_pos - acb->cur_pos;
- ret = qed_find_cluster(s, &acb->request, acb->cur_pos, &len, &offset);
- if (ret < 0) {
- qed_aio_complete(acb, ret);
- return;
- }
+ /* Find next cluster and start I/O */
+ len = acb->end_pos - acb->cur_pos;
+ ret = qed_find_cluster(s, &acb->request, acb->cur_pos, &len, &offset);
+ if (ret < 0) {
+ qed_aio_complete(acb, ret);
+ return;
+ }
- if (acb->flags & QED_AIOCB_WRITE) {
- ret = qed_aio_write_data(acb, ret, offset, len);
- } else {
- ret = qed_aio_read_data(acb, ret, offset, len);
- }
+ if (acb->flags & QED_AIOCB_WRITE) {
+ ret = qed_aio_write_data(acb, ret, offset, len);
+ } else {
+ ret = qed_aio_read_data(acb, ret, offset, len);
+ }
- if (ret < 0) {
- if (ret != -EINPROGRESS) {
- qed_aio_complete(acb, ret);
+ if (ret < 0) {
+ if (ret != -EINPROGRESS) {
+ qed_aio_complete(acb, ret);
+ }
+ return;
}
- return;
}
- qed_aio_next_io(acb);
}
static BlockAIOCB *qed_aio_setup(BlockDriverState *bs,
--
1.8.3.1
- [Qemu-block] [PATCH v2 16/31] qed: Inline qed_commit_l2_update(), (continued)
- [Qemu-block] [PATCH v2 16/31] qed: Inline qed_commit_l2_update(), Kevin Wolf, 2017/06/16
- [Qemu-block] [PATCH v2 14/31] qed: Make qed_aio_read_data() synchronous, Kevin Wolf, 2017/06/16
- [Qemu-block] [PATCH v2 17/31] qed: Add return value to qed_aio_write_l1_update(), Kevin Wolf, 2017/06/16
- [Qemu-block] [PATCH v2 15/31] qed: Make qed_aio_write_main() synchronous, Kevin Wolf, 2017/06/16
- [Qemu-block] [PATCH v2 18/31] qed: Add return value to qed_aio_write_l2_update(), Kevin Wolf, 2017/06/16
- [Qemu-block] [PATCH v2 19/31] qed: Add return value to qed_aio_write_main(), Kevin Wolf, 2017/06/16
- [Qemu-block] [PATCH v2 20/31] qed: Add return value to qed_aio_write_cow(), Kevin Wolf, 2017/06/16
- [Qemu-block] [PATCH v2 21/31] qed: Add return value to qed_aio_write_inplace/alloc(), Kevin Wolf, 2017/06/16
- [Qemu-block] [PATCH v2 22/31] qed: Add return value to qed_aio_read/write_data(), Kevin Wolf, 2017/06/16
- [Qemu-block] [PATCH v2 23/31] qed: Remove ret argument from qed_aio_next_io(), Kevin Wolf, 2017/06/16
- [Qemu-block] [PATCH v2 24/31] qed: Remove recursion in qed_aio_next_io(),
Kevin Wolf <=
- [Qemu-block] [PATCH v2 25/31] qed: Implement .bdrv_co_readv/writev, Kevin Wolf, 2017/06/16
- [Qemu-block] [PATCH v2 26/31] qed: Use CoQueue for serialising allocations, Kevin Wolf, 2017/06/16
- [Qemu-block] [PATCH v2 27/31] qed: Simplify request handling, Kevin Wolf, 2017/06/16
- [Qemu-block] [PATCH v2 30/31] qed: Use bdrv_co_* for coroutine_fns, Kevin Wolf, 2017/06/16
- [Qemu-block] [PATCH v2 28/31] qed: Use a coroutine for need_check_timer, Kevin Wolf, 2017/06/16
- [Qemu-block] [PATCH v2 29/31] qed: Add coroutine_fn to I/O path functions, Kevin Wolf, 2017/06/16
- [Qemu-block] [PATCH v2 31/31] block: Remove bdrv_aio_readv/writev/flush(), Kevin Wolf, 2017/06/16
- Re: [Qemu-block] [PATCH v2 00/31] qed: Convert to coroutines, Stefan Hajnoczi, 2017/06/19