[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] cluster/rgmanager ChangeLog include/res-ocf.h ...



CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	lhh sourceware org	2007-12-19 21:07:14

Modified files:
	rgmanager      : ChangeLog 
	rgmanager/include: res-ocf.h 
	rgmanager/src/daemons: restree.c 
	rgmanager/src/resources: clusterfs.sh 

Log message:
	Fix #254111 - when stopping a service using a shared GFS resource, it umounts it even if other services are using it.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/ChangeLog.diff?cvsroot=cluster&r1=1.66&r2=1.67
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/include/res-ocf.h.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/restree.c.diff?cvsroot=cluster&r1=1.40&r2=1.41
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/clusterfs.sh.diff?cvsroot=cluster&r1=1.22&r2=1.23

--- cluster/rgmanager/ChangeLog	2007/12/14 22:10:52	1.66
+++ cluster/rgmanager/ChangeLog	2007/12/19 21:07:13	1.67
@@ -1,3 +1,10 @@
+2007-12-19 Lon Hohberger <lhh at redhat.com>
+	* include/res-ocf.h: Fix typo
+	* src/daemons/restree.c: Export reference counts to resource agents.
+	* src/resources/clusterfs.sh: Use reference counts to ensure we
+	don't unmount a GFS file system if it's in use by multiple services
+	on the same node.  #254111
+
 2007-12-14 Lon Hohberger <lhh at redhat.com>
 	(Misc central_events fixes)
 	* Add return code for inability to run because of exclusive 
--- cluster/rgmanager/include/res-ocf.h	2007/07/31 18:00:25	1.3
+++ cluster/rgmanager/include/res-ocf.h	2007/12/19 21:07:13	1.4
@@ -31,6 +31,7 @@
 #define OCF_RESOURCE_INSTANCE_STR "OCF_RESOURCE_INSTANCE"
 #define OCF_CHECK_LEVEL_STR "OCF_CHECK_LEVEL"
 #define OCF_RESOURCE_TYPE_STR "OCF_RESOURCE_TYPE"
+#define OCF_REFCNT_STR "OCF_RESKEY_RGMANAGER_meta_refcnt"
 
 /*
    LSB return codes 
--- cluster/rgmanager/src/daemons/restree.c	2007/11/30 21:36:28	1.40
+++ cluster/rgmanager/src/daemons/restree.c	2007/12/19 21:07:14	1.41
@@ -130,7 +130,7 @@
    @see			build_env
  */
 static void
-add_ocf_stuff(resource_t *res, char **env, int depth)
+add_ocf_stuff(resource_t *res, char **env, int depth, int refcnt)
 {
 	char ver[10];
 	char *minor, *val;
@@ -214,6 +214,17 @@
 		return;
 	snprintf(val, n, "%s=%s", OCF_CHECK_LEVEL_STR, ver);
 	*env = val; env++;
+
+	/*
+	   Store the resource local refcnt (0 for now)
+	 */
+	snprintf(ver, sizeof(ver), "%d", refcnt);
+	n = strlen(OCF_REFCNT_STR) + strlen(ver) + 2;
+	val = malloc(n);
+	if (!val)
+		return;
+	snprintf(val, n, "%s=%s", OCF_REFCNT_STR, ver);
+	*env = val; env++;
 }
 
 
@@ -227,7 +238,7 @@
    @see			kill_env res_exec add_ocf_stuff
  */
 static char **
-build_env(resource_node_t *node, int depth)
+build_env(resource_node_t *node, int depth, int refcnt)
 {
 	resource_t *res = node->rn_resource;
 	char **env;
@@ -235,7 +246,7 @@
 	int x, attrs, n;
 
 	for (attrs = 0; res->r_attrs && res->r_attrs[attrs].ra_name; attrs++);
-	attrs += 7; /*
+	attrs += 8; /*
 		   Leave space for:
 		   OCF_RA_VERSION_MAJOR
 		   OCF_RA_VERSION_MINOR
@@ -243,6 +254,7 @@
 		   OCF_RESOURCE_INSTANCE
 		   OCF_RESOURCE_TYPE
 		   OCF_CHECK_LEVEL
+		   OCF_RESKEY_RGMANAGER_meta_refcnt
 		   (null terminator)
 		 */
 
@@ -282,7 +294,7 @@
 		++attrs;
 	}
 
-	add_ocf_stuff(res, &env[attrs], depth);
+	add_ocf_stuff(res, &env[attrs], depth, refcnt);
 
 	return env;
 }
@@ -345,7 +357,7 @@
 		return 0;
 
 #ifdef DEBUG
-	env = build_env(node, depth);
+	env = build_env(node, depth, node->rn_resource->r_incarnations);
 	if (!env)
 		return -errno;
 #endif
@@ -374,7 +386,7 @@
 #endif
 
 #ifndef DEBUG
-		env = build_env(node, depth);
+		env = build_env(node, depth, node->rn_resource->r_incarnations);
 #endif
 
 		if (!env)
--- cluster/rgmanager/src/resources/clusterfs.sh	2007/12/19 20:54:07	1.22
+++ cluster/rgmanager/src/resources/clusterfs.sh	2007/12/19 21:07:14	1.23
@@ -766,6 +766,7 @@
 	typeset -i try=1
 	typeset -i max_tries=3		# how many times to try umount
 	typeset -i sleep_time=2		# time between each umount failure
+	typeset -i refs=0
 	typeset done=""
 	typeset umount_failed=""
 	typeset force_umount=""
@@ -820,6 +821,18 @@
 		esac
 	fi
 
+	#
+	# Check the rgmanager-supplied reference count if one exists.
+	# If the reference count is <= 1, we can safely proceed
+	#
+	if [ -n "$OCF_RESKEY_RGMANAGER_meta_refcnt" ]; then
+		refs=$OCF_RESKEY_RGMANAGER_meta_refcnt
+		if [ $refs -gt 1 ]; then
+			((refs--))
+			ocf_log debug "Not unmounting $OCF_RESOURCE_INSTANCE - still in use by $refs other service(s)"
+			return $OCF_SUCCESS
+		fi
+	fi
 
 	#
 	# Always do this hackery on clustered file systems.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]