All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cluster-devel] cluster/rgmanager ChangeLog src/daemons/groups ...
@ 2007-07-02 15:15 lhh
  0 siblings, 0 replies; 9+ messages in thread
From: lhh @ 2007-07-02 15:15 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	lhh at sourceware.org	2007-07-02 15:15:00

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&r1=1.49&r2=1.50
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/groups.c.diff?cvsroot=cluster&r1=1.34&r2=1.35
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/rg_state.c.diff?cvsroot=cluster&r1=1.36&r2=1.37

--- cluster/rgmanager/ChangeLog	2007/06/27 14:03:51	1.49
+++ cluster/rgmanager/ChangeLog	2007/07/02 15:15:00	1.50
@@ -1,3 +1,7 @@
+2007-06-29 Lon Hohberger <lhh@redhat.com>
+	* src/daemons/groups.c, rg_state.c: Make all test cases for #237144
+	work correctly
+
 2007-06-27 Lon Hohberger <lhh@redhat.com>
 	* Merge from RHEL5 branch.
 	* src/daemons/vm.sh: Un-break migrate (#231692).  Make status
--- cluster/rgmanager/src/daemons/groups.c	2007/06/27 14:03:51	1.34
+++ cluster/rgmanager/src/daemons/groups.c	2007/07/02 15:15:00	1.35
@@ -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/27 14:03:51	1.36
+++ cluster/rgmanager/src/daemons/rg_state.c	2007/07/02 15:15:00	1.37
@@ -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 
@@ -859,13 +860,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));
@@ -1608,12 +1609,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.
 	 */
@@ -1633,19 +1654,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



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Cluster-devel] cluster/rgmanager ChangeLog src/daemons/groups ...
@ 2007-12-12 21:41 lhh
  0 siblings, 0 replies; 9+ messages in thread
From: lhh @ 2007-12-12 21:41 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	lhh at sourceware.org	2007-12-12 21:41:32

Modified files:
	rgmanager      : ChangeLog 
	rgmanager/src/daemons: groups.c slang_event.c 
	rgmanager/src/resources: default_event_script.sl 

Log message:
	Misc. minor central processing bugfixes

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/ChangeLog.diff?cvsroot=cluster&r1=1.63&r2=1.64
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/groups.c.diff?cvsroot=cluster&r1=1.41&r2=1.42
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/slang_event.c.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/default_event_script.sl.diff?cvsroot=cluster&r1=1.1&r2=1.2

--- cluster/rgmanager/ChangeLog	2007/12/12 15:27:34	1.63
+++ cluster/rgmanager/ChangeLog	2007/12/12 21:41:32	1.64
@@ -1,5 +1,12 @@
 2007-12-12 Lon Hohberger <lhh@redhat.com>
 	* Misc changes; add missing ds.h
+	* src/resources/default*.sl: Make clusvcadm -r go to a different
+	node.  Don't notice() that we're starting a service if it's
+	disabled.
+	* src/daemons/groups.c: Make clustat not interfere with startup
+	when central processing is enabled
+	* src/daemons/slang_event.c: Make clusvcadm correctly report
+	service owner after relocate/restart/enable requests.
 
 2007-11-30 Lon Hohberger <lhh@redhat.com>
 	* Commit RIND / S-Lang script engine [untested]
--- cluster/rgmanager/src/daemons/groups.c	2007/11/30 21:36:28	1.41
+++ cluster/rgmanager/src/daemons/groups.c	2007/12/12 21:41:32	1.42
@@ -1126,48 +1126,6 @@
 }
 
 
