From patchwork Wed Oct 2 12:39:23 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: 279724 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1949D2C007E for ; Wed, 2 Oct 2013 22:41:27 +1000 (EST) Received: from localhost ([::1]:35833 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRLk4-0007iG-W8 for incoming@patchwork.ozlabs.org; Wed, 02 Oct 2013 08:41:25 -0400 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 Received: by paradis.irqsave.net (Postfix, from userid 1002) id 978A88746C6; Wed, 2 Oct 2013 14:40:34 +0200 (CEST) Received: from Laure.example.org (unknown [192.168.77.20]) by paradis.irqsave.net (Postfix) with ESMTP id B2F068746D4; Wed, 2 Oct 2013 14:39:25 +0200 (CEST) From: =?UTF-8?q?Beno=C3=AEt=20Canet?= To: qemu-devel@nongnu.org Date: Wed, 2 Oct 2013 14:39:23 +0200 Message-Id: <1380717564-11098-11-git-send-email-benoit@irqsave.net> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1380717564-11098-1-git-send-email-benoit@irqsave.net> References: <1380717564-11098-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] [PATCH V9 10/11] 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 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,