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: Avoid status checks during reconfiguration
Date: Fri, 27 Mar 2009 14:27:00 -0000	[thread overview]
Message-ID: <20090327142613.6679B120150@lists.fedorahosted.org> (raw)

Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=638f8dbcfc5c9e81ef6f6da324f6a532fa5a71f7
Commit:        638f8dbcfc5c9e81ef6f6da324f6a532fa5a71f7
Parent:        9ee39052aa3655ea76b50a5805b30ceb0bb62983
Author:        Lon Hohberger <lhh@redhat.com>
AuthorDate:    Mon Nov 17 14:53:41 2008 -0500
Committer:     Lon Hohberger <lhh@redhat.com>
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);


                 reply	other threads:[~2009-03-27 14:27 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=20090327142613.6679B120150@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).