-#if 0
-/**
-  Send the state of the transition master to a given file descriptor.
-
-  @param fd		File descriptor to send state to
-  @param rgname		Resource group name whose state we want to send.
-  @see send_rg_states
- */
-void
-send_master_state(msgctx_t *ctx)
-{
-	rg_state_msg_t msg, *msgp = &msg;
-	event_master_t master;
-	rg_state_t *rs = &msg.rsm_state;
-
-	strncpy(rs->rs_name, "internal:CentralProcessor",
-		sizeof(rs->rs_name));
-	rs->rs_last_owner = 0;
-	rs->rs_restarts = 0;
-
-	if (event_master_info_cached(&master) < 0) {
-		rs->rs_owner = 0;
-		rs->rs_transition = master.m_master_time;
-		rs->rs_state = RG_STATE_UNINITIALIZED;
-	} else {
-		rs->rs_owner = master.m_nodeid;
-		rs->rs_transition = master.m_master_time;
-		rs->rs_state = RG_STATE_STARTED;
-	}
-
-	msgp->rsm_hdr.gh_magic = GENERIC_HDR_MAGIC;
-	msgp->rsm_hdr.gh_length = sizeof(msg);
-	msgp->rsm_hdr.gh_command = RG_STATUS;
-
-	swab_rg_state_msg_t(msgp);
-
-	if (msg_send(ctx, msgp, sizeof(msg)) < 0)
-		perror("msg_send");
-}
-#endif
-
-
 /**
   Send status from a thread because we don't want rgmanager's
   main thread to block in the case of DLM issues
@@ -1183,6 +1141,14 @@
 
 	free(arg);
 
+	if (central_events_enabled()) {
+		/* Never call get_rg_state() (distributed) if 
+		   central events are enabled, otherwise we
+		   might overwrite the rg state with 'stopped' 
+		   when it should be 'disabled' (e.g. autostart="0") */
+		fast = 1;
+	}
+
 	/* See if we have a slot... */
 	if (rg_inc_status() < 0) {
 		/* Too many outstanding status checks.  try again later. */
@@ -1327,6 +1293,7 @@
 	resource_node_t *curr;
 	rg_state_t svcblk;
 	char rg[64];
+	struct dlm_lksb lockp;
 	
 	/* Only one status thread@a time, please! */
 	if (pthread_mutex_trylock(&status_mutex) != 0)
@@ -1340,7 +1307,13 @@
 
 		/* Local check - no one will make us take a service */
 		if (get_rg_state_local(rg, &svcblk) < 0) {
-			continue;
+			if (rg_lock(rg, &lockp) != 0)
+				continue;
+			if (get_rg_state(rg, &svcblk) < 0) {
+				rg_unlock(&lockp);
+				continue;
+			}
+			rg_unlock(&lockp);
 		}
 
 		if (svcblk.rs_owner != my_id() ||
--- cluster/rgmanager/src/daemons/slang_event.c	2007/12/07 00:53:44	1.2
+++ cluster/rgmanager/src/daemons/slang_event.c	2007/12/12 21:41:32	1.3
@@ -487,7 +487,7 @@
 	char *svcname = NULL;
 	int *pref_list = NULL, pref_list_len = 0;
 	int *illegal_list = NULL, illegal_list_len = 0;
-	int nargs, t, x, ret = -1;
+	int nargs, t, newowner = 0, ret = -1;
 
 	nargs = SLang_Num_Function_Args;
 
@@ -528,8 +528,10 @@
 
 	/* TODO: Meat of function goes here */
 	ret = service_op_start(svcname, pref_list,
-			       pref_list_len, &x); ;
+			       pref_list_len, &newowner);
 
+	if (ret == 0 && newowner > 0)
+		ret = newowner;
 out:
 	if (svcname)
 		free(svcname);
@@ -1123,7 +1125,17 @@
 	/* XXX Send response code to caller - that 0 should be the
 	   new service owner, if there is one  */
 	if (ctx) {
-		send_ret(ctx, name, _user_return, request, 0);
+		if (_user_return > 0) {
+			/* sl_start_service() squashes return code and
+			   node ID into one value.  <0 = error, >0 =
+			   success, return-value == node id running
+			   service */
+			send_ret(ctx, name, 0, request, _user_return);
+		} else {
+			/* return value < 0 ... pass directly back;
+			   don't transpose */
+			send_ret(ctx, name, _user_return, request, 0);
+		}
 		msg_close(ctx);
 		msg_free_ctx(ctx);
 	}
--- cluster/rgmanager/src/resources/default_event_script.sl	2007/11/30 21:36:29	1.1
+++ cluster/rgmanager/src/resources/default_event_script.sl	2007/12/12 21:41:32	1.2
@@ -192,7 +192,8 @@
 		}
 
 		(owner, state) = service_status(services[x]);
-		if ((service_state == "started") and (owner < 0)) {
+		if ((service_state == "started") and (owner < 0) and
+		    (state == "stopped")) {
 			info("Dependency met; starting ", services[x]);
 			nodes = allowed_nodes(services[x]);
 			()=move_or_start(services[x], nodes);
@@ -245,6 +246,10 @@
 
 		if (user_target > 0) {
 			for (x = 0; x < length(nodes); x++) {
+				%
+				% Put the preferred node@the front of the 
+				% list for a user-relocate operation
+				%
 				if (nodes[x] == user_target) {
 					reordered = union(user_target, nodes);
 					nodes = reordered;
@@ -262,6 +267,13 @@
 			if (service_stop(service_name) < 0) {
 				return ERR_ABORT;
 			}
+
+			%
+			% The current owner shouldn't be the default
+			% for a relocate operation
+			%
+			reordered = subtract(nodes, owner);
+			nodes = union(reordered, owner);
 		}
 
 		ret = move_or_start(service_name, nodes);
@@ -275,7 +287,10 @@
 		ret = service_stop(service_name);
 
 	} 
+
+	%
 	% todo - migrate
+	%
 
 	return ret;
 }



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Cluster-devel] cluster/rgmanager ChangeLog src/daemons/groups ...
@ 2007-09-28 15:14 lhh
  0 siblings, 0 replies; 9+ messages in thread
From: lhh @ 2007-09-28 15:14 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL4
Changes by:	lhh at sourceware.org	2007-09-28 15:14:52

Modified files:
	rgmanager      : ChangeLog 
	rgmanager/src/daemons: groups.c resrules.c restree.c 

Log message:
	Fix #310981 - status check timers wrong

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/ChangeLog.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.5.2.31&r2=1.5.2.32
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/groups.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.8.2.20&r2=1.8.2.21
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/resrules.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.9.2.7&r2=1.9.2.8
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/restree.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.10.2.16&r2=1.10.2.17

--- cluster/rgmanager/ChangeLog	2007/09/25 14:00:41	1.5.2.31
+++ cluster/rgmanager/ChangeLog	2007/09/28 15:14:52	1.5.2.32
@@ -1,3 +1,7 @@
+2007-10-28 Lon hohberger <lhh@redhat.com>
+	* include/reslist.h, src/daemons/resgroup.c, restree.c:
+	Fix #310981
+
 2007-10-25 Lon Hohberger <lhh@redhat.com>
 	* src/resources/clusterfs.sh: Make self_fence work. #252241
 	* src/resources/SAPInstance, SAPDatabase, Makefile: Add 
--- cluster/rgmanager/src/daemons/groups.c	2007/07/31 18:26:39	1.8.2.20
+++ cluster/rgmanager/src/daemons/groups.c	2007/09/28 15:14:52	1.8.2.21
@@ -133,6 +133,40 @@
 }
 
 
