From patchwork Mon Jan 28 13:22:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Beno=C3=AEt_Canet?= X-Patchwork-Id: 216186 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 068D92C0084 for ; Tue, 29 Jan 2013 00:23:35 +1100 (EST) Received: from localhost ([::1]:34798 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TzogP-000562-3Q for incoming@patchwork.ozlabs.org; Mon, 28 Jan 2013 08:23:33 -0500 Received: from eggs.gnu.org ([208.118.235.92]:41121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tzog8-00053j-21 for qemu-devel@nongnu.org; Mon, 28 Jan 2013 08:23:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tzog5-0006u5-Ci for qemu-devel@nongnu.org; Mon, 28 Jan 2013 08:23:15 -0500 Received: from nodalink.pck.nerim.net ([62.212.105.220]:48299 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tzog4-0006tr-3t for qemu-devel@nongnu.org; Mon, 28 Jan 2013 08:23:13 -0500 Received: by paradis.irqsave.net (Postfix, from userid 1002) id 8B261874321; Mon, 28 Jan 2013 14:23:11 +0100 (CET) Received: from localhost.localdomain (unknown [192.168.77.1]) by paradis.irqsave.net (Postfix) with ESMTP id 8D5DC874328; Mon, 28 Jan 2013 14:22:18 +0100 (CET) From: =?UTF-8?q?Beno=C3=AEt=20Canet?= To: qemu-devel@nongnu.org Date: Mon, 28 Jan 2013 14:22:56 +0100 Message-Id: <1359379379-6017-11-git-send-email-benoit@irqsave.net> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1359379379-6017-1-git-send-email-benoit@irqsave.net> References: <1359379379-6017-1-git-send-email-benoit@irqsave.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 62.212.105.220 Cc: kwolf@redhat.com, =?UTF-8?q?Beno=C3=AEt=20Canet?= , stefanha@redhat.com Subject: [Qemu-devel] [RFC V7 10/13] quorum: Add quorum_co_flush(). X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 ed97a76..ee6bc45 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -579,12 +579,46 @@ 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; + QuorumVoteValue result_value; + int i; + int result = 0; + bool error = false; + + QLIST_INIT(&error_votes.vote_list); + error_votes.compare = quorum_long_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,