CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL5
Changes by: [EMAIL PROTECTED] 2007-12-19 21:04:41
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&only_with_tag=RHEL5&r1=1.31.2.32&r2=1.31.2.33
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/include/res-ocf.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1.16.3&r2=1.1.16.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/restree.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.23.2.13&r2=1.23.2.14
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/clusterfs.sh.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.15.2.6&r2=1.15.2.7
--- cluster/rgmanager/ChangeLog 2007/12/18 17:52:55 1.31.2.32
+++ cluster/rgmanager/ChangeLog 2007/12/19 21:04:40 1.31.2.33
@@ -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-18 Lon Hohberger <lhh at redhat.com>
* Merge RIND 0.8.1 + bugfixes from head branch to RHEL5
branch. Must be explicitly enabled by administrators in
--- cluster/rgmanager/include/res-ocf.h 2007/12/18 17:52:56 1.1.16.3
+++ cluster/rgmanager/include/res-ocf.h 2007/12/19 21:04:40 1.1.16.4
@@ -31,7 +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_RECFNT_STR "OCF_RESKEY_RGMANAGER_meta_refcnt"
+#define OCF_REFCNT_STR "OCF_RESKEY_RGMANAGER_meta_refcnt"
/*
LSB return codes
--- cluster/rgmanager/src/daemons/restree.c 2007/11/26 21:46:27
1.23.2.13
+++ cluster/rgmanager/src/daemons/restree.c 2007/12/19 21:04:41
1.23.2.14
@@ -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)
@@ -1063,7 +1075,8 @@
/* Ok, it's a 'status' action. See if enough time has
elapsed for a given type of status action */
- if (delta < node->rn_actions[x].ra_interval)
+ if (delta < node->rn_actions[x].ra_interval ||
+ !node->rn_actions[x].ra_interval)
continue;
if (idx == -1 ||
--- cluster/rgmanager/src/resources/clusterfs.sh 2007/12/19 20:53:35
1.15.2.6
+++ cluster/rgmanager/src/resources/clusterfs.sh 2007/12/19 21:04:41
1.15.2.7
@@ -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.