diff options
author | Kevin Wolf <kwolf@redhat.com> | 2016-11-18 14:16:42 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2017-06-26 14:51:15 +0200 |
commit | 018598747c775394471ce4a341a1ce225a1738dc (patch) | |
tree | 80835d2954b2bccc696d961178640b1e567d4d58 /block/qed.c | |
parent | dddf8db10b47d34d9d469ffe45e000170666ecdd (diff) |
qed: Remove recursion in qed_aio_next_io()
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 <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block/qed.c')
-rw-r--r-- | block/qed.c | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/block/qed.c b/block/qed.c index db80987dc3..e7621693e2 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, |