From patchwork Tue Feb 16 02:15:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changlong Xie X-Patchwork-Id: 8320131 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 04C3AC02AA for ; Tue, 16 Feb 2016 02:14:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5D05120357 for ; Tue, 16 Feb 2016 02:14:50 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 86BB620340 for ; Tue, 16 Feb 2016 02:14:49 +0000 (UTC) Received: from localhost ([::1]:38318 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVVA8-0004qm-Rb for patchwork-qemu-devel@patchwork.kernel.org; Mon, 15 Feb 2016 21:14:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVV9w-0004nD-Q2 for qemu-devel@nongnu.org; Mon, 15 Feb 2016 21:14:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aVV9v-0001AZ-0R for qemu-devel@nongnu.org; Mon, 15 Feb 2016 21:14:36 -0500 Received: from [59.151.112.132] (port=29137 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVV9u-00017P-Im for qemu-devel@nongnu.org; Mon, 15 Feb 2016 21:14:34 -0500 X-IronPort-AV: E=Sophos;i="5.20,346,1444665600"; d="scan'208";a="3578657" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 16 Feb 2016 10:14:25 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 146B84219037; Tue, 16 Feb 2016 10:12:51 +0800 (CST) Received: from changlox.g08.fujitsu.local (10.167.225.55) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 16 Feb 2016 10:14:22 +0800 From: Changlong Xie To: qemu devel , Alberto Garcia , Kevin Wolf , Eric Blake Date: Tue, 16 Feb 2016 10:15:44 +0800 Message-ID: <1455588944-29799-2-git-send-email-xiecl.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1455588944-29799-1-git-send-email-xiecl.fnst@cn.fujitsu.com> References: <1455588944-29799-1-git-send-email-xiecl.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.225.55] X-yoursite-MailScanner-ID: 146B84219037.AE480 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: xiecl.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: "Dr. David Alan Gilbert" Subject: [Qemu-devel] [PATCH v2 1/1] quorum: Change vote rules for 64 bits hash 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If quorum has two children(A, B). A do flush sucessfully, but B flush failed. We MUST choice A as winner rather than just pick anyone of them. Otherwise the filesystem of guest will become read-only with following errors: end_request: I/O error, dev vda, sector 11159960 Aborting journal on device vda3-8 EXT4-fs error (device vda3): ext4_journal_start_sb:327: Detected abort journal EXT4-fs (vda3): Remounting filesystem read-only Signed-off-by: Wen Congyang Signed-off-by: Changlong Xie --- block/quorum.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/block/quorum.c b/block/quorum.c index 11cc60b..f094208 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -447,7 +447,8 @@ static int quorum_compute_hash(QuorumAIOCB *acb, int i, QuorumVoteValue *hash) return 0; } -static QuorumVoteVersion *quorum_get_vote_winner(QuorumVotes *votes) +static QuorumVoteVersion *quorum_get_vote_winner(QuorumVotes *votes, + bool vote_error) { int max = 0; QuorumVoteVersion *candidate, *winner = NULL; @@ -456,6 +457,12 @@ static QuorumVoteVersion *quorum_get_vote_winner(QuorumVotes *votes) if (candidate->vote_count > max) { max = candidate->vote_count; winner = candidate; + continue; + } + /* For 64 bit hash */ + if (vote_error && candidate->vote_count == max + && candidate->value.l == 0) { + winner = candidate; } } @@ -545,7 +552,7 @@ static int quorum_vote_error(QuorumAIOCB *acb) } if (error) { - winner = quorum_get_vote_winner(&error_votes); + winner = quorum_get_vote_winner(&error_votes, false); ret = winner->value.l; } @@ -610,7 +617,7 @@ static bool quorum_vote(QuorumAIOCB *acb) } /* vote to select the most represented version */ - winner = quorum_get_vote_winner(&acb->votes); + winner = quorum_get_vote_winner(&acb->votes, false); /* if the winner count is smaller than threshold the read fails */ if (winner->vote_count < s->threshold) { @@ -770,7 +777,7 @@ static coroutine_fn int quorum_co_flush(BlockDriverState *bs) quorum_count_vote(&error_votes, &result_value, i); } - winner = quorum_get_vote_winner(&error_votes); + winner = quorum_get_vote_winner(&error_votes, true); result = winner->value.l; quorum_free_vote_list(&error_votes);