[Cluster-devel] cluster/group/dlm_controld action.c dlm_daemon ...

teigland at sourceware.org teigland at sourceware.org
Fri May 4 21:14:33 UTC 2007


CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	teigland at sourceware.org	2007-05-04 21:14:32

Modified files:
	group/dlm_controld: action.c dlm_daemon.h main.c member_cman.c 

Log message:
	Look in cluster.conf dlm section for protocol, timewarn, and log_debug
	settings and apply them to kernel if found.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/dlm_controld/action.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.8.2.2&r2=1.8.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/dlm_controld/dlm_daemon.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.5.2.3&r2=1.5.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/dlm_controld/main.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.6.2.4&r2=1.6.2.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/dlm_controld/member_cman.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.4.2.2&r2=1.4.2.3

--- cluster/group/dlm_controld/action.c	2007/04/23 15:31:02	1.8.2.2
+++ cluster/group/dlm_controld/action.c	2007/05/04 21:14:32	1.8.2.3
@@ -661,7 +661,89 @@
 		log_error("%s: rmdir failed: %d", path, errno);
 }
 
-int set_configfs_debug(int val)
+#define PROTOCOL_PATH "/cluster/dlm/@protocol"
+#define PROTO_TCP  1
+#define PROTO_SCTP 2
+
+static int get_ccs_protocol(int cd)
+{
+	char path[PATH_MAX], *str;
+	int error, rv;
+
+	memset(path, 0, PATH_MAX);
+	sprintf(path, PROTOCOL_PATH);
+
+	error = ccs_get(cd, path, &str);
+	if (error || !str)
+		return -1;
+
+	if (!strncasecmp(str, "tcp", 3))
+		rv = PROTO_TCP;
+	else if (!strncasecmp(str, "sctp", 4))
+		rv = PROTO_SCTP;
+	else {
+		log_error("read invalid dlm protocol from ccs");
+		rv = 0;
+	}
+
+	free(str);
+	log_debug("got ccs protocol %d", rv);
+	return rv;
+}
+
+#define TIMEWARN_PATH "/cluster/dlm/@timewarn"
+
+static int get_ccs_timewarn(int cd)
+{
+	char path[PATH_MAX], *str;
+	int error, rv;
+
+	memset(path, 0, PATH_MAX);
+	sprintf(path, TIMEWARN_PATH);
+
+	error = ccs_get(cd, path, &str);
+	if (error || !str)
+		return -1;
+
+	rv = atoi(str);
+
+	if (rv <= 0) {
+		log_error("read invalid dlm timewarn from ccs");
+		rv = -1;
+	}
+
+	free(str);
+	log_debug("got ccs timewarn %d", rv);
+	return rv;
+}
+
+#define DEBUG_PATH "/cluster/dlm/@log_debug"
+
+static int get_ccs_debug(int cd)
+{
+	char path[PATH_MAX], *str;
+	int error, rv;
+
+	memset(path, 0, PATH_MAX);
+	sprintf(path, DEBUG_PATH);
+
+	error = ccs_get(cd, path, &str);
+	if (error || !str)
+		return -1;
+
+	rv = atoi(str);
+
+	if (rv < 0) {
+		log_error("read invalid dlm log_debug from ccs");
+		rv = -1;
+	}
+
+	free(str);
+	log_debug("got ccs log_debug %d", rv);
+	return rv;
+}
+
+static int set_configfs_protocol(int proto)
 {
 	char path[PATH_MAX];
 	char buf[32];
@@ -672,16 +754,16 @@
 		return rv;
 
 	memset(path, 0, PATH_MAX);
-	snprintf(path, PATH_MAX, "%s/log_debug", CLUSTER_DIR);
+	snprintf(path, PATH_MAX, "%s/protocol", CLUSTER_DIR);
 
 	fd = open(path, O_WRONLY);
 	if (fd < 0) {
-		log_debug("%s: open failed: %d", path, errno);
+		log_error("%s: open failed: %d", path, errno);
 		return fd;
 	}
 
 	memset(buf, 0, sizeof(buf));
-	snprintf(buf, 32, "%d", val);
+	snprintf(buf, 32, "%d", proto);
 
 	rv = do_write(fd, buf, strlen(buf));
 	if (rv < 0) {
@@ -689,39 +771,43 @@
 		return rv;
 	}
 	close(fd);
+	log_debug("set protocol %d", proto);
 	return 0;
 }
 
