From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34728) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvrlH-0004kl-Ig for qemu-devel@nongnu.org; Thu, 17 Jan 2013 10:52:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TvrlB-0005wi-FX for qemu-devel@nongnu.org; Thu, 17 Jan 2013 10:52:15 -0500 Received: from nodalink.pck.nerim.net ([62.212.105.220]:44104 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvrlB-0005we-60 for qemu-devel@nongnu.org; Thu, 17 Jan 2013 10:52:09 -0500 From: =?UTF-8?q?Beno=C3=AEt=20Canet?= Date: Thu, 17 Jan 2013 16:51:37 +0100 Message-Id: <1358437897-24251-12-git-send-email-benoit@irqsave.net> In-Reply-To: <1358437897-24251-1-git-send-email-benoit@irqsave.net> References: <1358437897-24251-1-git-send-email-benoit@irqsave.net> Subject: [Qemu-devel] [RFC V6 11/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, pbonzini@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 | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/block/quorum.c b/block/quorum.c index 4bea906..dba2918 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -652,6 +652,35 @@ static int coroutine_fn quorum_co_is_allocated(BlockDriverState *bs, return result; } +static coroutine_fn int quorum_co_flush(BlockDriverState *bs) +{ + BDRVQuorumState *s = bs->opaque; + QuorumVoteVersion *winner = NULL; + QuorumVotes error_votes; + int i; + int result = 0; + bool error = false; + + QLIST_INIT(&error_votes.vote_list); + + for (i = 0; i < s->total; i++) { + result = bdrv_co_flush(s->bs[i]); + if (result) { + error = true; + quorum_count_vote(&error_votes, result, i); + } + } + + if (error) { + winner = quorum_get_vote_winner(&error_votes); + result = winner->value; + } + + quorum_free_vote_list(&error_votes); + + return result; +} + static BlockDriver bdrv_quorum = { .format_name = "quorum", .protocol_name = "quorum", @@ -662,6 +691,7 @@ static BlockDriver bdrv_quorum = { .bdrv_file_open = quorum_open, .bdrv_close = quorum_close, + .bdrv_co_flush_to_disk = quorum_co_flush, .bdrv_aio_readv = quorum_aio_readv, .bdrv_aio_writev = quorum_aio_writev, -- 1.7.10.4