Received: from eggs.gnu.org ([2001:4830:134:3::10]:55958) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRLjM-0007bm-P3 for qemu-devel@nongnu.org; Wed, 02 Oct 2013 08:40:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VRLjH-0007mR-K5 for qemu-devel@nongnu.org; Wed, 02 Oct 2013 08:40:40 -0400 Received: from nodalink.pck.nerim.net ([62.212.105.220]:42260 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRLjH-0007mI-9Z for qemu-devel@nongnu.org; Wed, 02 Oct 2013 08:40:35 -0400 From: =?UTF-8?q?Beno=C3=AEt=20Canet?= Date: Wed, 2 Oct 2013 14:39:23 +0200 Message-Id: <1380717564-11098-11-git-send-email-benoit@irqsave.net> In-Reply-To: <1380717564-11098-1-git-send-email-benoit@irqsave.net> References: <1380717564-11098-1-git-send-email-benoit@irqsave.net> Subject: [Qemu-devel] [PATCH V9 10/11] quorum: Add quorum_co_flush(). List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, =?UTF-8?q?Beno=C3=AEt=20Canet?= , stefanha@redhat.com Makes a vote to select error if any. Signed-off-by: Benoit Canet --- block/quorum.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/block/quorum.c b/block/quorum.c index 084d030..0a28ab1 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -641,12 +641,46 @@ free_exit: return result; } +static coroutine_fn int quorum_co_flush(BlockDriverState *bs) +{ + BDRVQuorumState *s = bs->opaque; + QuorumVoteVersion *winner = NULL; + QuorumVotes error_votes; + QuorumVoteValue result_value; + int i; + int result = 0; + bool error = false; + + QLIST_INIT(&error_votes.vote_list); + error_votes.compare = quorum_64bits_compare; + + for (i = 0; i < s->total; i++) { + result = bdrv_co_flush(&s->bs[i]); + if (result) { + error = true; + result_value.l = result; + quorum_count_vote(&error_votes, &result_value, i); + } + } + + if (error) { + winner = quorum_get_vote_winner(&error_votes); + result = winner->value.l; + } + + quorum_free_vote_list(&error_votes); + + return result; +} + static BlockDriver bdrv_quorum = { .format_name = "quorum", .protocol_name = "quorum", .instance_size = sizeof(BDRVQuorumState), + .bdrv_co_flush_to_disk = quorum_co_flush, + .bdrv_getlength = quorum_getlength, .bdrv_aio_readv = quorum_aio_readv, -- 1.8.1.2