From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29255 invoked by alias); 27 Mar 2009 14:27:13 -0000 Received: (qmail 29242 invoked by alias); 27 Mar 2009 14:27:12 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS X-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bastion.fedora.phx.redhat.com Subject: cluster: RHEL5 - rgmanager: Avoid status checks during reconfiguration To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/RHEL5 X-Git-Reftype: branch X-Git-Oldrev: 9ee39052aa3655ea76b50a5805b30ceb0bb62983 X-Git-Newrev: 638f8dbcfc5c9e81ef6f6da324f6a532fa5a71f7 From: Lon Hohberger Message-Id: <20090327142613.6679B120150@lists.fedorahosted.org> Date: Fri, 27 Mar 2009 14:27:00 -0000 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2009-q1/txt/msg00918.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=638f8dbcfc5c9e81ef6f6da324f6a532fa5a71f7 Commit: 638f8dbcfc5c9e81ef6f6da324f6a532fa5a71f7 Parent: 9ee39052aa3655ea76b50a5805b30ceb0bb62983 Author: Lon Hohberger AuthorDate: Mon Nov 17 14:53:41 2008 -0500 Committer: Lon Hohberger CommitterDate: Fri Mar 27 10:25:08 2009 -0400 rgmanager: Avoid status checks during reconfiguration Ignore queued status checks if a configuration update is pending. Basically, a queued status check during reconfiguration could get a status check done before the update is complete, causing an erroneous service restart. --- rgmanager/include/rg_locks.h | 9 ++++++--- rgmanager/src/daemons/groups.c | 9 ++++++++- rgmanager/src/daemons/main.c | 4 ++-- rgmanager/src/daemons/rg_locks.c | 24 +++++++++++++++++------- rgmanager/src/daemons/rg_thread.c | 4 ++++ 5 files changed, 37 insertions(+), 13 deletions(-) diff --git a/rgmanager/include/rg_locks.h b/rgmanager/include/rg_locks.h index 78d6096..c40607f 100644 --- a/rgmanager/include/rg_locks.h +++ b/rgmanager/include/rg_locks.h @@ -33,9 +33,12 @@ int rg_dec_threads(void); int rg_wait_threads(void); int rg_initialized(void); -int rg_set_initialized(void); -int rg_set_uninitialized(void); -int rg_wait_initialized(void); +int rg_set_initialized(int); +int rg_clear_initialized(int); +int rg_wait_initialized(int); + +#define FL_INIT 0x1 +#define FL_CONFIG 0x2 int rg_inc_status(void); int rg_dec_status(void); diff --git a/rgmanager/src/daemons/groups.c b/rgmanager/src/daemons/groups.c index 2c23cd5..e02a3dc 100644 --- a/rgmanager/src/daemons/groups.c +++ b/rgmanager/src/daemons/groups.c @@ -1673,6 +1673,12 @@ init_resource_groups(int reconfigure, int do_init, int new_config_version) free(val); } + /* Wait for any pending requests */ + rg_wait_threads(); + /* Block operations that would break during configuration + changes */ + rg_clear_initialized(FL_CONFIG); + clulog(LOG_DEBUG, "Building Resource Trees\n"); /* About to update the entire resource tree... */ if (load_resources(fd, &reslist, &rulelist) != 0) { @@ -1771,8 +1777,9 @@ init_resource_groups(int reconfigure, int do_init, int new_config_version) } else { clulog(LOG_INFO, "Skipping stop-before-start: overridden by administrator\n"); } - rg_set_initialized(); + rg_set_initialized(FL_INIT); } + rg_set_initialized(FL_CONFIG); return 0; } diff --git a/rgmanager/src/daemons/main.c b/rgmanager/src/daemons/main.c index 6a5a8b4..dcfa26c 100644 --- a/rgmanager/src/daemons/main.c +++ b/rgmanager/src/daemons/main.c @@ -165,7 +165,7 @@ membership_update(void) #endif clulog(LOG_DEBUG, "Flushing resource group cache\n"); kill_resource_groups(); - rg_set_uninitialized(); + rg_clear_initialized(0); return -1; } else if (!rg_quorate()) { @@ -677,7 +677,7 @@ handle_cluster_event(msgctx_t *ctx) clulog(LOG_WARNING, "#67: Shutting down uncleanly\n"); rg_set_inquorate(); rg_doall(RG_INIT, 1, "Emergency stop of %s"); - rg_set_uninitialized(); + rg_clear_initialized(0); #if defined(LIBCMAN_VERSION) && LIBCMAN_VERSION >= 2 /* cman_replyto_shutdown() */ #endif diff --git a/rgmanager/src/daemons/rg_locks.c b/rgmanager/src/daemons/rg_locks.c index ef60748..5f2f342 100644 --- a/rgmanager/src/daemons/rg_locks.c +++ b/rgmanager/src/daemons/rg_locks.c @@ -65,10 +65,13 @@ rg_initialized(void) int -rg_set_initialized(void) +rg_set_initialized(int flag) { + if (!flag) + flag = ~0; + pthread_mutex_lock(&locks_mutex); - __rg_initialized = 1; + __rg_initialized |= flag; pthread_cond_broadcast(&init_cond); pthread_mutex_unlock(&locks_mutex); return 0; @@ -76,21 +79,28 @@ rg_set_initialized(void) int -rg_set_uninitialized(void) +rg_clear_initialized(int flag) { + if (!flag) + flag = ~0; pthread_mutex_lock(&locks_mutex); - __rg_initialized = 0; + __rg_initialized &= ~flag; pthread_mutex_unlock(&locks_mutex); return 0; } int -rg_wait_initialized(void) +rg_wait_initialized(int flag) { pthread_mutex_lock(&locks_mutex); - while (!__rg_initialized) - pthread_cond_wait(&init_cond, &locks_mutex); + if (flag) { + while ((__rg_initialized & flag) != flag) + pthread_cond_wait(&init_cond, &locks_mutex); + } else { + while (!__rg_initialized) + pthread_cond_wait(&init_cond, &locks_mutex); + } pthread_mutex_unlock(&locks_mutex); return 0; } diff --git a/rgmanager/src/daemons/rg_thread.c b/rgmanager/src/daemons/rg_thread.c index bcd6eee..d0c0b50 100644 --- a/rgmanager/src/daemons/rg_thread.c +++ b/rgmanager/src/daemons/rg_thread.c @@ -434,6 +434,10 @@ resgroup_thread_main(void *arg) break; case RG_STATUS: + if (!(rg_initialized()&FL_CONFIG)) { + ret = RG_SUCCESS; + break; + } /* Need to make sure we don't check status of resource groups we don't own */ error = svc_status(myname);