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: 23 Apr 2007 15:24:48 -0000	[thread overview]
Message-ID: <20070423152448.20798.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	teigland at sourceware.org	2007-04-23 16:24:47

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

Log message:
	Look for a protocol setting in cluster.conf dlm section, and set
	kernel accordingly if found.
	Also, set /proc/self/oom_adj (all daemons will get this).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/dlm_controld/action.c.diff?cvsroot=cluster&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/dlm_controld/dlm_daemon.h.diff?cvsroot=cluster&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/dlm_controld/main.c.diff?cvsroot=cluster&r1=1.9&r2=1.10

--- cluster/group/dlm_controld/action.c	2007/01/09 19:17:08	1.9
+++ cluster/group/dlm_controld/action.c	2007/04/23 15:24:47	1.10
@@ -692,3 +692,87 @@
 	return 0;
 }
 
+#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);
+	return rv;
+}
+
+static int set_configfs_protocol(int proto)
+{
+	char path[PATH_MAX];
+	char buf[32];
+	int fd, rv;
+
+	rv = add_configfs_base();
+	if (rv < 0)
+		return rv;
+
+	memset(path, 0, PATH_MAX);
+	snprintf(path, PATH_MAX, "%s/protocol", CLUSTER_DIR);
+
+	fd = open(path, O_WRONLY);
+	if (fd < 0) {
+		log_debug("%s: open failed: %d", path, errno);
+		return fd;
+	}
+
+	memset(buf, 0, sizeof(buf));
+	snprintf(buf, 32, "%d", proto);
+
+	rv = do_write(fd, buf, strlen(buf));
+	if (rv < 0) {
+		log_error("%s: write failed: %d", path, errno);
+		return rv;
+	}
+	close(fd);
+	return 0;
+}
+
+void set_protocol(void)
+{
+	int cd, rv, proto;
+
+	cd = open_ccs();
+
+	rv = get_ccs_protocol(cd);
+
+	if (!rv || rv < 0)
+		goto out;
+
+	/* for dlm kernel, TCP=0 and SCTP=1 */
+	if (rv == PROTO_TCP)
+		proto = 0;
+	else if (rv == PROTO_SCTP)
+		proto = 1;
+	else
+		goto out;
+
+	set_configfs_protocol(proto);
+ out:
+	ccs_disconnect(cd);
+}
+
--- cluster/group/dlm_controld/dlm_daemon.h	2007/02/09 16:05:30	1.7
+++ cluster/group/dlm_controld/dlm_daemon.h	2007/04/23 15:24:47	1.8
@@ -84,6 +84,7 @@
 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);
 
 /* member_xxx.c */
 int setup_member(void);
--- cluster/group/dlm_controld/main.c	2007/02/09 16:05:30	1.9
+++ cluster/group/dlm_controld/main.c	2007/04/23 15:24:47	1.10
@@ -399,6 +399,18 @@
 	}
 }
 
+void set_oom_adj(int val)
+{
+	FILE *fp;
+
+	fp = fopen("/proc/self/oom_adj", "w");
+	if (!fp)
+		return;
+
+	fprintf(fp, "%i", val);
+	fclose(fp);
+}
+
 void set_scheduler(void)
 {
 	struct sched_param sched_param;
@@ -431,6 +443,8 @@
 	signal(SIGTERM, sigterm_handler);
 
 	set_scheduler();
+	set_oom_adj(-16);
+	set_protocol();
 
 	return loop();
 }



             reply	other threads:[~2007-04-23 15:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-23 15:24 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-05-04 21:05 teigland
2007-04-23 15:31 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=20070423152448.20798.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.