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: STABLE3 - rgmanager: Fix incarnation handling Date: Tue, 11 Aug 2009 19:09:00 -0000 [thread overview] Message-ID: <20090811190826.041C61201D6@lists.fedorahosted.org> (raw) 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; } }
reply other threads:[~2009-08-11 19:09 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=20090811190826.041C61201D6@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: linkBe 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).