Gitweb:
http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 161b6d3d7db0b34046c6e4b8c6c5818e655e549e
Parent: 9bf4612bceb34beeb9302d0cdcfa2a0dadb90a2c
Author: Christine Caulfield <ccaulfie(a)redhat.com>
AuthorDate: Tue Sep 22 09:10:19 2009 +0100
Committer: Christine Caulfield <ccaulfie(a)redhat.com>
CommitterDate: Tue Sep 22 09:10:19 2009 +0100
cman: Allow re-registering of a quorum disk
cman-register_quorum_device now allows the quorum device to be be
registered, with different votes, provided the name stays the same.
This should make it easier for qdiskd to handle configuration changes
without the cluster losing quorum.
Signed-off-by: Christine Caulfield <ccaulfie(a)redhat.com>
---
cman/daemon/commands.c | 55 ++++++++++++++++++++++++++++-------------------
1 files changed, 33 insertions(+), 22 deletions(-)
diff --git a/cman/daemon/commands.c b/cman/daemon/commands.c
index c2169f0..cc3c8c9 100644
--- a/cman/daemon/commands.c
+++ b/cman/daemon/commands.c
@@ -488,7 +488,7 @@ static int do_cmd_set_version(char *cmdbuf, int *retlen)
/* If the passed-in version number is 0 then read the file now, then
* tell the other nodes to look for that version number.
* That means we also have to send the notification here, because it will
- * beskipped when we get our own RECONFIGURE message back as the version
+ * be skipped when we get our own RECONFIGURE message back, as the version
* number will match.
*/
if (!version->config) {
@@ -1106,38 +1106,49 @@ static int do_cmd_register_quorum_device(char *cmdbuf, int
*retlen)
if (!we_are_a_cluster_member)
return -ENOENT;
- if (quorum_device)
- return -EBUSY;
-
if (strlen(name) > MAX_CLUSTER_MEMBER_NAME_LEN)
return -EINVAL;
+ /* Allow re-registering of a quorum device if the name is the same */
+ if (quorum_device && strcmp(name, quorum_device->name))
+ return -EBUSY;
+
if (find_node_by_name(name))
return -EALREADY;
memcpy(&votes, cmdbuf, sizeof(int));
- quorum_device = malloc(sizeof(struct cluster_node));
- if (!quorum_device)
- return -ENOMEM;
- memset(quorum_device, 0, sizeof(struct cluster_node));
-
- quorum_device->name = malloc(strlen(name) + 1);
- if (!quorum_device->name) {
- free(quorum_device);
- quorum_device = NULL;
- return -ENOMEM;
- }
+ /* A new quorum device */
+ if (!quorum_device)
+ {
+ quorum_device = malloc(sizeof(struct cluster_node));
+ if (!quorum_device)
+ return -ENOMEM;
+ memset(quorum_device, 0, sizeof(struct cluster_node));
- strcpy(quorum_device->name, name);
- quorum_device->votes = votes;
- quorum_device->state = NODESTATE_DEAD;
- gettimeofday(&quorum_device->join_time, NULL);
+ quorum_device->name = malloc(strlen(name) + 1);
+ if (!quorum_device->name) {
+ free(quorum_device);
+ quorum_device = NULL;
+ return -ENOMEM;
+ }
+
+ strcpy(quorum_device->name, name);
+ quorum_device->state = NODESTATE_DEAD;
+ gettimeofday(&quorum_device->join_time, NULL);
+
+ /* Keep this list valid so it doesn't confuse other code */
+ list_init(&quorum_device->addr_list);
+ log_printf(LOG_INFO, "quorum device registered\n");
+ }
+ else
+ {
+ log_printf(LOG_INFO, "quorum device re-registered\n");
+ }
- /* Keep this list valid so it doesn't confuse other code */
- list_init(&quorum_device->addr_list);
+ /* Update votes even if it existed before */
+ quorum_device->votes = votes;
- log_printf(LOG_INFO, "quorum device registered\n");
return 0;
}