cluster: STABLE3 - qdiskd: Enable master_wins intelligently

Fabio M. Di Nitto fabbione at fedoraproject.org
Tue Mar 2 05:28:29 UTC 2010


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=463a731a9396385a46d2ec5736bfe7ba687968b3
Commit:        463a731a9396385a46d2ec5736bfe7ba687968b3
Parent:        1b02c28d6b10fc2bef9016b956dd474d72f99a1b
Author:        Fabio M. Di Nitto <fdinitto at redhat.com>
AuthorDate:    Tue Mar 2 06:27:51 2010 +0100
Committer:     Fabio M. Di Nitto <fdinitto at redhat.com>
CommitterDate: Tue Mar 2 06:27:51 2010 +0100

qdiskd: Enable master_wins intelligently

In two node clusters with no heuristics, running
qdiskd is useless unless master_wins is set.
This patch enables master_wins by default in this
case.

In order to use this mode automatically on start
up:
 * the quorumd 'votes' parameter must be unset
 * there must be exactly two nodes in the cluster
 * there must be no heuristics configured

If enabled automatically during startup, this mode
will later be disabled if the quorum disk's vote count
changes.  This can occur by:
 * adding a host to the cluster
 * setting the 'votes' parameter to a value other
   than '1'.

Signed-off-by: Lon Hohberger <lhh at redhat.com>
Signed-off-by: Fabio M. Di Nitto <fdinitto at redhat.com>
---
 cman/man/qdisk.5  |   10 ++++++++--
 cman/qdisk/disk.h |    4 +++-
 cman/qdisk/main.c |   22 ++++++++++++++++++++++
 3 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/cman/man/qdisk.5 b/cman/man/qdisk.5
index 7004f01..efa3638 100644
--- a/cman/man/qdisk.5
+++ b/cman/man/qdisk.5
@@ -73,7 +73,7 @@ the amount of synchronous I/O contention on the shared quorum disk.
 * Cluster node IDs must be statically configured in cluster.conf and
 must be numbered from 1..16 (there can be gaps, of course).
 
-* Cluster node votes should all be 1.
+* Cluster node votes must all be 1.
 
 * CMAN must be running before the qdisk program can operate in full
 capacity.  If CMAN is not running, qdisk will wait for it.
@@ -91,7 +91,7 @@ been explored.
 
 * For 'tiebreaker' operation in a two-node cluster, unset CMAN's two_node
 flag (or set it to 0), set CMAN's expected votes to '3', set each node's
-vote to '1', and set qdisk's vote count to '1' as well.  This will allow
+vote to '1', and leave qdisk's vote count unset.  This will allow
 the cluster to operate if either both nodes are online, or a single node &
 the heuristics.
 
@@ -300,6 +300,12 @@ This option only takes effect if there are no heuristics
 configured.  Usage of this option in configurations with more than
 two cluster nodes is undefined and should not be done.
 
+In a two-node cluster with no heuristics and no defined vote
+count (see above), this mode is turned by default.  If enabled in
+this way at startup and a node is later added to the cluster 
+configuration or the vote count is set to a value other than 1, this
+mode will be disabled.
+
 .in 9
 \fIallow_kill\fP\fB="\fP1\fB"\fP
 .in 12
diff --git a/cman/qdisk/disk.h b/cman/qdisk/disk.h
index 8678ca7..93d15fe 100644
--- a/cman/qdisk/disk.h
+++ b/cman/qdisk/disk.h
@@ -55,7 +55,9 @@ typedef enum {
 	RF_UPTIME = 0x20,
 	RF_CMAN_LABEL = 0x40,
 	RF_IOTIMEOUT = 0x80,
-	RF_MASTER_WINS = 0x100
+	RF_MASTER_WINS = 0x100,
+	RF_AUTO_VOTES = 0x200,
+	RF_AUTO_MASTER_WINS = 0x400
 } run_flag_t;
 
 
diff --git a/cman/qdisk/main.c b/cman/qdisk/main.c
index 81218d0..4d1c411 100644
--- a/cman/qdisk/main.c
+++ b/cman/qdisk/main.c
@@ -1526,6 +1526,7 @@ get_dynamic_config_data(qd_ctx *ctx, int ccsfd)
 	/* Get votes */
 	if (ctx->qc_config) {
 		old_votes = ctx->qc_votes;
+		ctx->qc_flags &= ~RF_AUTO_VOTES;
 	}
 
 	snprintf(query, sizeof(query), "/cluster/quorumd/@votes");
@@ -1546,6 +1547,8 @@ get_dynamic_config_data(qd_ctx *ctx, int ccsfd)
 				/* During startup, this is fatal */
 				return -1;
 			}
+		} else {
+			ctx->qc_flags |= RF_AUTO_VOTES;
 		}
 	}
 
@@ -1553,6 +1556,12 @@ get_dynamic_config_data(qd_ctx *ctx, int ccsfd)
 		logt_print(LOG_DEBUG, "Changing vote count from %d to %d\n",
 			   old_votes, ctx->qc_votes);
 
+		if (ctx->qc_flags & RF_AUTO_MASTER_WINS) {
+			logt_print(LOG_DEBUG, "Vote count changed! "
+				   "Disabling master-wins\n");
+			ctx->qc_flags &= ~(RF_MASTER_WINS|RF_AUTO_MASTER_WINS);
+		}
+
 		/*
 		 * This is done in main() normally.  Here, we are
 		 * reconfiguring _only_ the votes at this point.  The 
@@ -1789,6 +1798,19 @@ get_config_data(qd_ctx *ctx, struct h_data *h, int maxh, int *cfh)
 			logt_print(LOG_WARNING, "Master-wins mode disabled\n");
 			ctx->qc_flags &= ~RF_MASTER_WINS;
 		}
+	} else {
+		if (ctx->qc_flags & RF_AUTO_VOTES &&
+		    !(ctx->qc_flags & RF_MASTER_WINS) &&
+		    ctx->qc_votes == 1) { 
+			/* Two node cluster, no heuristics, 1 vote for
+			 * quorum disk daemon.  Safe to enable master-wins.
+			 * In fact, qdiskd without master-wins in this config
+			 * is a waste of resources.
+			 */
+			ctx->qc_flags |= RF_MASTER_WINS | RF_AUTO_MASTER_WINS;
+			logt_print(LOG_INFO, "Enabling master-wins mode for "
+				   "simple two-node cluster\n");
+		}
 	}
 
 	ret = 0;


More information about the cluster-commits mailing list