All of lore.kernel.org
 help / color / mirror / Atom feed
From: teigland@sourceware.org <teigland@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/group/dlm_controld action.c dlm_daemon ...
Date: 4 May 2007 21:05:29 -0000	[thread overview]
Message-ID: <20070504210529.8763.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	teigland at sourceware.org	2007-05-04 21:05:28

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&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/dlm_controld/dlm_daemon.h.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/dlm_controld/main.c.diff?cvsroot=cluster&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/dlm_controld/member_cman.c.diff?cvsroot=cluster&r1=1.6&r2=1.7

--- cluster/group/dlm_controld/action.c	2007/04/23 15:24:47	1.10
+++ cluster/group/dlm_controld/action.c	2007/05/04 21:05:28	1.11
@@ -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:24:47	1.8
+++ cluster/group/dlm_controld/dlm_daemon.h	2007/05/04 21:05:28	1.9
@@ -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:24:47	1.10
+++ cluster/group/dlm_controld/main.c	2007/05/04 21:05:28	1.11
@@ -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:17:08	1.6
+++ cluster/group/dlm_controld/member_cman.c	2007/05/04 21:05:28	1.7
@@ -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;



             reply	other threads:[~2007-05-04 21:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-04 21:05 teigland [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-05-04 21:14 [Cluster-devel] cluster/group/dlm_controld action.c dlm_daemon teigland
2007-04-23 15:31 teigland
2007-04-23 15:24 teigland
2007-01-09 19:18 teigland
2007-01-09 19:17 teigland
2006-10-24 16:16 teigland
2006-10-05  7:52 pcaulfield

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070504210529.8763.qmail@sourceware.org \
    --to=teigland@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.