+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 get_rg_state_local(char *, rg_state_t *);
 int
 count_resource_groups_local(cluster_member_t *mp)
@@ -147,6 +181,7 @@
 	pthread_rwlock_rdlock(&resource_lock);
 
 	list_do(&_resources, res) {
+
 		if (res->r_rule->rr_root == 0)
 			continue;
 
@@ -165,11 +200,8 @@
 
 		++mp->cm_svccount;
 
-		val = res_attr_value(res, "exclusive");
-		if (val && ((!strcmp(val, "yes") ||
-				     (atoi(val)>0))) ) {
+		if (is_exclusive_res(res)) 
 			++mp->cm_svcexcl;
-		}
 
 	} while (!list_done(&_resources, res));
 
@@ -180,21 +212,17 @@
 
 
 int
-have_exclusive_resources()
+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;
 		}
-
 	} while (!list_done(&_resources, res));
 
 	pthread_rwlock_unlock(&resource_lock);
--- cluster/rgmanager/src/daemons/resrules.c	2007/03/20 19:40:06	1.9.2.7
+++ cluster/rgmanager/src/daemons/resrules.c	2007/09/28 15:14:52	1.9.2.8
@@ -298,6 +298,7 @@
 		acts[0].ra_depth = depth;
 		acts[0].ra_timeout = timeout;
 		acts[0].ra_interval = interval;
+		acts[0].ra_last = 0;
 		acts[1].ra_name = NULL;
 
 		*actsp = acts;
@@ -342,6 +343,7 @@
 	acts[x].ra_depth = depth;
 	acts[x].ra_timeout = timeout;
 	acts[x].ra_interval = interval;
+	acts[x].ra_last = 0;
 
 	acts[x+1].ra_name = NULL;
 
--- cluster/rgmanager/src/daemons/restree.c	2007/05/02 22:54:28	1.10.2.16
+++ cluster/rgmanager/src/daemons/restree.c	2007/09/28 15:14:52	1.10.2.17
@@ -1053,35 +1053,51 @@
 
 	now = time(NULL);
 
-       for (; node->rn_actions[x].ra_name; x++) {
+	for (; node->rn_actions[x].ra_name; x++) {
 		if (!has_recover &&
-                   !strcmp(node->rn_actions[x].ra_name, "recover")) {
+		    !strcmp(node->rn_actions[x].ra_name, "recover")) {
 			has_recover = 1;
 			continue;
 		}
 
-               if (strcmp(node->rn_actions[x].ra_name, "status"))
+		if (strcmp(node->rn_actions[x].ra_name, "status"))
 			continue;
 
-               delta = now - node->rn_actions[x].ra_last;
+		delta = now - node->rn_actions[x].ra_last;
+
+		/*
+		printf("%s:%s %s level %d interval = %d  elapsed = %d\n",
+			node->rn_resource->r_rule->rr_type,
+			node->rn_resource->r_attrs->ra_value,
+			node->rn_actions[x].ra_name, node->rn_actions[x].ra_depth,
+			(int)node->rn_actions[x].ra_interval, (int)delta);
+		 */
 
-		/* Ok, it's a 'monitor' action. See if enough time has
-		   elapsed for a given type of monitoring action */
-               if (delta < node->rn_actions[x].ra_interval)
+		/* Ok, it's a 'status' action. See if enough time has
+		   elapsed for a given type of status action */
+		if (delta < node->rn_actions[x].ra_interval)
 			continue;
 
 		if (idx == -1 ||
-                   node->rn_actions[x].ra_depth > node->rn_actions[idx].ra_depth)
+		    node->rn_actions[x].ra_depth > node->rn_actions[idx].ra_depth)
 			idx = x;
 	}
 
 	/* No check levels ready at the moment. */
