commit 2acd52b50becbf98a45746f1f43d223d4365f521 Author: Christine Caulfield <ccaulfie@redhat.com> Date: Mon Oct 26 16:02:05 2009 +0000 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. rhbz#525270 Signed-off-by: Christine Caulfield <ccaulfie@redhat.com> diff --git a/cman/daemon/commands.c b/cman/daemon/commands.c index 29a9f1f..b1b1c69 100644 --- a/cman/daemon/commands.c +++ b/cman/daemon/commands.c @@ -981,38 +981,47 @@ 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; - } + if (!quorum_device) + { + 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; + } - strcpy(quorum_device->name, name); - quorum_device->votes = votes; - quorum_device->state = NODESTATE_DEAD; - gettimeofday(&quorum_device->join_time, NULL); + 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); + /* Keep this list valid so it doesn't confuse other code */ + list_init(&quorum_device->addr_list); + log_msg(LOG_INFO, "quorum device registered\n"); + } + else + { + log_printf(LOG_INFO, "quorum device re-registered\n"); + } - log_msg(LOG_INFO, "quorum device registered\n"); + /* Update votes even if it existed before */ + quorum_device->votes = votes; return 0; }