This is simpler than taking and releasing the AioContext lock.
Signed-off-by: Paolo Bonzini <[email protected]>
---
block/quorum.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/block/quorum.c b/block/quorum.c
index b9ba028..3b19c9e 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -250,15 +250,10 @@ static void quorum_rewrite_aio_cb(void *opaque, int ret)
{
QuorumAIOCB *acb = opaque;
- /* one less rewrite to do */
- acb->rewrite_count--;
-
/* wait until all rewrite callbacks have completed */
- if (acb->rewrite_count) {
- return;
+ if (atomic_fetch_dec(&acb->rewrite_count) == 1) {
+ quorum_aio_finalize(acb);
}
-
- quorum_aio_finalize(acb);
}
static BlockAIOCB *read_fifo_child(QuorumAIOCB *acb);
@@ -361,7 +356,7 @@ static bool quorum_rewrite_bad_versions(BDRVQuorumState *s,
QuorumAIOCB *acb,
}
/* quorum_rewrite_aio_cb will count down this to zero */
- acb->rewrite_count = count;
+ atomic_mb_set(&acb->rewrite_count, count);
/* now fire the correcting rewrites */
QLIST_FOREACH(version, &acb->votes.vote_list, next) {
--
1.8.3.1