Gitweb:
http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 68fb61d29d4653442d064499bdb41721371a7754
Parent: 0247047ad88bb1a16d72f5237053ce1fd014b85f
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Mon Feb 22 11:56:07 2010 -0500
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Fri Feb 26 18:12:07 2010 -0500
qdiskd: Dynamic votes
This patch allows qdiskd to reregister with CMAN
when the cluster node count or the administrator-supplied
votes parameter changes.
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
cman/man/qdisk.5 | 4 +-
cman/qdisk/main.c | 112 ++++++++++++++++++++++++++++++++++-------------------
2 files changed, 75 insertions(+), 41 deletions(-)
diff --git a/cman/man/qdisk.5 b/cman/man/qdisk.5
index abd80dc..7004f01 100644
--- a/cman/man/qdisk.5
+++ b/cman/man/qdisk.5
@@ -240,7 +240,9 @@ exceed \fBtko\fP.
.in 12
This is the number of votes the quorum daemon advertises to CMAN when it
has a high enough score. The default is the number of nodes in the cluster
-minus 1. For example, in a 4 node cluster, the default is 3.
+minus 1. For example, in a 4 node cluster, the default is 3. This value
+may change during normal operation, for example when adding or removing
+a node from the cluster.
.in 9
\fIlog_level\fP\fB="\fP4\fB"\fP
diff --git a/cman/qdisk/main.c b/cman/qdisk/main.c
index d1f29c5..59cb967 100644
--- a/cman/qdisk/main.c
+++ b/cman/qdisk/main.c
@@ -1339,10 +1339,45 @@ get_log_config_data(int ccsfd)
static int
+auto_qdisk_votes(int desc)
+{
+ int x = 0, ret = 0;
+ char buf[128];
+ char *name;
+
+ if (desc < 0) {
+ return 1;
+ }
+
+ while (++x) {
+ snprintf(buf, sizeof(buf)-1,
+ "/cluster/clusternodes/clusternode[%d]/@name", x);
+
+ name = NULL;
+ if (ccs_get(desc, buf, &name) != 0)
+ break;
+
+ free(name);
+ ret = x;
+ }
+
+ --ret;
+ if (ret <= 0) {
+ ret = 1;
+ }
+
+ logt_print(LOG_DEBUG, "Setting votes to %d\n", ret);
+
+ return (ret);
+}
+
+
+static int
get_dynamic_config_data(qd_ctx *ctx, int ccsfd)
{
char *val = NULL;
char query[256];
+ int old_votes = 0;
if (ccsfd < 0)
return -1;
@@ -1464,41 +1499,49 @@ get_dynamic_config_data(qd_ctx *ctx, int ccsfd)
free(val);
}
- return 0;
-}
-
-
-static int
-auto_qdisk_votes(int desc)
-{
- int x = 0, ret = 0;
- char buf[128];
- char *name;
-
- if (desc < 0) {
- return 1;
+ /* Get votes */
+ if (ctx->qc_config) {
+ old_votes = ctx->qc_votes;
}
- while (++x) {
- snprintf(buf, sizeof(buf)-1,
- "/cluster/clusternodes/clusternode[%d]/@name", x);
-
- name = NULL;
- if (ccs_get(desc, buf, &name) != 0)
- break;
-
- free(name);
- ret = x;
+ snprintf(query, sizeof(query), "/cluster/quorumd/@votes");
+ if (ccs_get(ccsfd, query, &val) == 0) {
+ ctx->qc_votes = atoi(val);
+ free(val);
+ if (ctx->qc_votes < 0)
+ ctx->qc_votes = 0;
+ } else {
+ ctx->qc_votes = auto_qdisk_votes(ccsfd);
+ if (ctx->qc_votes < 0) {
+ if (ctx->qc_config) {
+ logt_print(LOG_WARNING, "Unable to determine "
+ "new vote value; retaining old "
+ "value of %d\n", old_votes);
+ ctx->qc_votes = old_votes;
+ }
+ }
}
- --ret;
- if (ret <= 0) {
- ret = 1;
- }
+ if (ctx->qc_config && old_votes != ctx->qc_votes) {
+ logt_print(LOG_DEBUG, "Changing vote count from %d to %d\n",
+ old_votes, ctx->qc_votes);
- logt_print(LOG_DEBUG, "Setting votes to %d\n", ret);
+ /*
+ * This is done in main() normally. Here, we are
+ * reconfiguring _only_ the votes at this point. 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);
+ }
- return (ret);
+ return 0;
}
@@ -1601,17 +1644,6 @@ get_static_config_data(qd_ctx *ctx, int ccsfd)
qdisk_fo + (ctx->qc_interval * 1000));
}
- /* Get votes */
- snprintf(query, sizeof(query), "/cluster/quorumd/@votes");
- if (ccs_get(ccsfd, query, &val) == 0) {
- ctx->qc_votes = atoi(val);
- free(val);
- if (ctx->qc_votes < 0)
- ctx->qc_votes = 0;
- } else {
- ctx->qc_votes = auto_qdisk_votes(ccsfd);
- }
-
/* Get device */
snprintf(query, sizeof(query), "/cluster/quorumd/@device");
if (ccs_get(ccsfd, query, &val) == 0) {