-	if (idx == -1)
+	if (idx == -1) {
+		if (node->rn_checked)
+			return node->rn_last_status;
 		return 0;
+	}
+
+	node->rn_actions[idx].ra_last = now;
+	x = res_exec(node, RS_STATUS, node->rn_actions[idx].ra_depth);
 
-       node->rn_actions[idx].ra_last = now;
-	if ((x = res_exec(node, RS_STATUS,
-                         node->rn_actions[idx].ra_depth)) == 0)
+	node->rn_last_status = x;
+	node->rn_last_depth = node->rn_actions[idx].ra_depth;
+	node->rn_checked = 1;
+
+	if (x == 0)
 		return 0;
 
 	if (!has_recover)
@@ -1138,18 +1154,21 @@
 {
 	time_t now;
 	int x = 0;
-	resource_t *res = node->rn_resource;
 
-	now = res->r_started;
+	now = time(NULL);
 
-       for (; node->rn_actions[x].ra_name; x++) {
+	for (; node->rn_actions[x].ra_name; x++) {
 
-               if (strcmp(node->rn_actions[x].ra_name, "monitor") &&
-                   strcmp(node->rn_actions[x].ra_name, "status"))
+		if (strcmp(node->rn_actions[x].ra_name, "monitor") &&
+		    strcmp(node->rn_actions[x].ra_name, "status"))
 			continue;
 
-               node->rn_actions[x].ra_last = now;
+		node->rn_actions[x].ra_last = now;
 	}
+
+	node->rn_checked = 0;
+	node->rn_last_status = 0;
+	node->rn_last_depth = 0;
 }
 
 



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Cluster-devel] cluster/rgmanager ChangeLog src/daemons/groups ...
@ 2007-07-31 18:26 lhh
  0 siblings, 0 replies; 9+ messages in thread
From: lhh @ 2007-07-31 18:26 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL4
Changes by:	lhh at sourceware.org	2007-07-31 18:26:39

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

Log message:
	Fix #246669

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/ChangeLog.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.5.2.28&r2=1.5.2.29
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/groups.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.8.2.19&r2=1.8.2.20
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/rg_thread.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.7.2.9&r2=1.7.2.10

--- cluster/rgmanager/ChangeLog	2007/06/28 12:04:02	1.5.2.28
+++ cluster/rgmanager/ChangeLog	2007/07/31 18:26:39	1.5.2.29
@@ -1,3 +1,7 @@
+2007-07-31 Lon Hohberger <lhh@redhat.com>
+	* src/daemons/groups.c, rg_thread.c: Fix #246669 - status check unbounded
+	but should be 1
+
 2007-06-28 Marek Grac <mgrac@redhat.com>
 	* src/resources/named.sh, named.metadata: Add resource agent
 	for named (fix #213524)
--- cluster/rgmanager/src/daemons/groups.c	2007/05/03 15:02:47	1.8.2.19
+++ cluster/rgmanager/src/daemons/groups.c	2007/07/31 18:26:39	1.8.2.20
@@ -877,7 +877,7 @@
 			continue;
 
 		rt_enqueue_request(name, RG_STATUS,
-				   -1, 0, NODE_ID_NONE, 0, 0);
+				   -1, 1, NODE_ID_NONE, 0, 0);
 
 	} while (!list_done(&_tree, curr));
 
