master - dlm_controld: isolate cman and fence code

David Teigland teigland@fedoraproject.org
Wed Aug 20 20:23:00 GMT 2008


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=27dd7c7b36949a06e5130f62c8ad0eb4dac19bb8
Commit:        27dd7c7b36949a06e5130f62c8ad0eb4dac19bb8
Parent:        474a67543034f409f56ab0f9f4bd6c17a0936d07
Author:        David Teigland <teigland@redhat.com>
AuthorDate:    Wed Aug 20 14:13:50 2008 -0500
Committer:     David Teigland <teigland@redhat.com>
CommitterDate: Wed Aug 20 14:13:50 2008 -0500

dlm_controld: isolate cman and fence code

in member_cman.c, so that alternative code can be compiled instead.

Signed-off-by: David Teigland <teigland@redhat.com>
---
 group/dlm_controld/action.c      |    6 ++--
 group/dlm_controld/config.c      |   38 -------------------------------
 group/dlm_controld/cpg.c         |   28 ++++++++++-------------
 group/dlm_controld/dlm_daemon.h  |   43 ++++++++++++++++++++++++++---------
 group/dlm_controld/main.c        |   46 ++++++++++++++++++++++++++++++++++---
 group/dlm_controld/member_cman.c |   45 +++++++++++++++++++++++++++++++-----
 6 files changed, 127 insertions(+), 79 deletions(-)

