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

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



CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	rohara sourceware org	2007-06-05 20:12:43

Modified files:
	group/dlm_controld: action.c 

Log message:
	New lockspace config for external dlm.
	Changed get_weight to look for node weight in lockspace config.

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.3&r2=1.8.2.4

--- cluster/group/dlm_controld/action.c	2007/05/04 21:14:32	1.8.2.3
+++ cluster/group/dlm_controld/action.c	2007/06/05 20:12:43	1.8.2.4
@@ -205,12 +205,16 @@
 
 /* when not set in cluster.conf, a node's default weight is 1 */
 
+#define MASTER_PATH "/cluster/dlm/lockspace[ name=\"%s\"]/master"
 #define WEIGHT_PATH "/cluster/clusternodes/clusternode[ name=\"%s\"]/@weight"
 
-static int get_weight(int cd, int nodeid)
+#define MASTER_NAME   MASTER_PATH "/@name"
+#define MASTER_WEIGHT MASTER_PATH "[ name=\"%s\"]/@weight"
+
+static int get_weight(int cd, int nodeid, char *lockspace)
 {
 	char path[PATH_MAX], *str, *name;
-	int error, w;
+	int error, weight, flag = 0, count = 0;
 
 	name = nodeid2name(nodeid);
 	if (!name) {
@@ -219,15 +223,48 @@
 	}
 
 	memset(path, 0, PATH_MAX);
-	sprintf(path, WEIGHT_PATH, name);
+	sprintf(path, MASTER_NAME, lockspace);
 
-	error = ccs_get(cd, path, &str);
-	if (error || !str)
-		return 1;
+	while (1)
+	{
+		error = ccs_get_list(cd, path, &str);
+		if (error || !str) {
+			break;
+		}
+		count++;
+		if (strcmp(str, name) == 0) {
+			flag = 1;
+		}
+		free(str);
+	}
 
-	w = atoi(str);
-	free(str);
-	return w;
+	if (count > 0) {
+		if (flag) {
+			memset(path, 0, PATH_MAX);
+			sprintf(path, MASTER_WEIGHT, lockspace, name);
+
+			error = ccs_get(cd, path, &str);
+			if (error || !str)
+				return 1;
+
+			weight = atoi(str);
+			free(str);
+			return weight;
+		} else {
+			return 0;
+		}
+	} else {
+		memset(path, 0, PATH_MAX);
+		sprintf(path, WEIGHT_PATH, name);
+
+		error = ccs_get(cd, path, &str);
+		if (error || !str)
+			return 1;
+
+		weight = atoi(str);
+		free(str);
+		return weight;
+	}
 }
 
 int set_members(char *name, int new_count, int *new_members)
@@ -346,7 +383,7 @@
 		if (!cd)
 			cd = open_ccs();
 
-		w = get_weight(cd, id);
+		w = get_weight(cd, id, name);
 
 		memset(path, 0, PATH_MAX);
 		snprintf(path, PATH_MAX, "%s/%s/nodes/%d/weight",


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