public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
From: Lon Hohberger <lon@fedoraproject.org>
To: cluster-cvs-relay@redhat.com
Subject: cluster: RHEL5 - rgmanager: Fix incarnation handling
Date: Wed, 12 Aug 2009 14:47:00 -0000	[thread overview]
Message-ID: <20090812144655.8ACD01201E6@lists.fedorahosted.org> (raw)

Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=f50272d497c5596a7b191b66ef216878b0fafc07
Commit:        f50272d497c5596a7b191b66ef216878b0fafc07
Parent:        48ea9c79b17f5fd98ab07fb2dc219ffee00bfc89
Author:        Lon Hohberger <lhh@redhat.com>
AuthorDate:    Fri Jul 31 15:42:58 2009 -0400
Committer:     Lon Hohberger <lhh@redhat.com>
CommitterDate: Wed Aug 12 10:46:24 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 7e30db5..b202c2f 100644
--- a/rgmanager/include/reslist.h
+++ b/rgmanager/include/reslist.h
@@ -110,6 +110,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 cdc68a0..94e8c64 100644
--- a/rgmanager/src/daemons/reslist.c
+++ b/rgmanager/src/daemons/reslist.c
@@ -749,6 +749,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 6de7c49..d93921b 100644
--- a/rgmanager/src/daemons/restree.c
+++ b/rgmanager/src/daemons/restree.c
@@ -1345,6 +1345,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);
@@ -1355,6 +1356,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;
 		}
 
@@ -1365,6 +1367,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 */
@@ -1422,16 +1426,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;
 		}
 	}


                 reply	other threads:[~2009-08-12 14:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090812144655.8ACD01201E6@lists.fedorahosted.org \
    --to=lon@fedoraproject.org \
    --cc=cluster-cvs-relay@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).