diff --git a/group/dlm_controld/action.c b/group/dlm_controld/action.c
index 18d0b09..e201e4f 100644
--- a/group/dlm_controld/action.c
+++ b/group/dlm_controld/action.c
@@ -354,8 +354,8 @@ int set_configfs_members(char *name, int new_count, int *new_members,
 		else if (id_exists(id, old_count, old_members))
 			continue;
 
-		if (!is_cman_member(id))
-			cman_statechange();
+		if (!is_cluster_member(id))
+			update_cluster();
 		/*
 		 * create node's dir
 		 */
@@ -813,7 +813,7 @@ int setup_configfs(void)
 		return rv;
 
 	/* add configfs entries for existing nodes */
-	cman_statechange();
+	update_cluster();
 
 	/* the kernel has its own defaults for these values which we
 	   don't want to change unless these have been set; -1 means
diff --git a/group/dlm_controld/config.c b/group/dlm_controld/config.c
index 372028f..1460ad6 100644
--- a/group/dlm_controld/config.c
+++ b/group/dlm_controld/config.c
@@ -30,44 +30,6 @@
 
 static int ccs_handle;
 
-/* was a config value set on command line?, 0 or 1.
-   optk is a kernel option, optd is a daemon option */
-
-int optk_debug;
-int optk_timewarn;
-int optk_protocol;
-int optd_groupd_compat;
-int optd_debug_logsys;
-int optd_enable_fencing;
-int optd_enable_quorum;
-int optd_enable_deadlk;
-int optd_enable_plock;
-int optd_plock_debug;
-int optd_plock_rate_limit;
-int optd_plock_ownership;
-int optd_drop_resources_time;
-int optd_drop_resources_count;
-int optd_drop_resources_age;
-
-/* actual config value from command line, cluster.conf, or default.
-   cfgk is a kernel config value, cfgd is a daemon config value */
-
-int cfgk_debug			= -1;
-int cfgk_timewarn		= -1;
-int cfgk_protocol		= -1;
-int cfgd_groupd_compat		= DEFAULT_GROUPD_COMPAT;
-int cfgd_debug_logsys		= DEFAULT_DEBUG_LOGSYS;
-int cfgd_enable_fencing		= DEFAULT_ENABLE_FENCING;
-int cfgd_enable_quorum		= DEFAULT_ENABLE_QUORUM;
-int cfgd_enable_deadlk		= DEFAULT_ENABLE_DEADLK;
-int cfgd_enable_plock		= DEFAULT_ENABLE_PLOCK;
-int cfgd_plock_debug		= DEFAULT_PLOCK_DEBUG;
-int cfgd_plock_rate_limit	= DEFAULT_PLOCK_RATE_LIMIT;
-int cfgd_plock_ownership	= DEFAULT_PLOCK_OWNERSHIP;
-int cfgd_drop_resources_time	= DEFAULT_DROP_RESOURCES_TIME;
-int cfgd_drop_resources_count	= DEFAULT_DROP_RESOURCES_COUNT;
-int cfgd_drop_resources_age	= DEFAULT_DROP_RESOURCES_AGE;
-
 /* when not set in cluster.conf, a node's default weight is 1 */
 
 #define MASTER_PATH "/cluster/dlm/lockspace[@name=\"%s\"]/master"
diff --git a/group/dlm_controld/cpg.c b/group/dlm_controld/cpg.c
index 6559906..a62520a 100644
--- a/group/dlm_controld/cpg.c
+++ b/group/dlm_controld/cpg.c
@@ -1,6 +1,5 @@
 #include "dlm_daemon.h"
 #include "config.h"
-#include "libfenced.h"
 
 uint32_t cpgname_to_crc(const char *data, int len);
 
@@ -386,9 +385,8 @@ static void node_history_fail(struct lockspace *ls, int nodeid,
 static int check_fencing_done(struct lockspace *ls)
 {
 	struct node *node;
-	struct fenced_node nodeinfo;
-	struct fenced_domain domain;
-	int wait_count = 0;
+	uint64_t last_fenced_time;
+	int in_progress, wait_count = 0;
 	int rv;
 
 	if (!cfgd_enable_fencing)
@@ -401,13 +399,11 @@ static int check_fencing_done(struct lockspace *ls)
 		/* check with fenced to see if the node has been
 		   fenced since node->add_time */
 
-		memset(&nodeinfo, 0, sizeof(nodeinfo));
-
-		rv = fenced_node_info(node->nodeid, &nodeinfo);
+		rv = fence_node_time(node->nodeid, &last_fenced_time);
 		if (rv < 0)
 			log_error("fenced_node_info error %d", rv);
 
-		if (nodeinfo.last_fenced_time > node->add_time) {
+		if (last_fenced_time > node->add_time) {
 			node->check_fencing = 0;
 			node->add_time = 0;
 		} else {
@@ -424,13 +420,13 @@ static int check_fencing_done(struct lockspace *ls)
 	   we may not have seen in any lockspace), and return 0 if there
 	   are any */
 
-	rv = fenced_domain_info(&domain);
+	rv = fence_in_progress(&in_progress);
 	if (rv < 0) {
 		log_error("fenced_domain_info error %d", rv);
 		return 0;
 	}
 
-	if (domain.victim_count)
+	if (in_progress)
 		return 0;
 	return 1;
 }
@@ -443,18 +439,18 @@ static int check_quorum_done(struct lockspace *ls)
 	if (!cfgd_enable_quorum)
 		return 1;
 
-	/* wait for cman to see all the same nodes failed, so we know that
-	   cman_quorate is adjusted for the same failures we've seen
-	   (see comment in fenced about the assumption here) */
+	/* wait for quorum system (cman) to see all the same nodes failed, so
+	   we know that cluster_quorate is adjusted for the same failures we've
+	   seen (see comment in fenced about the assumption here) */
 
 	list_for_each_entry(node, &ls->node_history, list) {
 		if (!node->check_quorum)
 			continue;
 
-		if (!is_cman_member(node->nodeid)) {
+		if (!is_cluster_member(node->nodeid)) {
 			node->check_quorum = 0;
 		} else {
-			log_group(ls, "check_quorum %d is_cman_member",
+			log_group(ls, "check_quorum %d is_cluster_member",
 				  node->nodeid);
 			wait_count++;
 		}
@@ -463,7 +459,7 @@ static int check_quorum_done(struct lockspace *ls)
 	if (wait_count)
 		return 0;
 
-	if (!cman_quorate) {
+	if (!cluster_quorate) {
 		log_group(ls, "check_quorum not quorate");
 		return 0;
 	}
diff --git a/group/dlm_controld/dlm_daemon.h b/group/dlm_controld/dlm_daemon.h
index 3a4b31c..f1f4c29 100644
--- a/group/dlm_controld/dlm_daemon.h
+++ b/group/dlm_controld/dlm_daemon.h
@@ -74,7 +74,7 @@ extern int poll_ignore_plock;
 extern int plock_fd;
 extern int plock_ci;
 extern struct list_head lockspaces;
-extern int cman_quorate;
+extern int cluster_quorate;
 extern int our_nodeid;
 extern char daemon_debug_buf[256];
 extern char dump_buf[DLMC_DUMP_SIZE];
@@ -270,13 +270,15 @@ char *dlm_mode_str(int mode);
 void cluster_dead(int ci);
 
 /* member_cman.c */
-int setup_cman(void);
-void close_cman(void);
-void process_cman(int ci);
-void cman_statechange(void);
-int is_cman_member(int nodeid);
+int setup_cluster(void);
+void close_cluster(void);
+void process_cluster(int ci);
+void update_cluster(void);
+int is_cluster_member(int nodeid);
 char *nodeid2name(int nodeid);
 void kick_node_from_cluster(int nodeid);
+int fence_node_time(int nodeid, uint64_t *last_fenced_time);
+int fence_in_progress(int *count);
 
 /* netlink.c */
 int setup_netlink(void);
@@ -298,19 +300,38 @@ void purge_plocks(struct lockspace *ls, int nodeid, int unmount);
 int fill_plock_dump_buf(struct lockspace *ls);
 
 /* group.c */
+#define BUILD_GROUPD_COMPAT
+#ifdef BUILD_GROUPD_COMPAT
 int setup_groupd(void);
 void close_groupd(void);
 void process_groupd(int ci);
 int dlm_join_lockspace_group(struct lockspace *ls);
 int dlm_leave_lockspace_group(struct lockspace *ls);
 int set_node_info_group(struct lockspace *ls, int nodeid,
-			struct dlmc_node *node);
+	struct dlmc_node *node);
 int set_lockspace_info_group(struct lockspace *ls,
-			struct dlmc_lockspace *lockspace);
-int set_lockspaces_group(int *count, struct dlmc_lockspace **lss_out);
-int set_lockspace_nodes_group(struct lockspace *ls, int option, int *node_count,
-			struct dlmc_node **nodes);
+	struct dlmc_lockspace *lockspace);
+int set_lockspaces_group(int *count,
+	struct dlmc_lockspace **lss_out);
+int set_lockspace_nodes_group(struct lockspace *ls, int option,
+	int *node_count, struct dlmc_node **nodes);
 void set_group_mode(void);
+#else
+static inline int setup_groupd(void) { return -1; }
+static inline void close_groupd(void) { }
+static inline void process_groupd(int ci) { }
+static inline int dlm_join_lockspace_group(struct lockspace *ls) { return -1; }
+static inline int dlm_leave_lockspace_group(struct lockspace *ls) { return -1; }
+static inline int set_node_info_group(struct lockspace *ls, int nodeid,
+	struct dlmc_node *node) { return -1; }
+static inline int set_lockspace_info_group(struct lockspace *ls,
+	struct dlmc_lockspace *lockspace) { return -1; }
+static inline int set_lockspaces_group(int *count,
+	struct dlmc_lockspace **lss_out) { return -1; }
+static inline int set_lockspace_nodes_group(struct lockspace *ls, int option,
+	int *node_count, struct dlmc_node **nodes) { return -1; }
+static inline void set_group_mode(void) { }
+#endif
 
 /* logging.c */
 
diff --git a/group/dlm_controld/main.c b/group/dlm_controld/main.c
index d712b88..a4c38b9 100644
--- a/group/dlm_controld/main.c
+++ b/group/dlm_controld/main.c
@@ -877,10 +877,10 @@ static void loop(void)
 		goto out;
 	client_add(rv, process_listener, NULL);
 
-	rv = setup_cman();
+	rv = setup_cluster();
 	if (rv < 0)
 		goto out;
-	client_add(rv, process_cman, cluster_dead);
+	client_add(rv, process_cluster, cluster_dead);
 
 	rv = setup_ccs();
 	if (rv < 0)
@@ -997,7 +997,7 @@ static void loop(void)
 	clear_configfs();
 	close_logging();
 	close_ccs();
-	close_cman();
+	close_cluster();
 
 	if (!list_empty(&lockspaces))
 		log_error("lockspaces abandoned");
@@ -1287,7 +1287,7 @@ int poll_ignore_plock;
 int plock_fd;
 int plock_ci;
 struct list_head lockspaces;
-int cman_quorate;
+int cluster_quorate;
 int our_nodeid;
 char daemon_debug_buf[256];
 char dump_buf[DLMC_DUMP_SIZE];
@@ -1301,3 +1301,41 @@ uint32_t monitor_minor;
 uint32_t plock_minor;
 uint32_t old_plock_minor;
 
+/* was a config value set on command line?, 0 or 1.
+   optk is a kernel option, optd is a daemon option */
+
+int optk_debug;
+int optk_timewarn;
+int optk_protocol;
+int optd_groupd_compat;
+int optd_debug_logsys;
+int optd_enable_fencing;
+int optd_enable_quorum;
+int optd_enable_deadlk;
+int optd_enable_plock;
+int optd_plock_debug;
+int optd_plock_rate_limit;
+int optd_plock_ownership;
+int optd_drop_resources_time;
+int optd_drop_resources_count;
+int optd_drop_resources_age;
+
+/* actual config value from command line, cluster.conf, or default.
+   cfgk is a kernel config value, cfgd is a daemon config value */
+
+int cfgk_debug                  = -1;
+int cfgk_timewarn               = -1;
+int cfgk_protocol               = -1;
+int cfgd_groupd_compat          = DEFAULT_GROUPD_COMPAT;
+int cfgd_debug_logsys           = DEFAULT_DEBUG_LOGSYS;
+int cfgd_enable_fencing         = DEFAULT_ENABLE_FENCING;
+int cfgd_enable_quorum          = DEFAULT_ENABLE_QUORUM;
+int cfgd_enable_deadlk          = DEFAULT_ENABLE_DEADLK;
+int cfgd_enable_plock           = DEFAULT_ENABLE_PLOCK;
+int cfgd_plock_debug            = DEFAULT_PLOCK_DEBUG;
+int cfgd_plock_rate_limit       = DEFAULT_PLOCK_RATE_LIMIT;
+int cfgd_plock_ownership        = DEFAULT_PLOCK_OWNERSHIP;
+int cfgd_drop_resources_time    = DEFAULT_DROP_RESOURCES_TIME;
+int cfgd_drop_resources_count   = DEFAULT_DROP_RESOURCES_COUNT;
+int cfgd_drop_resources_age     = DEFAULT_DROP_RESOURCES_AGE;
+
diff --git a/group/dlm_controld/member_cman.c b/group/dlm_controld/member_cman.c
index 7fe0b95..8ecc5af 100644
--- a/group/dlm_controld/member_cman.c
+++ b/group/dlm_controld/member_cman.c
@@ -1,6 +1,7 @@
 #include "dlm_daemon.h"
 #include "config.h"
 #include <libcman.h>
+#include "libfenced.h"
 
 static cman_handle_t	ch;
 static cman_handle_t	ch_admin;
@@ -37,7 +38,7 @@ static int is_old_member(int nodeid)
 	return is_member(old_nodes, old_node_count, nodeid);
 }
 
-int is_cman_member(int nodeid)
+int is_cluster_member(int nodeid)
 {
 	return is_member(cman_nodes, cman_node_count, nodeid);
 }
@@ -73,7 +74,7 @@ static void statechange(void)
 	int num_addrs;
 	struct cman_node_address *addrptr = addrs;
 
-	cman_quorate = cman_is_quorate(ch);
+	cluster_quorate = cman_is_quorate(ch);
 
 	old_node_count = cman_node_count;
 	memcpy(&old_nodes, &cman_nodes, sizeof(old_nodes));
@@ -96,7 +97,7 @@ static void statechange(void)
 
 	for (i = 0; i < old_node_count; i++) {
 		if (old_nodes[i].cn_member &&
-		    !is_cman_member(old_nodes[i].cn_nodeid)) {
+		    !is_cluster_member(old_nodes[i].cn_nodeid)) {
 
 			log_debug("cman: node %d removed",
 				   old_nodes[i].cn_nodeid);
@@ -149,7 +150,7 @@ static void cman_callback(cman_handle_t h, void *private, int reason, int arg)
 	}
 }
 
-void process_cman(int ci)
+void process_cluster(int ci)
 {
 	int rv;
 
@@ -158,7 +159,7 @@ void process_cman(int ci)
 		cluster_dead(0);
 }
 
-int setup_cman(void)
+int setup_cluster(void)
 {
 	cman_node_t node;
 	int rv, fd;
@@ -222,14 +223,44 @@ int setup_cman(void)
 	return fd;
 }
 
-void close_cman(void)
+void close_cluster(void)
 {
 	cman_finish(ch);
 }
 
 /* Force re-read of cman nodes */
-void cman_statechange(void)
+void update_cluster(void)
 {
 	statechange();
 }
 
+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;
+}
+



More information about the Cluster-cvs mailing list