cluster: STABLE31 - rgmanager: Fix dependency restart bug in CP mode
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: c751d1894640b096808d2f13e331bee4c536f96a
Parent: 90373b84a47814c38ba030509882bc8cca3fe458
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Fri Oct 7 12:31:16 2011 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Thu Oct 13 16:15:57 2011 -0400
rgmanager: Fix dependency restart bug in CP mode
If we:
- had central_processing mode enabled,
- had a service with 'depend' set on another
service,
- we attempted to restart the service with the
dependency, and
- the dependency was missing
rgmanager would leave the state in 'recovering'
Resolves: rhbz#743442
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/resources/default_event_script.sl | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/rgmanager/src/resources/default_event_script.sl b/rgmanager/src/resources/default_event_script.sl
index 759215c..57f65e9 100644
--- a/rgmanager/src/resources/default_event_script.sl
+++ b/rgmanager/src/resources/default_event_script.sl
@@ -178,6 +178,9 @@ define move_or_start(service, node_list)
(,,, owner, state) = service_status(depends);
if (owner < 0) {
debug(service, " is not runnable; dependency not met");
+ if (state == "recovering") {
+ service_stop(service);
+ }
return ERR_DEPEND;
}
}
12 years, 6 months
cluster: RHEL58 - cman: fix building of debuginfo package (enable -g)
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 141d1d9241b2ad2cd8865d524a6b38dc069fffd3
Parent: f38483b5b484828f78d04e6188f9e10c3b1c6892
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Mon Oct 17 10:39:57 2011 +0200
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Mon Oct 17 10:39:57 2011 +0200
cman: fix building of debuginfo package (enable -g)
Resolves: rhbz#746599
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
cman/daemon/Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/cman/daemon/Makefile b/cman/daemon/Makefile
index 3e6f1f7..de233b0 100644
--- a/cman/daemon/Makefile
+++ b/cman/daemon/Makefile
@@ -21,7 +21,7 @@ CFLAGS+= -fPIC -I${ccsincdir} -I${incdir} -I${top_srcdir}/config \
ifeq ($(DEBUG),y)
CFLAGS+= -O0 -g -DDEBUG
else
-CFLAGS+= -O2
+CFLAGS+= -O2 -g
endif
TARGET=service_cman.lcrso
12 years, 6 months
cluster: RHEL58 - qdisk: Fix man page example
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: f38483b5b484828f78d04e6188f9e10c3b1c6892
Parent: 8034c6d0c7f68e6e8d823d65edda986b4a4f510b
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Wed Oct 12 11:23:28 2011 -0400
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Mon Oct 17 10:21:59 2011 +0200
qdisk: Fix man page example
Resolves: rhbz#745536
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
cman/man/qdisk.5 | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/cman/man/qdisk.5 b/cman/man/qdisk.5
index 100952e..eccef6c 100644
--- a/cman/man/qdisk.5
+++ b/cman/man/qdisk.5
@@ -1,6 +1,6 @@
-.TH "QDisk" "5" "06 Sep 2007" "" "Cluster Quorum Disk"
+.TH "QDisk" "5" "12 Oct 2011" "" "Cluster Quorum Disk"
.SH "NAME"
-QDisk 1.2.1 \- a disk-based quorum daemon for CMAN / Linux-Cluster
+qdisk \- a disk-based quorum daemon for CMAN / Linux-Cluster
.SH "1. Overview"
.SH "1.1 Problem"
In some situations, it may be necessary or desirable to sustain
@@ -463,7 +463,7 @@ by the qdiskd timeout.
.br
<quorumd interval="1" tko="10" votes="1" label="testing">
.in 12
-<heuristic program="ping A -c1 -t1" score="1" interval="2" tko="3"/>
+<heuristic program="ping A -c1 -w1" score="1" interval="2" tko="3"/>
.br
.in 8
</quorumd>
12 years, 6 months
cluster: RHEL58 - cman: Clean shutdown_con if the controlling process is killed.
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 8034c6d0c7f68e6e8d823d65edda986b4a4f510b
Parent: 523abe7c546805181ea3969b61d01aa23402335e
Author: Christine Caulfield <ccaulfie(a)redhat.com>
AuthorDate: Fri Sep 19 13:02:40 2008 +0100
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Mon Oct 17 10:09:53 2011 +0200
cman: Clean shutdown_con if the controlling process is killed.
If a shutdown is initiated by a process that is then killed, the
shutdown_con isn't cleared. So if another process replies to the
shutdown request cman could segfault.
Resolves: rhbz#590101
Signed-off-by: Christine Caulfield <ccaulfie(a)redhat.com>
Signed-off-by: Fabio M. Di Nitto <fdintto(a)redhat.com>
---
cman/daemon/commands.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/cman/daemon/commands.c b/cman/daemon/commands.c
index ddc85ec..1fafdac 100644
--- a/cman/daemon/commands.c
+++ b/cman/daemon/commands.c
@@ -1541,6 +1541,11 @@ void unbind_con(struct connection *con)
check_shutdown_status();
}
+
+ /* If the controlling shutdown process has quit, then cancel the
+ shutdown session */
+ if (con == shutdown_con)
+ shutdown_con = NULL;
}
/* Post a PORT OPEN/CLOSE event to anyone listening on this end */
12 years, 6 months
cluster: STABLE31 - qdisk: Fix man page example
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 90373b84a47814c38ba030509882bc8cca3fe458
Parent: c2697a0eae26d6542edbaaf72efdeb4cbf6e476f
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Wed Oct 12 11:23:28 2011 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Wed Oct 12 11:24:55 2011 -0400
qdisk: Fix man page example
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
cman/man/qdisk.5 | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/cman/man/qdisk.5 b/cman/man/qdisk.5
index 4070f48..e0b0ff6 100644
--- a/cman/man/qdisk.5
+++ b/cman/man/qdisk.5
@@ -1,4 +1,4 @@
-.TH "QDisk" "5" "20 Feb 2007" "" "Cluster Quorum Disk"
+.TH "QDisk" "5" "12 Oct 2011" "" "Cluster Quorum Disk"
.SH "NAME"
qdisk \- a disk-based quorum daemon for CMAN / Linux-Cluster
.SH "1. Overview"
@@ -502,7 +502,7 @@ by the qdiskd timeout.
.br
<quorumd interval="1" tko="10" votes="1" label="testing">
.in 12
-<heuristic program="ping A -c1 -t1" score="1" interval="2" tko="3"/>
+<heuristic program="ping A -c1 -w1" score="1" interval="2" tko="3"/>
.br
.in 8
</quorumd>
12 years, 7 months
cluster: STABLE31 - rgmanager: Fix dependency restart bug
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: c2697a0eae26d6542edbaaf72efdeb4cbf6e476f
Parent: afe8df67ab28a9fed6ba01a4a952354a012d9b25
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Fri Oct 7 12:31:16 2011 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Tue Oct 11 18:59:57 2011 -0400
rgmanager: Fix dependency restart bug
If we:
- had a service with 'depend' set on another
service,
- both services were running on the same host,
- that host died, and
- the service which depended on the other service
also had the 'restart' recovery policy,
rgmanager would enter handle_start_req and return
an immediate error - with no further recovery action
performed.
Resolves: rhbz#743442
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/daemons/rg_state.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/rgmanager/src/daemons/rg_state.c b/rgmanager/src/daemons/rg_state.c
index 3db6bd9..0d6a0e5 100644
--- a/rgmanager/src/daemons/rg_state.c
+++ b/rgmanager/src/daemons/rg_state.c
@@ -2075,8 +2075,16 @@ handle_start_req(char *svcName, int req, int *new_owner)
/* Check for dependency. We cannot start unless our
dependency is met */
- if (check_depend_safe(svcName) == 0)
+ if (check_depend_safe(svcName) == 0) {
+ if (req == RG_START_RECOVER) {
+ logt_print(LOG_INFO, "Dependency for %s missing "
+ "during recovery; marking as stopped",
+ svcName);
+
+ _svc_stop_finish(svcName, 0, RG_STATE_STOPPED);
+ }
return RG_EDEPEND;
+ }
/*
* This is a 'root' start request. We need to clear out our failure
12 years, 7 months
dlm: master - dlm_controld: rename member_cman.c
by David Teigland
Gitweb: http://git.fedorahosted.org/git/dlm.git?p=dlm.git;a=commitdiff;h=ca4807a2...
Commit: ca4807a270a126ac6ee4d58f9c6c0658053b4101
Parent: 6011133ecf9899148970d979c0c1d930c6cfe474
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Oct 11 13:59:09 2011 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Oct 11 13:59:43 2011 -0500
dlm_controld: rename member_cman.c
Signed-off-by: David Teigland <teigland(a)redhat.com>
---
dlm_controld/Makefile | 2 +-
dlm_controld/dlm_daemon.h | 2 +-
dlm_controld/member.c | 311 ++++++++++++++++++++++++++++++++++++++++++++
dlm_controld/member_cman.c | 311 --------------------------------------------
4 files changed, 313 insertions(+), 313 deletions(-)
diff --git a/dlm_controld/Makefile b/dlm_controld/Makefile
index a4cc5d7..403cc91 100644
--- a/dlm_controld/Makefile
+++ b/dlm_controld/Makefile
@@ -29,7 +29,7 @@ BIN_SOURCE = action.c \
main.c \
plock.c \
config.c \
- member_cman.c \
+ member.c \
logging.c \
rbtree.c
LIB_SOURCE = lib.c
diff --git a/dlm_controld/dlm_daemon.h b/dlm_controld/dlm_daemon.h
index 9d8cd52..b999267 100644
--- a/dlm_controld/dlm_daemon.h
+++ b/dlm_controld/dlm_daemon.h
@@ -330,7 +330,7 @@ struct lockspace *find_ls_id(uint32_t id);
const char *dlm_mode_str(int mode);
void cluster_dead(int ci);
-/* member_cman.c */
+/* member.c */
int setup_cluster(void);
void close_cluster(void);
void process_cluster(int ci);
diff --git a/dlm_controld/member.c b/dlm_controld/member.c
new file mode 100644
index 0000000..d645911
--- /dev/null
+++ b/dlm_controld/member.c
@@ -0,0 +1,311 @@
+/*
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ */
+
+#include "dlm_daemon.h"
+#include <corosync/corotypes.h>
+#include <corosync/cfg.h>
+#include <corosync/quorum.h>
+
+static corosync_cfg_handle_t ch;
+static quorum_handle_t qh;
+static uint32_t old_nodes[MAX_NODES];
+static int old_node_count;
+static uint32_t quorum_nodes[MAX_NODES];
+static int quorum_node_count;
+static struct list_head cluster_nodes;
+
+struct node_cluster {
+ struct list_head list;
+ int nodeid;
+
+ uint64_t cluster_add_time;
+ uint64_t cluster_rem_time;
+};
+
+static struct node_cluster *get_cluster_node(int nodeid, int create)
+{
+ struct node_cluster *node;
+
+ list_for_each_entry(node, &cluster_nodes, list) {
+ if (node->nodeid == nodeid)
+ return node;
+ }
+
+ if (!create)
+ return NULL;
+
+ node = malloc(sizeof(struct node_cluster));
+ if (!node)
+ return NULL;
+
+ memset(node, 0, sizeof(struct node_cluster));
+ node->nodeid = nodeid;
+ list_add(&node->list, &cluster_nodes);
+ return node;
+}
+
+static void add_cluster_node(int nodeid, uint64_t now)
+{
+ struct node_cluster *node;
+
+ node = get_cluster_node(nodeid, 1);
+ if (!node)
+ return;
+ node->cluster_add_time = now;
+}
+
+static void rem_cluster_node(int nodeid, uint64_t now)
+{
+ struct node_cluster *node;
+
+ node = get_cluster_node(nodeid, 0);
+ if (!node)
+ return;
+ node->cluster_rem_time = now;
+}
+
+uint64_t cluster_add_time(int nodeid)
+{
+ struct node_cluster *node;
+
+ node = get_cluster_node(nodeid, 0);
+ if (!node)
+ return 0;
+
+ return node->cluster_add_time;
+}
+
+static int is_member(uint32_t *node_list, int count, uint32_t nodeid)
+{
+ int i;
+
+ for (i = 0; i < count; i++) {
+ if (node_list[i] == nodeid)
+ return 1;
+ }
+ return 0;
+}
+
+static int is_old_member(uint32_t nodeid)
+{
+ return is_member(old_nodes, old_node_count, nodeid);
+}
+
+int is_cluster_member(uint32_t nodeid)
+{
+ return is_member(quorum_nodes, quorum_node_count, nodeid);
+}
+
+static void quorum_callback(quorum_handle_t h, uint32_t quorate,
+ uint64_t ring_seq, uint32_t node_list_entries,
+ uint32_t *node_list)
+{
+ corosync_cfg_node_address_t addrs[MAX_NODE_ADDRESSES];
+ corosync_cfg_node_address_t *addrptr = addrs;
+ cs_error_t err;
+ int i, j, num_addrs;
+ uint64_t now = monotime();
+
+ if (!cluster_quorate && quorate)
+ quorate_time = now;
+
+ cluster_quorate = quorate;
+ cluster_ringid_seq = (uint32_t)ring_seq;
+
+ log_debug("cluster quorum %u seq %u nodes %u",
+ cluster_quorate, cluster_ringid_seq, node_list_entries);
+
+ old_node_count = quorum_node_count;
+ memcpy(&old_nodes, &quorum_nodes, sizeof(old_nodes));
+
+ quorum_node_count = 0;
+ memset(&quorum_nodes, 0, sizeof(quorum_nodes));
+
+ for (i = 0; i < node_list_entries; i++)
+ quorum_nodes[quorum_node_count++] = node_list[i];
+
+ for (i = 0; i < old_node_count; i++) {
+ if (!is_cluster_member(old_nodes[i])) {
+ log_debug("cluster node %u removed seq %u",
+ old_nodes[i], cluster_ringid_seq);
+ rem_cluster_node(old_nodes[i], now);
+ del_configfs_node(old_nodes[i]);
+ }
+ }
+
+ for (i = 0; i < quorum_node_count; i++) {
+ if (!is_old_member(quorum_nodes[i])) {
+ log_debug("cluster node %u added seq %u",
+ quorum_nodes[i], cluster_ringid_seq);
+ add_cluster_node(quorum_nodes[i], now);
+
+ err = corosync_cfg_get_node_addrs(ch, quorum_nodes[i],
+ MAX_NODE_ADDRESSES,
+ &num_addrs, addrs);
+ if (err != CS_OK) {
+ log_error("corosync_cfg_get_node_addrs failed "
+ "nodeid %u", quorum_nodes[i]);
+ continue;
+ }
+
+ for (j = 0; j < num_addrs; j++) {
+ add_configfs_node(quorum_nodes[i],
+ addrptr[j].address,
+ addrptr[j].address_length,
+ (quorum_nodes[i] ==
+ our_nodeid));
+ }
+ }
+ }
+}
+
+static quorum_callbacks_t quorum_callbacks =
+{
+ .quorum_notify_fn = quorum_callback,
+};
+
+void process_cluster(int ci)
+{
+ cs_error_t err;
+
+ err = quorum_dispatch(qh, CS_DISPATCH_ALL);
+ if (err != CS_OK)
+ cluster_dead(0);
+}
+
+/* Force re-read of quorum nodes */
+void update_cluster(void)
+{
+ cs_error_t err;
+
+ err = quorum_dispatch(qh, CS_DISPATCH_ONE);
+ if (err != CS_OK)
+ cluster_dead(0);
+}
+
+int setup_cluster(void)
+{
+ cs_error_t err;
+ int fd;
+
+ INIT_LIST_HEAD(&cluster_nodes);
+
+ err = quorum_initialize(&qh, &quorum_callbacks);
+ if (err != CS_OK) {
+ log_error("quorum init error %d", err);
+ return -1;
+ }
+
+ err = quorum_fd_get(qh, &fd);
+ if (err != CS_OK) {
+ log_error("quorum fd_get error %d", err);
+ goto fail;
+ }
+
+ err = quorum_trackstart(qh, CS_TRACK_CHANGES);
+ if (err != CS_OK) {
+ log_error("quorum trackstart error %d", err);
+ goto fail;
+ }
+
+ old_node_count = 0;
+ memset(&old_nodes, 0, sizeof(old_nodes));
+ quorum_node_count = 0;
+ memset(&quorum_nodes, 0, sizeof(quorum_nodes));
+
+ return fd;
+ fail:
+ quorum_finalize(qh);
+ return -1;
+}
+
+void close_cluster(void)
+{
+ quorum_trackstop(qh);
+ quorum_finalize(qh);
+}
+
+void kick_node_from_cluster(int nodeid)
+{
+ if (!nodeid) {
+ log_error("telling corosync to shut down cluster locally");
+ corosync_cfg_try_shutdown(ch,
+ COROSYNC_CFG_SHUTDOWN_FLAG_IMMEDIATE);
+ } else {
+ log_error("telling corosync to remove nodeid %d from cluster",
+ nodeid);
+ corosync_cfg_kill_node(ch, nodeid, "dlm_controld");
+ }
+}
+
+static void shutdown_callback(corosync_cfg_handle_t h,
+ corosync_cfg_shutdown_flags_t flags)
+{
+ if (flags & COROSYNC_CFG_SHUTDOWN_FLAG_REQUEST) {
+ if (list_empty(&lockspaces))
+ corosync_cfg_replyto_shutdown(ch,
+ COROSYNC_CFG_SHUTDOWN_FLAG_YES);
+ else {
+ log_debug("no to corosync shutdown");
+ corosync_cfg_replyto_shutdown(ch,
+ COROSYNC_CFG_SHUTDOWN_FLAG_NO);
+ }
+ }
+}
+
+static corosync_cfg_callbacks_t cfg_callbacks =
+{
+ .corosync_cfg_shutdown_callback = shutdown_callback,
+ .corosync_cfg_state_track_callback = NULL,
+};
+
+void process_cluster_cfg(int ci)
+{
+ cs_error_t err;
+
+ err = corosync_cfg_dispatch(ch, CS_DISPATCH_ALL);
+ if (err != CS_OK)
+ cluster_dead(0);
+}
+
+int setup_cluster_cfg(void)
+{
+ cs_error_t err;
+ unsigned int nodeid;
+ int fd;
+
+ err = corosync_cfg_initialize(&ch, &cfg_callbacks);
+ if (err != CS_OK) {
+ log_error("corosync cfg init error %d", err);
+ return -1;
+ }
+
+ err = corosync_cfg_fd_get(ch, &fd);
+ if (err != CS_OK) {
+ log_error("corosync cfg fd_get error %d", err);
+ corosync_cfg_finalize(ch);
+ return -1;
+ }
+
+ err = corosync_cfg_local_get(ch, &nodeid);
+ if (err != CS_OK) {
+ log_error("corosync cfg local_get error %d", err);
+ corosync_cfg_finalize(ch);
+ return -1;
+ }
+ our_nodeid = nodeid;
+ log_debug("our_nodeid %d", our_nodeid);
+
+ return fd;
+}
+
+void close_cluster_cfg(void)
+{
+ corosync_cfg_finalize(ch);
+}
+
diff --git a/dlm_controld/member_cman.c b/dlm_controld/member_cman.c
deleted file mode 100644
index d645911..0000000
--- a/dlm_controld/member_cman.c
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
- *
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU General Public License v.2.
- */
-
-#include "dlm_daemon.h"
-#include <corosync/corotypes.h>
-#include <corosync/cfg.h>
-#include <corosync/quorum.h>
-
-static corosync_cfg_handle_t ch;
-static quorum_handle_t qh;
-static uint32_t old_nodes[MAX_NODES];
-static int old_node_count;
-static uint32_t quorum_nodes[MAX_NODES];
-static int quorum_node_count;
-static struct list_head cluster_nodes;
-
-struct node_cluster {
- struct list_head list;
- int nodeid;
-
- uint64_t cluster_add_time;
- uint64_t cluster_rem_time;
-};
-
-static struct node_cluster *get_cluster_node(int nodeid, int create)
-{
- struct node_cluster *node;
-
- list_for_each_entry(node, &cluster_nodes, list) {
- if (node->nodeid == nodeid)
- return node;
- }
-
- if (!create)
- return NULL;
-
- node = malloc(sizeof(struct node_cluster));
- if (!node)
- return NULL;
-
- memset(node, 0, sizeof(struct node_cluster));
- node->nodeid = nodeid;
- list_add(&node->list, &cluster_nodes);
- return node;
-}
-
-static void add_cluster_node(int nodeid, uint64_t now)
-{
- struct node_cluster *node;
-
- node = get_cluster_node(nodeid, 1);
- if (!node)
- return;
- node->cluster_add_time = now;
-}
-
-static void rem_cluster_node(int nodeid, uint64_t now)
-{
- struct node_cluster *node;
-
- node = get_cluster_node(nodeid, 0);
- if (!node)
- return;
- node->cluster_rem_time = now;
-}
-
-uint64_t cluster_add_time(int nodeid)
-{
- struct node_cluster *node;
-
- node = get_cluster_node(nodeid, 0);
- if (!node)
- return 0;
-
- return node->cluster_add_time;
-}
-
-static int is_member(uint32_t *node_list, int count, uint32_t nodeid)
-{
- int i;
-
- for (i = 0; i < count; i++) {
- if (node_list[i] == nodeid)
- return 1;
- }
- return 0;
-}
-
-static int is_old_member(uint32_t nodeid)
-{
- return is_member(old_nodes, old_node_count, nodeid);
-}
-
-int is_cluster_member(uint32_t nodeid)
-{
- return is_member(quorum_nodes, quorum_node_count, nodeid);
-}
-
-static void quorum_callback(quorum_handle_t h, uint32_t quorate,
- uint64_t ring_seq, uint32_t node_list_entries,
- uint32_t *node_list)
-{
- corosync_cfg_node_address_t addrs[MAX_NODE_ADDRESSES];
- corosync_cfg_node_address_t *addrptr = addrs;
- cs_error_t err;
- int i, j, num_addrs;
- uint64_t now = monotime();
-
- if (!cluster_quorate && quorate)
- quorate_time = now;
-
- cluster_quorate = quorate;
- cluster_ringid_seq = (uint32_t)ring_seq;
-
- log_debug("cluster quorum %u seq %u nodes %u",
- cluster_quorate, cluster_ringid_seq, node_list_entries);
-
- old_node_count = quorum_node_count;
- memcpy(&old_nodes, &quorum_nodes, sizeof(old_nodes));
-
- quorum_node_count = 0;
- memset(&quorum_nodes, 0, sizeof(quorum_nodes));
-
- for (i = 0; i < node_list_entries; i++)
- quorum_nodes[quorum_node_count++] = node_list[i];
-
- for (i = 0; i < old_node_count; i++) {
- if (!is_cluster_member(old_nodes[i])) {
- log_debug("cluster node %u removed seq %u",
- old_nodes[i], cluster_ringid_seq);
- rem_cluster_node(old_nodes[i], now);
- del_configfs_node(old_nodes[i]);
- }
- }
-
- for (i = 0; i < quorum_node_count; i++) {
- if (!is_old_member(quorum_nodes[i])) {
- log_debug("cluster node %u added seq %u",
- quorum_nodes[i], cluster_ringid_seq);
- add_cluster_node(quorum_nodes[i], now);
-
- err = corosync_cfg_get_node_addrs(ch, quorum_nodes[i],
- MAX_NODE_ADDRESSES,
- &num_addrs, addrs);
- if (err != CS_OK) {
- log_error("corosync_cfg_get_node_addrs failed "
- "nodeid %u", quorum_nodes[i]);
- continue;
- }
-
- for (j = 0; j < num_addrs; j++) {
- add_configfs_node(quorum_nodes[i],
- addrptr[j].address,
- addrptr[j].address_length,
- (quorum_nodes[i] ==
- our_nodeid));
- }
- }
- }
-}
-
-static quorum_callbacks_t quorum_callbacks =
-{
- .quorum_notify_fn = quorum_callback,
-};
-
-void process_cluster(int ci)
-{
- cs_error_t err;
-
- err = quorum_dispatch(qh, CS_DISPATCH_ALL);
- if (err != CS_OK)
- cluster_dead(0);
-}
-
-/* Force re-read of quorum nodes */
-void update_cluster(void)
-{
- cs_error_t err;
-
- err = quorum_dispatch(qh, CS_DISPATCH_ONE);
- if (err != CS_OK)
- cluster_dead(0);
-}
-
-int setup_cluster(void)
-{
- cs_error_t err;
- int fd;
-
- INIT_LIST_HEAD(&cluster_nodes);
-
- err = quorum_initialize(&qh, &quorum_callbacks);
- if (err != CS_OK) {
- log_error("quorum init error %d", err);
- return -1;
- }
-
- err = quorum_fd_get(qh, &fd);
- if (err != CS_OK) {
- log_error("quorum fd_get error %d", err);
- goto fail;
- }
-
- err = quorum_trackstart(qh, CS_TRACK_CHANGES);
- if (err != CS_OK) {
- log_error("quorum trackstart error %d", err);
- goto fail;
- }
-
- old_node_count = 0;
- memset(&old_nodes, 0, sizeof(old_nodes));
- quorum_node_count = 0;
- memset(&quorum_nodes, 0, sizeof(quorum_nodes));
-
- return fd;
- fail:
- quorum_finalize(qh);
- return -1;
-}
-
-void close_cluster(void)
-{
- quorum_trackstop(qh);
- quorum_finalize(qh);
-}
-
-void kick_node_from_cluster(int nodeid)
-{
- if (!nodeid) {
- log_error("telling corosync to shut down cluster locally");
- corosync_cfg_try_shutdown(ch,
- COROSYNC_CFG_SHUTDOWN_FLAG_IMMEDIATE);
- } else {
- log_error("telling corosync to remove nodeid %d from cluster",
- nodeid);
- corosync_cfg_kill_node(ch, nodeid, "dlm_controld");
- }
-}
-
-static void shutdown_callback(corosync_cfg_handle_t h,
- corosync_cfg_shutdown_flags_t flags)
-{
- if (flags & COROSYNC_CFG_SHUTDOWN_FLAG_REQUEST) {
- if (list_empty(&lockspaces))
- corosync_cfg_replyto_shutdown(ch,
- COROSYNC_CFG_SHUTDOWN_FLAG_YES);
- else {
- log_debug("no to corosync shutdown");
- corosync_cfg_replyto_shutdown(ch,
- COROSYNC_CFG_SHUTDOWN_FLAG_NO);
- }
- }
-}
-
-static corosync_cfg_callbacks_t cfg_callbacks =
-{
- .corosync_cfg_shutdown_callback = shutdown_callback,
- .corosync_cfg_state_track_callback = NULL,
-};
-
-void process_cluster_cfg(int ci)
-{
- cs_error_t err;
-
- err = corosync_cfg_dispatch(ch, CS_DISPATCH_ALL);
- if (err != CS_OK)
- cluster_dead(0);
-}
-
-int setup_cluster_cfg(void)
-{
- cs_error_t err;
- unsigned int nodeid;
- int fd;
-
- err = corosync_cfg_initialize(&ch, &cfg_callbacks);
- if (err != CS_OK) {
- log_error("corosync cfg init error %d", err);
- return -1;
- }
-
- err = corosync_cfg_fd_get(ch, &fd);
- if (err != CS_OK) {
- log_error("corosync cfg fd_get error %d", err);
- corosync_cfg_finalize(ch);
- return -1;
- }
-
- err = corosync_cfg_local_get(ch, &nodeid);
- if (err != CS_OK) {
- log_error("corosync cfg local_get error %d", err);
- corosync_cfg_finalize(ch);
- return -1;
- }
- our_nodeid = nodeid;
- log_debug("our_nodeid %d", our_nodeid);
-
- return fd;
-}
-
-void close_cluster_cfg(void)
-{
- corosync_cfg_finalize(ch);
-}
-
12 years, 7 months
dlm: master - dlm_controld: move fence code into separate file
by David Teigland
Gitweb: http://git.fedorahosted.org/git/dlm.git?p=dlm.git;a=commitdiff;h=6011133e...
Commit: 6011133ecf9899148970d979c0c1d930c6cfe474
Parent: a93c6d5bcb9ddf52fa524895a65ce3aedb71819b
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Oct 11 13:58:49 2011 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Oct 11 13:58:49 2011 -0500
dlm_controld: move fence code into separate file
Signed-off-by: David Teigland <teigland(a)redhat.com>
---
dlm_controld/Makefile | 1 +
dlm_controld/dlm_daemon.h | 2 ++
dlm_controld/fence.c | 41 +++++++++++++++++++++++++++++++++++++++++
dlm_controld/member_cman.c | 31 -------------------------------
4 files changed, 44 insertions(+), 31 deletions(-)
diff --git a/dlm_controld/Makefile b/dlm_controld/Makefile
index 7bd37a1..a4cc5d7 100644
--- a/dlm_controld/Makefile
+++ b/dlm_controld/Makefile
@@ -25,6 +25,7 @@ LIB_TARGET = $(LIB_SO).$(LIB_MAJOR).$(LIB_MINOR)
BIN_SOURCE = action.c \
cpg.c \
crc.c \
+ fence.c \
main.c \
plock.c \
config.c \
diff --git a/dlm_controld/dlm_daemon.h b/dlm_controld/dlm_daemon.h
index 5209762..9d8cd52 100644
--- a/dlm_controld/dlm_daemon.h
+++ b/dlm_controld/dlm_daemon.h
@@ -341,6 +341,8 @@ int setup_cluster_cfg(void);
void close_cluster_cfg(void);
void process_cluster_cfg(int ci);
void kick_node_from_cluster(int nodeid);
+
+/* fence.c */
int fence_node_time(int nodeid, uint64_t *last_fenced_time);
int fence_in_progress(int *count);
diff --git a/dlm_controld/fence.c b/dlm_controld/fence.c
new file mode 100644
index 0000000..15271b6
--- /dev/null
+++ b/dlm_controld/fence.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License v.2.
+ */
+
+#include "dlm_daemon.h"
+#include "libfenced.h"
+
+int fence_node_time(int nodeid, uint64_t *last_fenced_time)
+{
+ struct fenced_node nodeinfo;
+ int rv;
+
+ memset(&nodeinfo, 0, sizeof(nodeinfo));
+
+ rv = fenced_node_info(nodeid, &nodeinfo);
+ if (rv < 0)
+ return rv;
+
+ *last_fenced_time = nodeinfo.last_fenced_time;
+ return 0;
+}
+
+int fence_in_progress(int *count)
+{
+ struct fenced_domain domain;
+ int rv;
+
+ memset(&domain, 0, sizeof(domain));
+
+ rv = fenced_domain_info(&domain);
+ if (rv < 0)
+ return rv;
+
+ *count = domain.victim_count;
+ return 0;
+}
+
diff --git a/dlm_controld/member_cman.c b/dlm_controld/member_cman.c
index 6bfb2a9..d645911 100644
--- a/dlm_controld/member_cman.c
+++ b/dlm_controld/member_cman.c
@@ -10,7 +10,6 @@
#include <corosync/corotypes.h>
#include <corosync/cfg.h>
#include <corosync/quorum.h>
-#include "libfenced.h"
static corosync_cfg_handle_t ch;
static quorum_handle_t qh;
@@ -310,33 +309,3 @@ void close_cluster_cfg(void)
corosync_cfg_finalize(ch);
}
-int fence_node_time(int nodeid, uint64_t *last_fenced_time)
-{
- struct fenced_node nodeinfo;
- int rv;
-
- memset(&nodeinfo, 0, sizeof(nodeinfo));
-
- rv = fenced_node_info(nodeid, &nodeinfo);
- if (rv < 0)
- return rv;
-
- *last_fenced_time = nodeinfo.last_fenced_time;
- return 0;
-}
-
-int fence_in_progress(int *count)
-{
- struct fenced_domain domain;
- int rv;
-
- memset(&domain, 0, sizeof(domain));
-
- rv = fenced_domain_info(&domain);
- if (rv < 0)
- return rv;
-
- *count = domain.victim_count;
- return 0;
-}
-
12 years, 7 months
dlm: master - dlm_controld: reorganize quorum/fencing checks
by David Teigland
Gitweb: http://git.fedorahosted.org/git/dlm.git?p=dlm.git;a=commitdiff;h=a93c6d5b...
Commit: a93c6d5bcb9ddf52fa524895a65ce3aedb71819b
Parent: d4cf6836ee60d12d07841b44986cf443a8b4f2ce
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Oct 11 13:49:10 2011 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Oct 11 13:49:10 2011 -0500
dlm_controld: reorganize quorum/fencing checks
prepare for different fencing system(s)
Signed-off-by: David Teigland <teigland(a)redhat.com>
---
dlm_controld/cpg.c | 70 ++++++++++++++++++++++++++++++---------------
dlm_controld/dlm_daemon.h | 2 +-
dlm_controld/main.c | 2 +-
3 files changed, 49 insertions(+), 25 deletions(-)
diff --git a/dlm_controld/cpg.c b/dlm_controld/cpg.c
index 4bf7d1d..1d238ed 100644
--- a/dlm_controld/cpg.c
+++ b/dlm_controld/cpg.c
@@ -71,6 +71,7 @@ struct node {
int check_fs;
int fs_notified;
+ int request_fencing;
int check_fencing;
uint64_t fail_realtime;
uint64_t fence_realtime;
@@ -525,6 +526,7 @@ static void node_history_lockspace_fail(struct lockspace *ls, int nodeid,
}
if (cfgd_enable_fencing && node->start_time) {
+ node->request_fencing = 1;
node->check_fencing = 1;
node->fence_realtime = 0;
node->fence_queries = 0;
@@ -650,6 +652,34 @@ static int check_fencing_done(struct lockspace *ls)
return 1;
}
+static int need_fencing(struct lockspace *ls)
+{
+ struct node *node;
+
+ list_for_each_entry(node, &ls->node_history, list) {
+ if (node->check_fencing)
+ return 1;
+ }
+ return 0;
+}
+
+static void request_fencing(struct lockspace *ls)
+{
+ struct node *node;
+
+ list_for_each_entry(node, &ls->node_history, list) {
+ if (!node->request_fencing)
+ continue;
+
+ /* we don't need to ask fenced to initiate fencing; it does
+ so itself when it sees a fence domain member fail. Without
+ fenced we'll probably need to ask another daemon to initiate
+ fencing, then check with it above, like we check libfenced. */
+
+ node->request_fencing = 0;
+ }
+}
+
/* we know that the quorum value here is consistent with the cpg events
because the ringid's are in sync per the previous check_ringid_done */
@@ -661,11 +691,11 @@ static int check_quorum_done(struct lockspace *ls)
}
if (!cluster_quorate) {
- log_debug("check_quorum not quorate");
+ log_group(ls, "check_quorum not quorate");
return 0;
}
- log_debug("check_quorum done");
+ log_group(ls, "check_quorum done");
return 1;
}
@@ -791,34 +821,28 @@ static void stop_kernel(struct lockspace *ls, uint32_t seq)
don't need to check for because stop_kernel(), which is synchronous,
was done when the change was created */
+/* the fencing/quorum/fs conditions need to account for all the changes
+ that have occured since the last change applied to dlm-kernel, not
+ just the latest change */
+
static int wait_conditions_done(struct lockspace *ls)
{
- if (!check_ringid_done(ls)) {
- poll_ringid++;
+ if (!check_ringid_done(ls))
return 0;
- }
- /* the fencing/quorum/fs conditions need to account for all the changes
- that have occured since the last change applied to dlm-kernel, not
- just the latest change */
+ /* It's convenient to be able to join and leave lockspaces without
+ having quorum. If the fencing system does not wait for quorum
+ before carrying out fencing requests, then we may want to wait for
+ quorum here before requesting fencing, to avoid having partitioned
+ nodes fence good nodes. */
- if (!check_fencing_done(ls)) {
- poll_fencing++;
+ if (need_fencing(ls) && !check_quorum_done(ls))
return 0;
- }
- /* fencing waits for quorum, so we don't need to check quorum for any
- reasons related to safety or protection, so enable_quorum defaults
- to 0. This does mean that lockspaces (and cluster fs's) can be
- started/enabled in an inquorate cluster if there are no outstanding
- fencing operations. Some users or apps may want lockspaces/fs's to
- only be enabled in a quorate cluster; enable_quorum can be set to 1
- to get that behavior. The main advantage of not waiting for quorum
- here is to allow lockspaces to be shut down (and cluster fs's
- unmounted) in an inquorate cluster. */
+ request_fencing(ls);
- if (!check_quorum_done(ls)) {
- poll_quorum++;
+ if (!check_fencing_done(ls)) {
+ poll_fencing++;
return 0;
}
@@ -1903,7 +1927,7 @@ int dlm_join_lockspace(struct lockspace *ls)
/* TODO: allow global_id to be set in cluster.conf? */
ls->global_id = cpgname_to_crc(name.value, name.length);
- log_debug("cpg_join %s ...", name.value);
+ log_group(ls, "cpg_join %s ...", name.value);
retry:
error = cpg_join(h, &name);
if (error == CPG_ERR_TRY_AGAIN) {
diff --git a/dlm_controld/dlm_daemon.h b/dlm_controld/dlm_daemon.h
index 6129477..5209762 100644
--- a/dlm_controld/dlm_daemon.h
+++ b/dlm_controld/dlm_daemon.h
@@ -81,7 +81,7 @@
#define DEFAULT_DEBUG_LOGFILE 0
#define DEFAULT_ENABLE_FENCING 1
-#define DEFAULT_ENABLE_QUORUM 0
+#define DEFAULT_ENABLE_QUORUM 1
#define DEFAULT_ENABLE_PLOCK 1
#define DEFAULT_PLOCK_DEBUG 0
#define DEFAULT_PLOCK_RATE_LIMIT 0
diff --git a/dlm_controld/main.c b/dlm_controld/main.c
index 822a6a5..d28cc23 100644
--- a/dlm_controld/main.c
+++ b/dlm_controld/main.c
@@ -969,7 +969,7 @@ static void loop(void)
poll_timeout = -1;
- if (poll_fencing || poll_quorum || poll_fs) {
+ if (poll_fencing || poll_fs) {
process_lockspace_changes();
poll_timeout = 1000;
}
12 years, 7 months
dlm: master - dlm_controld: use monotonic times
by David Teigland
Gitweb: http://git.fedorahosted.org/git/dlm.git?p=dlm.git;a=commitdiff;h=d4cf6836...
Commit: d4cf6836ee60d12d07841b44986cf443a8b4f2ce
Parent: d218916fd8a4132d2b4df8b7853ad419b3538637
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Oct 7 15:46:12 2011 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Oct 7 15:46:12 2011 -0500
dlm_controld: use monotonic times
except for value compared to time from fenced
which is still real time
Signed-off-by: David Teigland <teigland(a)redhat.com>
---
dlm_controld/cpg.c | 26 +++++++++++++++-----------
dlm_controld/member_cman.c | 2 +-
dlm_controld/plock.c | 12 ++++++------
3 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/dlm_controld/cpg.c b/dlm_controld/cpg.c
index 4dc2bc2..4bf7d1d 100644
--- a/dlm_controld/cpg.c
+++ b/dlm_controld/cpg.c
@@ -72,7 +72,8 @@ struct node {
int fs_notified;
int check_fencing;
- uint64_t fence_time; /* for debug */
+ uint64_t fail_realtime;
+ uint64_t fence_realtime;
uint32_t fence_queries; /* for debug */
};
@@ -525,7 +526,7 @@ static void node_history_lockspace_fail(struct lockspace *ls, int nodeid,
if (cfgd_enable_fencing && node->start_time) {
node->check_fencing = 1;
- node->fence_time = 0;
+ node->fence_realtime = 0;
node->fence_queries = 0;
}
@@ -540,6 +541,7 @@ static void node_history_lockspace_fail(struct lockspace *ls, int nodeid,
node->lockspace_fail_time = now;
node->lockspace_fail_seq = node->lockspace_rem_seq;
node->lockspace_fail_reason = reason; /* for queries */
+ node->fail_realtime = time(NULL);
}
static void node_history_start(struct lockspace *ls, int nodeid)
@@ -552,7 +554,7 @@ static void node_history_start(struct lockspace *ls, int nodeid)
return;
}
- node->start_time = time(NULL);
+ node->start_time = monotime();
}
/* wait for cluster ringid and cpg ringid to be the same so we know our
@@ -596,31 +598,33 @@ static int check_fencing_done(struct lockspace *ls)
if (rv < 0)
log_error("fenced_node_info error %d", rv);
+ /* fenced gives us real time */
+
/* need >= not just > because in at least one case
we've seen fenced_time within the same second as
fail_time: with external fencing, e.g. fence_node */
- if (last_fenced_time >= node->lockspace_fail_time) {
+ if (last_fenced_time >= node->fail_realtime) {
log_group(ls, "check_fencing %d done "
"start %llu fail %llu last %llu",
node->nodeid,
(unsigned long long)node->start_time,
- (unsigned long long)node->lockspace_fail_time,
+ (unsigned long long)node->fail_realtime,
(unsigned long long)last_fenced_time);
node->check_fencing = 0;
node->start_time = 0;
- node->fence_time = last_fenced_time;
+ node->fence_realtime = last_fenced_time;
} else {
if (!node->fence_queries ||
- node->fence_time != last_fenced_time) {
+ node->fence_realtime != last_fenced_time) {
log_group(ls, "check_fencing %d wait "
"start %llu fail %llu last %llu",
node->nodeid,
(unsigned long long)node->start_time,
- (unsigned long long)node->lockspace_fail_time,
+ (unsigned long long)node->fail_realtime,
(unsigned long long)last_fenced_time);
node->fence_queries++;
- node->fence_time = last_fenced_time;
+ node->fence_realtime = last_fenced_time;
}
wait_count++;
}
@@ -1415,7 +1419,7 @@ static int add_change(struct lockspace *ls,
struct change *cg;
struct member *memb;
int i, error;
- uint64_t now = time(NULL);
+ uint64_t now = monotime();
cg = malloc(sizeof(struct change));
if (!cg)
@@ -2418,7 +2422,7 @@ static void confchg_cb_daemon(cpg_handle_t handle,
size_t joined_list_entries)
{
struct node_daemon *node;
- uint64_t now = time(NULL);
+ uint64_t now = monotime();
int i;
log_config(group_name, member_list, member_list_entries,
diff --git a/dlm_controld/member_cman.c b/dlm_controld/member_cman.c
index f7a099c..6bfb2a9 100644
--- a/dlm_controld/member_cman.c
+++ b/dlm_controld/member_cman.c
@@ -110,7 +110,7 @@ static void quorum_callback(quorum_handle_t h, uint32_t quorate,
corosync_cfg_node_address_t *addrptr = addrs;
cs_error_t err;
int i, j, num_addrs;
- uint64_t now = time(NULL);
+ uint64_t now = monotime();
if (!cluster_quorate && quorate)
quorate_time = now;
diff --git a/dlm_controld/plock.c b/dlm_controld/plock.c
index d475cf4..3e48267 100644
--- a/dlm_controld/plock.c
+++ b/dlm_controld/plock.c
@@ -813,11 +813,11 @@ static void __receive_plock(struct lockspace *ls, struct dlm_plock_info *in,
{
switch (in->optype) {
case DLM_PLOCK_OP_LOCK:
- ls->last_plock_time = time(NULL);
+ ls->last_plock_time = monotime();
do_lock(ls, in, r);
break;
case DLM_PLOCK_OP_UNLOCK:
- ls->last_plock_time = time(NULL);
+ ls->last_plock_time = monotime();
do_unlock(ls, in, r);
break;
case DLM_PLOCK_OP_GET:
@@ -1132,7 +1132,7 @@ static void _receive_own(struct lockspace *ls, struct dlm_header *hd, int len)
int from = hd->nodeid;
int rv;
- ls->last_plock_time = time(NULL);
+ ls->last_plock_time = monotime();
memcpy(&info, (char *)hd + sizeof(struct dlm_header), sizeof(info));
info_bswap_in(&info);
@@ -1305,7 +1305,7 @@ static void _receive_sync(struct lockspace *ls, struct dlm_header *hd, int len)
int from = hd->nodeid;
int rv;
- ls->last_plock_time = time(NULL);
+ ls->last_plock_time = monotime();
memcpy(&info, (char *)hd + sizeof(struct dlm_header), sizeof(info));
info_bswap_in(&info);
@@ -1352,7 +1352,7 @@ static void _receive_drop(struct lockspace *ls, struct dlm_header *hd, int len)
int from = hd->nodeid;
int rv;
- ls->last_plock_time = time(NULL);
+ ls->last_plock_time = monotime();
memcpy(&info, (char *)hd + sizeof(struct dlm_header), sizeof(info));
info_bswap_in(&info);
@@ -2072,7 +2072,7 @@ void purge_plocks(struct lockspace *ls, int nodeid, int unmount)
}
if (purged)
- ls->last_plock_time = time(NULL);
+ ls->last_plock_time = monotime();
log_dlock(ls, "purged %d plocks for %d", purged, nodeid);
}
12 years, 7 months