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

[Cluster-devel] cluster/rgmanager ChangeLog src/daemons/groups ...



CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	lhh sourceware org	2007-07-02 15:13:43

Modified files:
	rgmanager      : ChangeLog 
	rgmanager/src/daemons: groups.c rg_state.c 

Log message:
	Fix #237144 - pass 2.  All testcases accounted for now.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/ChangeLog.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.31.2.17&r2=1.31.2.18
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/groups.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.25.2.7&r2=1.25.2.8
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/rg_state.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.24.2.9&r2=1.24.2.10

--- cluster/rgmanager/ChangeLog	2007/06/27 14:03:20	1.31.2.17
+++ cluster/rgmanager/ChangeLog	2007/07/02 15:13:42	1.31.2.18
@@ -1,3 +1,7 @@
+2007-06-29 Lon Hohberger <lhh at redhat.com>
+	* src/daemons/groups.c, rg_state.c: Make all test cases for #237144
+	work correctly
+
 2007-06-27 Lon Hohberger <lhh at redhat.com>
 	* include/resgroup.h: Make RG_STATUS_INQUIRY forwards-compatible
 	with -HEAD
--- cluster/rgmanager/src/daemons/groups.c	2007/06/26 21:55:46	1.25.2.7
+++ cluster/rgmanager/src/daemons/groups.c	2007/07/02 15:13:43	1.25.2.8
@@ -144,12 +144,46 @@
 }
 
 
+static inline int 
+is_exclusive_res(resource_t *res)
+{
+	char *val;
+
+	val = res_attr_value(res, "exclusive");
+	if (val && ((!strcmp(val, "yes") ||
+			(atoi(val)>0))) ) {
+		return 1;
+	}
+	return 0;
+}
+
+
+/* Locked exported function */
+int 
+is_exclusive(char *svcName)
+{
+	int ret = 0;
+	resource_t *res = NULL;
+
+	pthread_rwlock_rdlock(&resource_lock);
+	res = find_root_by_ref(&_resources, svcName);
+
+	if (!res)
+		ret = RG_ENOSERVICE;
+	else
+		ret = is_exclusive_res(res);
+
+	pthread_rwlock_unlock(&resource_lock);
+	return ret;
+}
+
+
 int
 count_resource_groups_local(cman_node_t *mp)
 {
 	resource_t *res;
 	resource_node_t *node;
-	char rgname[64], *val;
+	char rgname[64];
 	rg_state_t st;
 
 	mp->cn_svccount = 0;
@@ -176,11 +210,8 @@
 
 		++mp->cn_svccount;
 
-		val = res_attr_value(res, "exclusive");
-		if (val && ((!strcmp(val, "yes") ||
-				     (atoi(val)>0))) ) {
+		if (is_exclusive_res(res))
 			++mp->cn_svcexcl;
-		}
 
 	} while (!list_done(&_tree, node));
 
@@ -193,14 +224,11 @@
 have_exclusive_resources(void)
 {
 	resource_t *res;
-	char *val;
 
 	pthread_rwlock_rdlock(&resource_lock);
 
 	list_do(&_resources, res) {
-		val = res_attr_value(res, "exclusive");
-		if (val && ((!strcmp(val, "yes") ||
-						(atoi(val)>0))) ) {
+		if (is_exclusive_res(res)) {
 			pthread_rwlock_unlock(&resource_lock);
 			return 1;
 		}
@@ -217,9 +245,8 @@
 check_exclusive_resources(cluster_member_list_t *membership, char *svcName)
 {
 	cman_node_t *mp;
-	int exclusive, count; 
+	int exclusive, count, excl; 
 	resource_t *res;
-	char *val;
 
 	mp = memb_id_to_p(membership, my_id());
 	assert(mp);
@@ -230,14 +257,13 @@
 	res = find_root_by_ref(&_resources, svcName);
 	if (!res) {
 		pthread_rwlock_unlock(&resource_lock);
-		return RG_EFAIL;
+		return RG_ENOSERVICE;
 	}
-	val = res_attr_value(res, "exclusive");
+
+	excl = is_exclusive_res(res);
 	pthread_rwlock_unlock(&resource_lock);
-	if (exclusive || (count && val && 
-			(!strcmp(val, "yes") || (atoi(val)>0)))) {
+	if (exclusive || (count && excl))
 		return RG_YES;
-	}
 
 	return 0;
 }
--- cluster/rgmanager/src/daemons/rg_state.c	2007/06/26 21:55:46	1.24.2.9
+++ cluster/rgmanager/src/daemons/rg_state.c	2007/07/02 15:13:43	1.24.2.10
@@ -58,6 +58,7 @@
 static inline int handle_started_status(char *svcName, int ret, rg_state_t *svcStatus);
 static inline int handle_migrate_status(char *svcName, int ret, rg_state_t *svcStatus);
 int count_resource_groups_local(cman_node_t *mp);
+int is_exclusive(char *svcName);
 
 
 int 
@@ -842,13 +843,13 @@
 	}
 
 	count_resource_groups_local(m);
-	if (m->cn_svcexcl) {
+	if (m->cn_svcexcl ||
+	    (m->cn_svccount && is_exclusive(svcName))) {
 		free_member_list(membership);
 		return RG_EDEPEND;
 	}
 	free_member_list(membership);
 
-
 	if (rg_lock(svcName, &lockp) < 0) {
 		clulog(LOG_ERR, "#45: Unable to obtain cluster lock: %s\n",
 		       strerror(errno));
@@ -1503,12 +1504,32 @@
 handle_relocate_req(char *svcName, int request, int preferred_target,
 		    int *new_owner)
 {
-	cluster_member_list_t *allowed_nodes, *backup = NULL;
+	cluster_member_list_t *allowed_nodes = NULL, *backup = NULL;
 	cman_node_t *m;
 	int target = preferred_target, me = my_id();
 	int ret, x;
 	rg_state_t svcStatus;
 	
+	if (preferred_target > 0) {
+		/* TODO: simplify this and don't keep alloc/freeing 
+		   member lists */
+		allowed_nodes = member_list();
+		/* Avoid even bothering the other node if we can */
+		m = memb_id_to_p(allowed_nodes, preferred_target);
+		if (!m) {
+			free_member_list(allowed_nodes);
+			return RG_EINVAL;
+		}
+
+		count_resource_groups_local(m);
+		if (m->cn_svcexcl ||
+	    	    (m->cn_svccount && is_exclusive(svcName))) {
+			free_member_list(allowed_nodes);
+			return RG_EDEPEND;
+		}
+		free_member_list(allowed_nodes);
+	}
+
 	/*
 	 * Stop the service - if we haven't already done so.
 	 */
@@ -1525,19 +1546,6 @@
 	if (preferred_target > 0) {
 
 		allowed_nodes = member_list();
-		m = memb_id_to_p(allowed_nodes, preferred_target);
-		if (!m) {
-			free_member_list(allowed_nodes);
-			return RG_EINVAL;
-		}
-
-		/* Avoid even bothering the other node if we can */
-		count_resource_groups_local(m);
-		if (m->cn_svcexcl) {
-			free_member_list(allowed_nodes);
-			return RG_EDEPEND;
-		}
-
 		/*
 	   	   Mark everyone except me and the preferred target DOWN for now
 		   If we can't start it on the preferred target, then we'll try


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