--- cluster/rgmanager/src/daemons/rg_thread.c	2007/01/04 15:52:41	1.7.2.9
+++ cluster/rgmanager/src/daemons/rg_thread.c	2007/07/31 18:26:39	1.7.2.10
@@ -598,7 +598,6 @@
 			} while (!list_done(resgroup->rt_queue, curr));
 	
 			if (count >= max) {
-				pthread_cond_broadcast(resgroup->rt_queue_cond);
 				pthread_mutex_unlock(resgroup->rt_queue_mutex);
 				pthread_mutex_unlock(&reslist_mutex);
 				/*



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Cluster-devel] cluster/rgmanager ChangeLog src/daemons/groups ...
@ 2007-07-10 18:25 lhh
  0 siblings, 0 replies; 9+ messages in thread
From: lhh @ 2007-07-10 18:25 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	lhh at sourceware.org	2007-07-10 18:25:27

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

Log message:
	Resolves: 247488

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/ChangeLog.diff?cvsroot=cluster&r1=1.50&r2=1.51
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/groups.c.diff?cvsroot=cluster&r1=1.35&r2=1.36
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/rg_thread.c.diff?cvsroot=cluster&r1=1.22&r2=1.23

--- cluster/rgmanager/ChangeLog	2007/07/02 15:15:00	1.50
+++ cluster/rgmanager/ChangeLog	2007/07/10 18:25:26	1.51
@@ -1,3 +1,7 @@
+2007-07-10 Lon Hohberger <lhh@redhat.com>
+	* src/daemons/rg_thread.c, groups.c: Make status queue max 1 instead
+	of unbounded (resolves: 247488)
+
 2007-06-29 Lon Hohberger <lhh@redhat.com>
 	* src/daemons/groups.c, rg_state.c: Make all test cases for #237144
 	work correctly
--- cluster/rgmanager/src/daemons/groups.c	2007/07/02 15:15:00	1.35
+++ cluster/rgmanager/src/daemons/groups.c	2007/07/10 18:25:26	1.36
@@ -1191,7 +1191,7 @@
 			continue;
 
 		rt_enqueue_request(rg, RG_STATUS,
-				   NULL, 0, 0, 0, 0);
+				   NULL, 1, 0, 0, 0);
 
 	} while (!list_done(&_tree, curr));
 
--- cluster/rgmanager/src/daemons/rg_thread.c	2007/06/27 14:03:51	1.22
+++ cluster/rgmanager/src/daemons/rg_thread.c	2007/07/10 18:25:26	1.23
@@ -670,7 +670,6 @@
 			} while (!list_done(resgroup->rt_queue, curr));
 	
 			if (count >= max) {
-				pthread_cond_broadcast(resgroup->rt_queue_cond);
 				pthread_mutex_unlock(resgroup->rt_queue_mutex);
 				pthread_mutex_unlock(&reslist_mutex);
 				/*



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Cluster-devel] cluster/rgmanager ChangeLog src/daemons/groups ...
@ 2007-07-10 18:24 lhh
  0 siblings, 0 replies; 9+ messages in thread
From: lhh @ 2007-07-10 18:24 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	lhh at sourceware.org	2007-07-10 18:24:00

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

Log message:
	Resolves: 247488

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/ChangeLog.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.31.2.18&r2=1.31.2.19
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/groups.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.25.2.8&r2=1.25.2.9
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/rg_thread.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.15.2.6&r2=1.15.2.7

--- cluster/rgmanager/ChangeLog	2007/07/02 15:13:42	1.31.2.18
+++ cluster/rgmanager/ChangeLog	2007/07/10 18:24:00	1.31.2.19
@@ -1,3 +1,7 @@
+2007-07-10 Lon Hohberger <lhh@redhat.com>
+	* src/daemons/rg_thread.c, groups.c: Make status queue max 1 instead
+	of unbounded (resolves: 247488)
+
 2007-06-29 Lon Hohberger <lhh@redhat.com>
 	* src/daemons/groups.c, rg_state.c: Make all test cases for #237144
 	work correctly
--- cluster/rgmanager/src/daemons/groups.c	2007/07/02 15:13:43	1.25.2.8
+++ cluster/rgmanager/src/daemons/groups.c	2007/07/10 18:24:00	1.25.2.9
@@ -1188,7 +1188,7 @@
 			continue;
 
 		rt_enqueue_request(rg, RG_STATUS,
-				   NULL, 0, 0, 0, 0);
+				   NULL, 1, 0, 0, 0);
 
 	} while (!list_done(&_tree, curr));
 
--- cluster/rgmanager/src/daemons/rg_thread.c	2007/06/26 21:55:46	1.15.2.6
+++ cluster/rgmanager/src/daemons/rg_thread.c	2007/07/10 18:24:00	1.15.2.7
@@ -658,7 +658,6 @@
 			} while (!list_done(resgroup->rt_queue, curr));
 	
 			if (count >= max) {
-				pthread_cond_broadcast(resgroup->rt_queue_cond);
 				pthread_mutex_unlock(resgroup->rt_queue_mutex);
 				pthread_mutex_unlock(&reslist_mutex);
 				/*



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Cluster-devel] cluster/rgmanager ChangeLog src/daemons/groups ...
@ 2007-07-02 15:13 lhh
  0 siblings, 0 replies; 9+ messages in thread
From: lhh @ 2007-07-02 15:13 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	lhh at 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@redhat.com>
+	* src/daemons/groups.c, rg_state.c: Make all test cases for #237144
+	work correctly
+
 2007-06-27 Lon Hohberger <lhh@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



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Cluster-devel] cluster/rgmanager ChangeLog src/daemons/groups ...
@ 2007-04-19 18:05 lhh
  0 siblings, 0 replies; 9+ messages in thread
From: lhh @ 2007-04-19 18:05 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	lhh at sourceware.org	2007-04-19 19:05:37

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

Log message:
	Apply patch from Andrey Mirkin to fix 237144

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/ChangeLog.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.31.2.1&r2=1.31.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/groups.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.25.2.3&r2=1.25.2.4
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.5&r2=1.24.2.6

--- cluster/rgmanager/ChangeLog	2007/04/12 17:23:05	1.31.2.1
+++ cluster/rgmanager/ChangeLog	2007/04/19 18:05:36	1.31.2.2
@@ -1,3 +1,9 @@
+2007-04-19 Lon Hohberger <lhh@redhat.com>
+	* src/daemons/groups.c, rg_state.c: Apply patch from Andrey
+	Mirkin to fix bug #237144; prevents exclusive services from
+	being accidentally (or intentionally) being started on the
+	same node
+
 2007-04-12 Lon Hohberger <lhh@redhat.com>
 	* src/daemons/main.c: Fix watchdog race condition causing
 	reboot; patch from Andrey Mirkin; bugzilla #236204
--- cluster/rgmanager/src/daemons/groups.c	2007/03/20 17:09:11	1.25.2.3
+++ cluster/rgmanager/src/daemons/groups.c	2007/04/19 18:05:37	1.25.2.4
@@ -20,6 +20,7 @@
 //#define DEBUG
 #include <platform.h>
 #include <resgroup.h>
+#include <reslist.h>
 #include <vf.h>
 #include <message.h>
 #include <ccs.h>
@@ -138,6 +139,105 @@
 }
 
 
+int
+count_resource_groups_local(cman_node_t *mp)
+{
+	resource_t *res;
+	resource_node_t *node;
+	char rgname[64], *val;
+	rg_state_t st;
+
+	mp->cn_svccount = 0;
+	mp->cn_svcexcl = 0;
+
+	pthread_rwlock_rdlock(&resource_lock);
+
+	list_do(&_tree, node) {
+
+		res = node->rn_resource;
+
+		res_build_name(rgname, sizeof(rgname), res);
+
+		if (get_rg_state_local(rgname, &st) < 0) {
+			continue;
+		}
+
+		if (st.rs_state != RG_STATE_STARTED &&
+		     st.rs_state != RG_STATE_STARTING)
+			continue;
+
+		if (mp->cn_nodeid != st.rs_owner)
+			continue;
+
+		++mp->cn_svccount;
+
+		val = res_attr_value(res, "exclusive");
+		if (val && ((!strcmp(val, "yes") ||
+				     (atoi(val)>0))) ) {
+			++mp->cn_svcexcl;
+		}
+
+	} while (!list_done(&_tree, node));
+
+	pthread_rwlock_unlock(&resource_lock);
+	return 0;
+}
+
+
+int
+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))) ) {
+			pthread_rwlock_unlock(&resource_lock);
+			return 1;
+		}
+
+	} while (!list_done(&_resources, res));
+
+	pthread_rwlock_unlock(&resource_lock);
+
+	return 0;
+}
+
+
+int
+check_exclusive_resources(cluster_member_list_t *membership, char *svcName)
+{
+	cman_node_t *mp;
+	int exclusive, count; 
+	resource_t *res;
+	char *val;
+
+	mp = memb_id_to_p(membership, my_id());
+	assert(mp);
+	count_resource_groups_local(mp);
+	exclusive = mp->cn_svcexcl;
+	count = mp->cn_svccount;
+	pthread_rwlock_rdlock(&resource_lock);
+	res = find_root_by_ref(&_resources, svcName);
+	if (!res) {
+		pthread_rwlock_unlock(&resource_lock);
+		return RG_EFAIL;
+	}
+	val = res_attr_value(res, "exclusive");
+	pthread_rwlock_unlock(&resource_lock);
+	if (exclusive || (count && val && 
+			(!strcmp(val, "yes") || (atoi(val)>0)))) {
+		return RG_YES;
+	}
+
+	return 0;
+}
+
+
 /**
    Find the best target node for a service *besides* the current service
    owner.  Takes into account:
--- cluster/rgmanager/src/daemons/rg_state.c	2007/03/20 17:09:11	1.24.2.5
+++ cluster/rgmanager/src/daemons/rg_state.c	2007/04/19 18:05:37	1.24.2.6
@@ -48,6 +48,8 @@
 void get_recovery_policy(char *rg_name, char *buf, size_t buflen);
 int check_depend_safe(char *servicename);
 int group_migratory(char *servicename, int lock);
+int have_exclusive_resources(void);
+int check_exclusive_resources(cluster_member_list_t *membership, char *svcName);
 
 
 int 
@@ -687,6 +689,10 @@
 			ret = 1;
 			break;
 		}
+		if (req == RG_START_RECOVER) {
+			ret = 1;
+			break;
+		}
 
 		clulog(LOG_DEBUG, "Not starting disabled RG %s\n",
 		       svcName);
@@ -1463,6 +1469,7 @@
 }
 
 
+pthread_mutex_t exclusive_mutex = PTHREAD_MUTEX_INITIALIZER;
 /**
  * handle_start_req - Handle a generic start request from a user or during
  * service manager boot.
@@ -1478,6 +1485,7 @@
 {
 	int ret, tolerance = FOD_BEST;
 	cluster_member_list_t *membership = member_list();
+	int need_check = have_exclusive_resources();
 
 	/*
 	 * When a service request is from a user application (eg, clusvcadm),
@@ -1493,6 +1501,18 @@
 		free_member_list(membership);
 		return RG_EFAIL;
 	}
+	if (need_check) {
+		pthread_mutex_lock(&exclusive_mutex);
+		ret = check_exclusive_resources(membership, svcName);
+		if (ret != 0) {
+			free_member_list(membership);
+			pthread_mutex_unlock(&exclusive_mutex);
+			if (ret > 0)
+				goto relocate;
+			else
+				return RG_EFAIL;
+		}
+	}
 	free_member_list(membership);
 
 	/* Check for dependency.  We cannot start unless our
@@ -1505,6 +1525,8 @@
 	 * mask here - so that we can try all nodes if necessary.
 	 */
 	ret = svc_start(svcName, req);
+	if (need_check)
+		pthread_mutex_unlock(&exclusive_mutex);
 
 	/* 
 	   If services are locked, return the error 
@@ -1544,6 +1566,7 @@
 		return RG_EABORT;
 	}
 	
+relocate:
 	/*
 	 * OK, it failed to start - but succeeded to stop.  Now,
 	 * we should relocate the service.
@@ -1581,6 +1604,7 @@
 	int x;
 	uint32_t me = my_id();
 	cluster_member_list_t *membership = member_list();
+	int need_check = have_exclusive_resources();
 
 	/* XXX ok, so we need to say "should I start this if I was the
 	   only cluster member online */
@@ -1601,10 +1625,23 @@
 		free_member_list(membership);
 		return RG_EFAIL;
 	}
