public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: STABLE3 - rgmanager: Fix incarnation handling
@ 2009-08-11 19:09 Lon Hohberger
  0 siblings, 0 replies; only message in thread
From: Lon Hohberger @ 2009-08-11 19:09 UTC (permalink / raw)
  To: cluster-cvs-relay

Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=7c04d4ab728bf612ae22cd69d107fad3c220e017
Commit:        7c04d4ab728bf612ae22cd69d107fad3c220e017
Parent:        db508706c7f433041823b21a4ce50df9e0edfd51
Author:        Lon Hohberger <lhh@redhat.com>
AuthorDate:    Fri Jul 31 15:42:58 2009 -0400
Committer:     Lon Hohberger <lhh@redhat.com>
CommitterDate: Tue Aug 11 15:07:53 2009 -0400

rgmanager: Fix incarnation handling

* Don't allow simultaneous starts/stops of the *same*
resource.
* Make incarnation numbers consistent between start/stop

Red Hat Bugzilla #506094, part 3/3

Signed-off-by: Lon Hohberger <lhh@redhat.com>
---
 rgmanager/include/reslist.h     |    1 +
 rgmanager/src/daemons/reslist.c |    1 +
 rgmanager/src/daemons/restree.c |   20 +++++++++++++++++++-
 3 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/rgmanager/include/reslist.h b/rgmanager/include/reslist.h
index 20f205d..88e148b 100644
--- a/rgmanager/include/reslist.h
+++ b/rgmanager/include/reslist.h
@@ -92,6 +92,7 @@ typedef struct _resource_rule {
 
 typedef struct _resource {
 	list_head();
+	pthread_mutex_t		r_mutex;
 	resource_rule_t *	r_rule;
 	char *	r_name;
 	resource_attr_t *	r_attrs;
diff --git a/rgmanager/src/daemons/reslist.c b/rgmanager/src/daemons/reslist.c
index 96336e4..fac4812 100644
--- a/rgmanager/src/daemons/reslist.c
+++ b/rgmanager/src/daemons/reslist.c
@@ -729,6 +729,7 @@ load_resource(int ccsfd, resource_rule_t *rule, char *base)
 	}
 
 	memset(res, 0, sizeof(*res));
+	pthread_mutex_init(&res->r_mutex, NULL);
 	res->r_rule = rule;
 
 	for (x = 0; res->r_rule->rr_attrs &&
diff --git a/rgmanager/src/daemons/restree.c b/rgmanager/src/daemons/restree.c
index 5afbc5c..4ae0848 100644
--- a/rgmanager/src/daemons/restree.c
+++ b/rgmanager/src/daemons/restree.c
@@ -1290,6 +1290,7 @@ _res_op_internal(resource_node_t __attribute__ ((unused)) **tree,
 	/* Start starts before children */
 	if (me && (op == RS_START)) {
 
+		pthread_mutex_lock(&node->rn_resource->r_mutex);
 		if (node->rn_flags & RF_RECONFIG &&
 		    realop == RS_CONDSTART) {
 			rv = res_exec(node, RS_RECONFIG, NULL, 0);
@@ -1300,6 +1301,7 @@ _res_op_internal(resource_node_t __attribute__ ((unused)) **tree,
 		node->rn_flags &= ~(RF_NEEDSTART | RF_RECONFIG);
 		if (rv != 0) {
 			node->rn_state = RES_FAILED;
+			pthread_mutex_unlock(&node->rn_resource->r_mutex);
 			return SFL_FAILURE;
 		}
 
@@ -1310,6 +1312,8 @@ _res_op_internal(resource_node_t __attribute__ ((unused)) **tree,
 			++node->rn_resource->r_incarnations;
 			node->rn_state = RES_STARTED;
 		}
+		pthread_mutex_unlock(&node->rn_resource->r_mutex);
+
 	} else if (me && (op == RS_STATUS || op == RS_STATUS_INQUIRY)) {
 
 		/* Special quick-check for status inquiry */
@@ -1367,16 +1371,30 @@ _res_op_internal(resource_node_t __attribute__ ((unused)) **tree,
  			
 	/* Stop should occur after children have stopped */
 	if (me && (op == RS_STOP)) {
+
+		/* Decrease incarnations so the script knows how many *other*
+		   incarnations there are. */
+		pthread_mutex_lock(&node->rn_resource->r_mutex);
+		if (node->rn_state == RES_STARTED) {
+			assert(node->rn_resource->r_incarnations > 0);
+			--node->rn_resource->r_incarnations;
+		}
+
 		node->rn_flags &= ~RF_NEEDSTOP;
 		rv |= res_exec(node, op, NULL, 0);
 
 		if (rv != 0) {
+			if (node->rn_state == RES_STARTED) {
+				/* Fail to stop: fix incarnations */
+				++node->rn_resource->r_incarnations;
+			}
 			node->rn_state = RES_FAILED;
+			pthread_mutex_unlock(&node->rn_resource->r_mutex);
 			return SFL_FAILURE;
 		}
+		pthread_mutex_unlock(&node->rn_resource->r_mutex);
 
 		if (node->rn_state != RES_STOPPED) {
-			--node->rn_resource->r_incarnations;
 			node->rn_state = RES_STOPPED;
 		}
 	}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-08-11 19:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-11 19:09 cluster: STABLE3 - rgmanager: Fix incarnation handling Lon Hohberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).