[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 4/8] quorum: Do cleanup in caller coroutine
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [RFC PATCH 4/8] quorum: Do cleanup in caller coroutine |
Date: |
Thu, 10 Nov 2016 18:19:05 +0100 |
Instead of calling quorum_aio_finalize() deeply nested in what used
to be an AIO callback, do it in the same functions that allocated the
AIOCB.
Signed-off-by: Kevin Wolf <address@hidden>
---
block/quorum.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/block/quorum.c b/block/quorum.c
index 3cb579e..a225327 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -139,9 +139,8 @@ static bool quorum_vote(QuorumAIOCB *acb);
static void quorum_aio_finalize(QuorumAIOCB *acb)
{
- acb->has_completed = true;
g_free(acb->qcrs);
- qemu_coroutine_enter_if_inactive(acb->co);
+ g_free(acb);
}
static bool quorum_sha256_compare(QuorumVoteValue *a, QuorumVoteValue *b)
@@ -233,7 +232,8 @@ static void quorum_rewrite_aio_cb(void *opaque, int ret)
return;
}
- quorum_aio_finalize(acb);
+ acb->has_completed = true;
+ qemu_coroutine_enter_if_inactive(acb->co);
}
static int read_fifo_child(QuorumAIOCB *acb);
@@ -279,7 +279,7 @@ static int quorum_fifo_aio_cb(void *opaque, int ret)
acb->vote_ret = ret;
/* FIXME: rewrite failed children if acb->children_read > 1? */
- quorum_aio_finalize(acb);
+
return ret;
}
@@ -317,7 +317,8 @@ static void quorum_aio_cb(void *opaque, int ret)
/* if no rewrite is done the code will finish right away */
if (!rewrite) {
- quorum_aio_finalize(acb);
+ acb->has_completed = true;
+ qemu_coroutine_enter_if_inactive(acb->co);
}
}
@@ -716,7 +717,8 @@ static int quorum_co_readv(BlockDriverState *bs,
} else {
ret = read_fifo_child(acb);
}
- g_free(acb);
+ quorum_aio_finalize(acb);
+
return ret;
}
@@ -759,6 +761,7 @@ static int quorum_co_writev(BlockDriverState *bs,
}
ret = acb->vote_ret;
+ quorum_aio_finalize(acb);
return ret;
}
--
1.8.3.1
- [Qemu-devel] [RFC PATCH 0/8] quorum: Implement .bdrv_co_preadv/pwritev(), Kevin Wolf, 2016/11/10
- [Qemu-devel] [RFC PATCH 2/8] quorum: Remove s from quorum_aio_get() arguments, Kevin Wolf, 2016/11/10
- [Qemu-devel] [RFC PATCH 1/8] coroutine: Introduce qemu_coroutine_enter_if_inactive(), Kevin Wolf, 2016/11/10
- [Qemu-devel] [RFC PATCH 4/8] quorum: Do cleanup in caller coroutine,
Kevin Wolf <=
- [Qemu-devel] [RFC PATCH 3/8] quorum: Implement .bdrv_co_readv/writev, Kevin Wolf, 2016/11/10
- [Qemu-devel] [RFC PATCH 5/8] quorum: Inline quorum_aio_cb(), Kevin Wolf, 2016/11/10
- [Qemu-devel] [RFC PATCH 8/8] quorum: Inline quorum_fifo_aio_cb(), Kevin Wolf, 2016/11/10
- [Qemu-devel] [RFC PATCH 7/8] quorum: Implement .bdrv_co_preadv/pwritev(), Kevin Wolf, 2016/11/10