+	if (need_check) {
+		pthread_mutex_lock(&exclusive_mutex);
+		if (check_exclusive_resources(membership, svcName) != 0) {
+			free_member_list(membership);
+			pthread_mutex_unlock(&exclusive_mutex);
+			return RG_EFAIL;
+		}
+	}
 	free_member_list(membership);
 
-	if (svc_start(svcName, req) == 0)
+	if (svc_start(svcName, req) == 0) {
+		if (need_check)
+			pthread_mutex_unlock(&exclusive_mutex);
 		return 0;
+	}
+	if (need_check)
+		pthread_mutex_unlock(&exclusive_mutex);
 
 	if (svc_stop(svcName, RG_STOP_RECOVER) == 0)
 		return RG_EFAIL;



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Cluster-devel] cluster/rgmanager ChangeLog src/daemons/groups ...
@ 2007-04-19 17:59 lhh
  0 siblings, 0 replies; 9+ messages in thread
From: lhh @ 2007-04-19 17:59 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	lhh at sourceware.org	2007-04-19 18:59:36

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

Log message:
	Apply patch from Andrey Mirkin to fix 237144

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/ChangeLog.diff?cvsroot=cluster&r1=1.33&r2=1.34
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/groups.c.diff?cvsroot=cluster&r1=1.30&r2=1.31
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/rg_state.c.diff?cvsroot=cluster&r1=1.30&r2=1.31

