[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v2 19/31] qed: Add return value to qed_aio_write_mai
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PATCH v2 19/31] qed: Add return value to qed_aio_write_main() |
Date: |
Fri, 16 Jun 2017 19:37:04 +0200 |
Don't recurse into qed_aio_next_io() and qed_aio_complete() here, but
just return an error code and let the caller handle it.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
---
block/qed.c | 55 ++++++++++++++++++++++++++++++-------------------------
1 file changed, 30 insertions(+), 25 deletions(-)
diff --git a/block/qed.c b/block/qed.c
index 3cda01f..a4b13f8 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -1022,29 +1022,22 @@ static int qed_aio_write_l2_update(QEDAIOCB *acb,
uint64_t offset)
/**
* Write data to the image file
*/
-static void qed_aio_write_main(void *opaque, int ret)
+static int qed_aio_write_main(QEDAIOCB *acb)
{
- QEDAIOCB *acb = opaque;
BDRVQEDState *s = acb_to_s(acb);
uint64_t offset = acb->cur_cluster +
qed_offset_into_cluster(s, acb->cur_pos);
+ int ret;
- trace_qed_aio_write_main(s, acb, ret, offset, acb->cur_qiov.size);
-
- if (ret) {
- qed_aio_complete(acb, ret);
- return;
- }
+ trace_qed_aio_write_main(s, acb, 0, offset, acb->cur_qiov.size);
BLKDBG_EVENT(s->bs->file, BLKDBG_WRITE_AIO);
ret = bdrv_pwritev(s->bs->file, offset, &acb->cur_qiov);
- if (ret >= 0) {
- ret = 0;
+ if (ret < 0) {
+ return ret;
}
- if (acb->find_cluster_ret == QED_CLUSTER_FOUND) {
- qed_aio_next_io(acb, ret);
- } else {
+ if (acb->find_cluster_ret != QED_CLUSTER_FOUND) {
if (s->bs->backing) {
/*
* Flush new data clusters before updating the L2 table
@@ -1057,20 +1050,16 @@ static void qed_aio_write_main(void *opaque, int ret)
* cluster and before updating the L2 table.
*/
ret = bdrv_flush(s->bs->file->bs);
- }
- if (ret) {
- goto err;
+ if (ret < 0) {
+ return ret;
+ }
}
ret = qed_aio_write_l2_update(acb, acb->cur_cluster);
- if (ret) {
- goto err;
+ if (ret < 0) {
+ return ret;
}
- qed_aio_next_io(acb, 0);
}
- return;
-
-err:
- qed_aio_complete(acb, ret);
+ return 0;
}
/**
@@ -1102,8 +1091,17 @@ static void qed_aio_write_cow(void *opaque, int ret)
trace_qed_aio_write_postfill(s, acb, start, len, offset);
ret = qed_copy_from_backing_file(s, start, len, offset);
+ if (ret) {
+ qed_aio_complete(acb, ret);
+ return;
+ }
- qed_aio_write_main(acb, ret);
+ ret = qed_aio_write_main(acb);
+ if (ret < 0) {
+ qed_aio_complete(acb, ret);
+ return;
+ }
+ qed_aio_next_io(acb, 0);
}
/**
@@ -1201,6 +1199,8 @@ static void qed_aio_write_alloc(QEDAIOCB *acb, size_t len)
*/
static void qed_aio_write_inplace(QEDAIOCB *acb, uint64_t offset, size_t len)
{
+ int ret;
+
/* Allocate buffer for zero writes */
if (acb->flags & QED_AIOCB_ZERO) {
struct iovec *iov = acb->qiov->iov;
@@ -1220,7 +1220,12 @@ static void qed_aio_write_inplace(QEDAIOCB *acb,
uint64_t offset, size_t len)
qemu_iovec_concat(&acb->cur_qiov, acb->qiov, acb->qiov_offset, len);
/* Do the actual write */
- qed_aio_write_main(acb, 0);
+ ret = qed_aio_write_main(acb);
+ if (ret < 0) {
+ qed_aio_complete(acb, ret);
+ return;
+ }
+ qed_aio_next_io(acb, 0);
}
/**
--
1.8.3.1
- [Qemu-block] [PATCH v2 09/31] qed: Make qed_write_header() synchronous, (continued)
- [Qemu-block] [PATCH v2 09/31] qed: Make qed_write_header() synchronous, Kevin Wolf, 2017/06/16
- [Qemu-block] [PATCH v2 10/31] qed: Remove callback from qed_write_header(), Kevin Wolf, 2017/06/16
- [Qemu-block] [PATCH v2 11/31] qed: Make qed_write_table() synchronous, Kevin Wolf, 2017/06/16
- [Qemu-block] [PATCH v2 12/31] qed: Remove GenericCB, Kevin Wolf, 2017/06/16
- [Qemu-block] [PATCH v2 13/31] qed: Remove callback from qed_write_table(), Kevin Wolf, 2017/06/16
- [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 <=
- [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, 2017/06/16
- [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