cluster: STABLE3 - qdiskd: Change votes instead of cman-visible status

Steven Whitehouse swhiteho at fedoraproject.org
Fri May 7 13:22:22 UTC 2010


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=669c6adcfae8a71ebb39722d95ed715f94e9c32b
Commit:        669c6adcfae8a71ebb39722d95ed715f94e9c32b
Parent:        fdc717eb3ac4c05073708750de1a55ee58247d2e
Author:        Lon Hohberger <lhh at redhat.com>
AuthorDate:    Thu May 6 14:04:03 2010 -0400
Committer:     Steven Whitehouse <swhiteho at redhat.com>
CommitterDate: Fri May 7 14:00:21 2010 +0100

qdiskd: Change votes instead of cman-visible status

With master-wins mode, we were advertising availability
of votes to cman.  This caused cman_tool nodes output to
claim the quorum disk was offline.  Since the initscript
expects the quorum disk to be reported as 'online', this
caused strange behaviors.

This fix makes us always advertise our votes as available.
Instead of presenting the votes vs. not presenting, we
simply present 0 votes when not master and 1 vote if
master.

Resolves: bz#576871

Signed-off-by: Lon Hohberger <lhh at redhat.com>
---
 cman/qdisk/main.c |   63 ++++++++++++++++++++++++++++++----------------------
 1 files changed, 36 insertions(+), 27 deletions(-)

diff --git a/cman/qdisk/main.c b/cman/qdisk/main.c
index 4d1c411..78dc3f0 100644
--- a/cman/qdisk/main.c
+++ b/cman/qdisk/main.c
@@ -677,6 +677,30 @@ check_votes(qd_ctx *ctx, node_info_t *ni, int max, disk_msg_t *msg)
 	return 0;
 }
 
+
+static int
+register_device(qd_ctx *ctx)
+{
+	return cman_register_quorum_device(
+			ctx->qc_cman_admin,
+			(ctx->qc_flags&RF_CMAN_LABEL) ?
+				ctx->qc_cman_label : ctx->qc_device,
+			(!(ctx->qc_flags & RF_MASTER_WINS) ||
+			 ctx->qc_status == S_MASTER) ?
+				ctx->qc_votes : 0);
+}
+
+
+static int 
+adjust_votes(qd_ctx *ctx)
+{
+	if (!(ctx->qc_flags & RF_MASTER_WINS))
+		return 0;
+
+	return register_device(ctx);
+}
+
+
 static void
 print_node_info(FILE *fp, node_info_t *ni)
 {
@@ -968,6 +992,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
 				       "downgrading\n",
 				       score, score_max, score_req);
 				ctx->qc_status = S_NONE;
+				adjust_votes(ctx);
 				msg.m_msg = M_NONE;
 				++msg.m_seq;
 				bid_pending = 0;
@@ -1006,6 +1031,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
 
 			/* Handle just like a recent upgrade */
 			ctx->qc_status = S_RUN;
+			adjust_votes(ctx);
 			upgrade = ctx->qc_upgrade_wait;
 			bid_pending = 0;
 			msg.m_msg = M_NONE;
@@ -1055,6 +1081,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
 				logt_print(LOG_INFO,
 				       "Assuming master role\n");
 				ctx->qc_status = S_MASTER;
+				adjust_votes(ctx);
 			case 2:
 				msg.m_msg = M_NONE;
 			case 1:
@@ -1107,9 +1134,11 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
 						"Halting qdisk operations\n");
 					return -1;
 				}
-				if (!errors && 
-				    (!(ctx->qc_flags & RF_MASTER_WINS)))
-					cman_poll_quorum_device(ctx->qc_cman_admin, 1);
+				if (!errors) {
+				    	cman_poll_quorum_device(
+						ctx->qc_cman_admin,
+						1);
+				}
 			}
 		}
 		
@@ -1563,18 +1592,13 @@ get_dynamic_config_data(qd_ctx *ctx, int ccsfd)
 		}
 
 		/*
-		 * This is done in main() normally.  Here, we are
-		 * reconfiguring _only_ the votes at this point.  The 
+		 * Here, we are reconfiguring _only_ the votes.  The 
 		 * label / cman runflags do not change during reconfiguration
 		 *
 		 * This only works after we have already gotten static
 		 * configuration data during initial startup.
 		 */
-		cman_register_quorum_device(ctx->qc_cman_admin,
-					    (ctx->qc_flags&RF_CMAN_LABEL)? 
-					    ctx->qc_cman_label:
-					    ctx->qc_device,
-					    ctx->qc_votes);
+		register_device(ctx);
 	}
 
 	return 0;
@@ -2018,23 +2042,8 @@ main(int argc, char **argv)
 	if (!_running)
 		goto out;
 	
-	cman_register_quorum_device(ctx.qc_cman_admin,
-				    (ctx.qc_flags&RF_CMAN_LABEL)? 
-				        ctx.qc_cman_label:
-                                        ctx.qc_device,
-				    ctx.qc_votes);
-	/*
-		XXX this always returns -1 / EBUSY even when it works?!!!
-		
-	if ((rv = cman_register_quorum_device(ctx.qc_cman_admin, ctx.qc_device,
-					      ctx.qc_votes)) < 0) {
-		logt_print(LOG_CRIT,
-				 "Could not register %s with CMAN; "
-				 "return = %d; error = %s\n",
-				 ctx.qc_device, rv, strerror(errno));
-		goto out;
-	}
-	*/
+	/* This registers the quorum device */
+	register_device(&ctx);
 
 	io_nanny_start(ctx.qc_tko * ctx.qc_interval);
 


More information about the cluster-commits mailing list