--- cluster/rgmanager/ChangeLog	2007/04/12 17:25:48	1.33
+++ cluster/rgmanager/ChangeLog	2007/04/19 17:59:36	1.34
@@ -1,3 +1,9 @@
+2007-04-19 Lon Hohberger <lhh@redhat.com>
+	* src/daemons/groups.c, rg_state.c: Apply patch from Andrey
+	Mirkin to fix bug #237144; prevents exclusive services from
+	being accidentally (or intentionally) being started on the
+	same node
+
 2007-04-12 Lon Hohberger <lhh@redhat.com>
 	* src/daemons/main.c: Fix watchdog race condition causing
 	reboot; patch from Andrey Mirkin; bugzilla #236204
--- cluster/rgmanager/src/daemons/groups.c	2007/03/27 19:33:20	1.30
+++ cluster/rgmanager/src/daemons/groups.c	2007/04/19 17:59:36	1.31
@@ -20,6 +20,7 @@
 //#define DEBUG
 #include <platform.h>
 #include <resgroup.h>
+#include <reslist.h>
 #include <vf.h>
 #include <message.h>
 #include <ccs.h>
@@ -143,6 +144,105 @@
 }
 
 
+int
+count_resource_groups_local(cman_node_t *mp)
+{
+	resource_t *res;
+	resource_node_t *node;
+	char rgname[64], *val;
+	rg_state_t st;
+
+	mp->cn_svccount = 0;
+	mp->cn_svcexcl = 0;
+
+	pthread_rwlock_rdlock(&resource_lock);
+
+	list_do(&_tree, node) {
+
+		res = node->rn_resource;
+
+		res_build_name(rgname, sizeof(rgname), res);
+
+		if (get_rg_state_local(rgname, &st) < 0) {
+			continue;
+		}
+
+		if (st.rs_state != RG_STATE_STARTED &&
+		     st.rs_state != RG_STATE_STARTING)
+			continue;
+
+		if (mp->cn_nodeid != st.rs_owner)
+			continue;
+
+		++mp->cn_svccount;
+
+		val = res_attr_value(res, "exclusive");
+		if (val && ((!strcmp(val, "yes") ||
+				     (atoi(val)>0))) ) {
+			++mp->cn_svcexcl;
+		}
+
+	} while (!list_done(&_tree, node));
+
+	pthread_rwlock_unlock(&resource_lock);
+	return 0;
+}
+
+
+int
+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))) ) {
+			pthread_rwlock_unlock(&resource_lock);
+			return 1;
+		}
+
+	} while (!list_done(&_resources, res));
+
+	pthread_rwlock_unlock(&resource_lock);
+
+	return 0;
+}
+
+
+int
+check_exclusive_resources(cluster_member_list_t *membership, char *svcName)
+{
+	cman_node_t *mp;
+	int exclusive, count; 
+	resource_t *res;
+	char *val;
+
+	mp = memb_id_to_p(membership, my_id());
+	assert(mp);
+	count_resource_groups_local(mp);
+	exclusive = mp->cn_svcexcl;
+	count = mp->cn_svccount;
+	pthread_rwlock_rdlock(&resource_lock);
+	res = find_root_by_ref(&_resources, svcName);
+	if (!res) {
+		pthread_rwlock_unlock(&resource_lock);
+		return RG_EFAIL;
+	}
+	val = res_attr_value(res, "exclusive");
+	pthread_rwlock_unlock(&resource_lock);
+	if (exclusive || (count && val && 
+			(!strcmp(val, "yes") || (atoi(val)>0)))) {
+		return RG_YES;
+	}
+
+	return 0;
+}
+
+
 /**
    Find the best target node for a service *besides* the current service
    owner.  Takes into account:
--- cluster/rgmanager/src/daemons/rg_state.c	2007/03/20 17:09:57	1.30
+++ cluster/rgmanager/src/daemons/rg_state.c	2007/04/19 17:59:36	1.31
@@ -48,6 +48,8 @@
 void get_recovery_policy(char *rg_name, char *buf, size_t buflen);
 int check_depend_safe(char *servicename);
 int group_migratory(char *servicename, int lock);
+int have_exclusive_resources(void);
+int check_exclusive_resources(cluster_member_list_t *membership, char *svcName);
 
 
 int 
@@ -687,6 +689,10 @@
 			ret = 1;
 			break;
 		}
+		if (req == RG_START_RECOVER) {
+			ret = 1;
+			break;
+		}
 
 		clulog(LOG_DEBUG, "Not starting disabled RG %s\n",
 		       svcName);
@@ -1463,6 +1469,7 @@
 }
 
 
+pthread_mutex_t exclusive_mutex = PTHREAD_MUTEX_INITIALIZER;
 /**
  * handle_start_req - Handle a generic start request from a user or during
  * service manager boot.
@@ -1478,6 +1485,7 @@
 {
 	int ret, tolerance = FOD_BEST;
 	cluster_member_list_t *membership = member_list();
+	int need_check = have_exclusive_resources();
 
 	/*
 	 * When a service request is from a user application (eg, clusvcadm),
@@ -1493,6 +1501,18 @@
 		free_member_list(membership);
 		return RG_EFAIL;
 	}
+	if (need_check) {
+		pthread_mutex_lock(&exclusive_mutex);
+		ret = check_exclusive_resources(membership, svcName);
+		if (ret != 0) {
+			free_member_list(membership);
+			pthread_mutex_unlock(&exclusive_mutex);
+			if (ret > 0)
+				goto relocate;
+			else
+				return RG_EFAIL;
+		}
+	}
 	free_member_list(membership);
 
 	/* Check for dependency.  We cannot start unless our
@@ -1505,6 +1525,8 @@
 	 * mask here - so that we can try all nodes if necessary.
 	 */
 	ret = svc_start(svcName, req);
