From 77f03db0131c88d607886bb02dd2a4276ab584d4 Mon Sep 17 00:00:00 2001 From: Jeff Darcy Date: Thu, 17 Nov 2016 10:42:02 -0500 Subject: afr: fix auto-quorum (1) afr_have_quorum is dead code. It was copied to afr_has_quorum, and everything else uses that, but the original was never deleted (until now). (2) Auto-quorum should be default for any N>2. Leaving quorum disabled is BAD, but apparently deemed acceptable for N=2 because there's no real quorum in that case. For any larger number (including arbiter configurations) there is such a thing as real quorum and we should use it by default. Note that for N=3 the answers we get from "N % 2" (the old check) and "N > 2" (the new one) are the same. (3) The special case for even N in afr_has_quorum has been simplified and explained more thoroughly in a comment. Change-Id: I48b33c15093512fecf516b26dcf09afecb7ae33b Signed-off-by: Jeff Darcy Reviewed-on: http://review.gluster.org/15873 Smoke: Gluster Build System CentOS-regression: Gluster Build System Reviewed-by: Vijay Bellur NetBSD-regression: NetBSD Build System Reviewed-by: Pranith Kumar Karampuri --- xlators/cluster/afr/src/afr-common.c | 37 ------------------------------------ 1 file changed, 37 deletions(-) (limited to 'xlators/cluster/afr/src/afr-common.c') diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c index 3521e63e6d0..77b68d34c18 100644 --- a/xlators/cluster/afr/src/afr-common.c +++ b/xlators/cluster/afr/src/afr-common.c @@ -5105,43 +5105,6 @@ afr_set_low_priority (call_frame_t *frame) } -gf_boolean_t -afr_have_quorum (char *logname, afr_private_t *priv) -{ - unsigned int quorum = 0; - unsigned int up_children = 0; - - GF_VALIDATE_OR_GOTO(logname,priv,out); - - up_children = __afr_get_up_children_count (priv); - quorum = priv->quorum_count; - if (quorum != AFR_QUORUM_AUTO) - return up_children >= quorum; - - quorum = priv->child_count / 2 + 1; - if (up_children >= quorum) - return _gf_true; - - /* - * Special case for even numbers of nodes: if we have exactly half - * and that includes the first ("senior-most") node, then that counts - * as quorum even if it wouldn't otherwise. This supports e.g. N=2 - * while preserving the critical property that there can only be one - * such group. - */ - if ((priv->child_count % 2) == 0) { - quorum = priv->child_count / 2; - if (up_children >= quorum) { - if (priv->child_up[0]) { - return _gf_true; - } - } - } - -out: - return _gf_false; -} - void afr_priv_destroy (afr_private_t *priv) { -- cgit