-#define PROTOCOL_PATH "/cluster/dlm/@protocol"
-#define PROTO_TCP  1
-#define PROTO_SCTP 2
-
-static int get_ccs_protocol(int cd)
+static int set_configfs_timewarn(int cs)
 {
-	char path[PATH_MAX], *str;
-	int error, rv;
+	char path[PATH_MAX];
+	char buf[32];
+	int fd, rv;
 
-	memset(path, 0, PATH_MAX);
-	sprintf(path, PROTOCOL_PATH);
+	rv = add_configfs_base();
+	if (rv < 0)
+		return rv;
 
-	error = ccs_get(cd, path, &str);
-	if (error || !str)
-		return -1;
+	memset(path, 0, PATH_MAX);
+	snprintf(path, PATH_MAX, "%s/timewarn_cs", CLUSTER_DIR);
 
-	if (!strncasecmp(str, "tcp", 3))
-		rv = PROTO_TCP;
-	else if (!strncasecmp(str, "sctp", 4))
-		rv = PROTO_SCTP;
-	else {
-		log_error("read invalid dlm protocol from ccs");
-		rv = 0;
+	fd = open(path, O_WRONLY);
+	if (fd < 0) {
+		log_error("%s: open failed: %d", path, errno);
+		return fd;
 	}
 
-	free(str);
-	return rv;
+	memset(buf, 0, sizeof(buf));
+	snprintf(buf, 32, "%d", cs);
+
+	rv = do_write(fd, buf, strlen(buf));
+	if (rv < 0) {
+		log_error("%s: write failed: %d", path, errno);
+		return rv;
+	}
+	close(fd);
+	log_debug("set timewarn_cs %d", cs);
+	return 0;
 }
 
-static int set_configfs_protocol(int proto)
+static int set_configfs_debug(int val)
 {
 	char path[PATH_MAX];
 	char buf[32];
@@ -732,16 +818,16 @@
 		return rv;
 
 	memset(path, 0, PATH_MAX);
-	snprintf(path, PATH_MAX, "%s/protocol", CLUSTER_DIR);
+	snprintf(path, PATH_MAX, "%s/log_debug", CLUSTER_DIR);
 
 	fd = open(path, O_WRONLY);
 	if (fd < 0) {
-		log_debug("%s: open failed: %d", path, errno);
+		log_error("%s: open failed: %d", path, errno);
 		return fd;
 	}
 
 	memset(buf, 0, sizeof(buf));
-	snprintf(buf, 32, "%d", proto);
+	snprintf(buf, 32, "%d", val);
 
 	rv = do_write(fd, buf, strlen(buf));
 	if (rv < 0) {
@@ -749,19 +835,17 @@
 		return rv;
 	}
 	close(fd);
+	log_debug("set log_debug %d", val);
 	return 0;
 }
 
-void set_protocol(void)
+static void set_protocol(int cd)
 {
-	int cd, rv, proto;
-
-	cd = open_ccs();
+	int rv, proto;
 
 	rv = get_ccs_protocol(cd);
-
 	if (!rv || rv < 0)
-		goto out;
+		return;
 
 	/* for dlm kernel, TCP=0 and SCTP=1 */
 	if (rv == PROTO_TCP)
@@ -769,10 +853,45 @@
 	else if (rv == PROTO_SCTP)
 		proto = 1;
 	else
-		goto out;
+		return;
 
 	set_configfs_protocol(proto);
- out:
+}
+
+static void set_timewarn(int cd)
+{
+	int rv;
+
+	rv = get_ccs_timewarn(cd);
+	if (rv < 0)
+		return;
+
+	set_configfs_timewarn(rv);
+}
+
+static void set_debug(int cd)
+{
+	int rv;
+
+	rv = get_ccs_debug(cd);
+	if (rv < 0)
+		return;
+
+	set_configfs_debug(rv);
+}
+
+void set_ccs_options(void)
+{
+	int cd;
+
+	cd = open_ccs();
+
+	log_debug("set_ccs_options %d", cd);
+
+	set_protocol(cd);
+	set_timewarn(cd);
+	set_debug(cd);
+
 	ccs_disconnect(cd);
 }
 
--- cluster/group/dlm_controld/dlm_daemon.h	2007/04/23 15:31:02	1.5.2.3
+++ cluster/group/dlm_controld/dlm_daemon.h	2007/05/04 21:14:32	1.5.2.4
@@ -83,8 +83,7 @@
 void clear_configfs(void);
 int set_members(char *name, int new_count, int *new_members);
 int set_id(char *name, uint32_t id);
-int set_configfs_debug(int val);
-void set_protocol(void);
+void set_ccs_options(void);
 
 /* member_xxx.c */
 int setup_member(void);
--- cluster/group/dlm_controld/main.c	2007/04/23 15:31:02	1.6.2.4
+++ cluster/group/dlm_controld/main.c	2007/05/04 21:14:32	1.6.2.5
@@ -444,7 +444,13 @@
 
 	set_scheduler();
 	set_oom_adj(-16);
-	set_protocol();
+
+	/* if this daemon was killed and the cluster shut down, and
+	   then the cluster brought back up and this daemon restarted,
+	   there will be old configfs entries we need to clear out */
+	clear_configfs();
+
+	set_ccs_options();
 
 	return loop();
 }
--- cluster/group/dlm_controld/member_cman.c	2007/01/09 19:18:18	1.4.2.2
+++ cluster/group/dlm_controld/member_cman.c	2007/05/04 21:14:32	1.4.2.3
@@ -173,14 +173,6 @@
 	}
 	local_nodeid = node.cn_nodeid;
 
-	/* if this daemon was killed and the cluster shut down, and
-	   then the cluster brought back up and this daemon restarted,
-	   there will be old configfs entries we need to clear out */
-
-	clear_configfs();
-
-	set_configfs_debug(kernel_debug_opt);
-
 	old_node_count = 0;
 	memset(&old_nodes, 0, sizeof(old_nodes));
 	cman_node_count = 0;




More information about the Cluster-devel mailing list