+	if (need_check)
+		pthread_mutex_unlock(&exclusive_mutex);
 
 	/* 
 	   If services are locked, return the error 
@@ -1544,6 +1566,7 @@
 		return RG_EABORT;
 	}
 	
+relocate:
 	/*
 	 * OK, it failed to start - but succeeded to stop.  Now,
 	 * we should relocate the service.
@@ -1581,6 +1604,7 @@
 	int x;
 	uint32_t me = my_id();
 	cluster_member_list_t *membership = member_list();
+	int need_check = have_exclusive_resources();
 
 	/* XXX ok, so we need to say "should I start this if I was the
 	   only cluster member online */
@@ -1601,10 +1625,23 @@
 		free_member_list(membership);
 		return RG_EFAIL;
 	}
+	if (need_check) {
+		pthread_mutex_lock(&exclusive_mutex);
+		if (check_exclusive_resources(membership, svcName) != 0) {
+			free_member_list(membership);
+			pthread_mutex_unlock(&exclusive_mutex);
+			return RG_EFAIL;
+		}
+	}
 	free_member_list(membership);
 
-	if (svc_start(svcName, req) == 0)
+	if (svc_start(svcName, req) == 0) {
+		if (need_check)
+			pthread_mutex_unlock(&exclusive_mutex);
 		return 0;
+	}
+	if (need_check)
+		pthread_mutex_unlock(&exclusive_mutex);
 
 	if (svc_stop(svcName, RG_STOP_RECOVER) == 0)
 		return RG_EFAIL;



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-12-12 21:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-02 15:15 [Cluster-devel] cluster/rgmanager ChangeLog src/daemons/groups lhh
  -- strict thread matches above, loose matches on Subject: below --
2007-12-12 21:41 lhh
2007-09-28 15:14 lhh
2007-07-31 18:26 lhh
2007-07-10 18:25 lhh
2007-07-10 18:24 lhh
2007-07-02 15:13 lhh
2007-04-19 18:05 lhh
2007-04-19 17:59 lhh

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.