From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46249) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aY8pZ-0007Tw-OJ for qemu-devel@nongnu.org; Tue, 23 Feb 2016 04:00:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aY8pT-0003B5-TH for qemu-devel@nongnu.org; Tue, 23 Feb 2016 04:00:29 -0500 Received: from [59.151.112.132] (port=27960 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aY8pS-000379-SD for qemu-devel@nongnu.org; Tue, 23 Feb 2016 04:00:23 -0500 From: Changlong Xie Date: Tue, 23 Feb 2016 17:01:39 +0800 Message-ID: <1456218099-386-3-git-send-email-xiecl.fnst@cn.fujitsu.com> In-Reply-To: <1456218099-386-1-git-send-email-xiecl.fnst@cn.fujitsu.com> References: <1456218099-386-1-git-send-email-xiecl.fnst@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH v4 2/2] quorum: modify vote rules for flush operation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu devel , Alberto Garcia , Eric Blake , Kevin Wolf , Max Reitz Cc: "Dr. David Alan Gilbert" Keep flush interface the same logic as quorum read/write, Otherwise in following scenario, we'll encounter unexpected errors. Quorum has two children(A, B). A do flush sucessfully, but B flush failed. This cause the filesystem of guest 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 | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/block/quorum.c b/block/quorum.c index d3c3958..6048208 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -768,19 +768,28 @@ static coroutine_fn int quorum_co_flush(BlockDriverState *bs) QuorumVoteValue result_value; int i; int result = 0; + int success_count = 0; QLIST_INIT(&error_votes.vote_list); error_votes.compare = quorum_64bits_compare; for (i = 0; i < s->num_children; i++) { result = bdrv_co_flush(s->children[i]->bs); - result_value.l = result; - quorum_count_vote(&error_votes, &result_value, i); + if (result) { + quorum_flush_error(s->children[i]->bs->node_name, "Flush failed"); + result_value.l = result; + quorum_count_vote(&error_votes, &result_value, i); + } else { + success_count++; + } } - winner = quorum_get_vote_winner(&error_votes); - result = winner->value.l; - + if (success_count >= s->threshold) { + result = 0; + } else { + winner = quorum_get_vote_winner(&error_votes); + result = winner->value.l; + } quorum_free_vote_list(&error_votes); return result; -- 1.9.3