[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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



CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	teigland sourceware org	2007-04-23 16:31:03

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&only_with_tag=RHEL5&r1=1.8.2.1&r2=1.8.2.2
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.2&r2=1.5.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/dlm_controld/main.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.6.2.3&r2=1.6.2.4

--- cluster/group/dlm_controld/action.c	2007/01/09 19:18:18	1.8.2.1
+++ cluster/group/dlm_controld/action.c	2007/04/23 15:31:02	1.8.2.2
@@ -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:38	1.5.2.2
+++ cluster/group/dlm_controld/dlm_daemon.h	2007/04/23 15:31:02	1.5.2.3
@@ -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:38	1.6.2.3
+++ cluster/group/dlm_controld/main.c	2007/04/23 15:31:02	1.6.2.4
@@ -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();
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]