cluster: STABLE3 - HA LVM: Use CLVM with local machine kernel targets (bz 585217)
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 38a984c3b415a13142d2f65aa30edcdc60d70497
Parent: 32dc73f5e8ed4a4266985905770a8ff4eee84dbe
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Mon Apr 26 10:55:18 2010 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Mon Apr 26 10:55:18 2010 -0500
HA LVM: Use CLVM with local machine kernel targets (bz 585217)
When a logical volume is activated in a cluster exclusively,
the kernel targets used are single machine targets. This
means we can use CLVM to protect the LVM metadata and still
better align ourselves with active/passive application stacks.
Making this change also simplifies HA LVM setup. There is no
more setting up tags, volume_list entries, or updating the
initrd.
---
rgmanager/src/resources/lvm.sh | 52 ++-----------
rgmanager/src/resources/lvm_by_lv.sh | 75 +++++++++++++++++-
rgmanager/src/resources/lvm_by_vg.sh | 147 +++++++++++++++++++++++++++++++++-
3 files changed, 221 insertions(+), 53 deletions(-)
diff --git a/rgmanager/src/resources/lvm.sh b/rgmanager/src/resources/lvm.sh
index b19a8ac..4b7155c 100644
--- a/rgmanager/src/resources/lvm.sh
+++ b/rgmanager/src/resources/lvm.sh
@@ -17,19 +17,6 @@ export LC_ALL LANG PATH
rv=0
################################################################################
-# clvm_check
-#
-################################################################################
-function clvm_check
-{
- if [[ $(vgs -o attr --noheadings $1) =~ .....c ]]; then
- return 1
- fi
-
- return 0
-}
-
-################################################################################
# ha_lvm_proper_setup_check
#
################################################################################
@@ -87,18 +74,10 @@ function ha_lvm_proper_setup_check
case $1 in
start)
- ##
- # We can safely ignore clustered volume groups (VGs handled by CLVM)
- ##
- if ! clvm_check $OCF_RESKEY_vg_name; then
- ocf_log notice "$OCF_RESKEY_vg_name is a cluster volume. Ignoring..."
- exit 0
+ if ! [[ $(vgs -o attr --noheadings $OCF_RESKEY_vg_name) =~ .....c ]]; then
+ ha_lvm_proper_setup_check || exit 1
fi
- ha_lvm_proper_setup_check || exit 1
-
- rv=0
-
if [ -z $OCF_RESKEY_lv_name ]; then
vg_start || exit 1
else
@@ -114,20 +93,13 @@ status|monitor)
else
lv_status || exit 1
fi
- rv=0
;;
stop)
- ##
- # We can safely ignore clustered volume groups (VGs handled by CLVM)
- ##
- if ! clvm_check $OCF_RESKEY_vg_name; then
- ocf_log notice "$OCF_RESKEY_vg_name is a cluster volume. Ignoring..."
- exit 0
- fi
-
- if ! ha_lvm_proper_setup_check; then
- ocf_log err "WARNING: An improper setup can cause data corruption!"
+ if ! [[ $(vgs -o attr --noheadings $OCF_RESKEY_vg_name) =~ .....c ]]; then
+ if ! ha_lvm_proper_setup_check; then
+ ocf_log err "WARNING: An improper setup can cause data corruption!"
+ fi
fi
if [ -z $OCF_RESKEY_lv_name ]; then
@@ -135,35 +107,23 @@ stop)
else
lv_stop || exit 1
fi
- rv=0
;;
recover|restart)
$0 stop || exit $OCF_ERR_GENERIC
$0 start || exit $OCF_ERR_GENERIC
- rv=0
;;
meta-data)
cat `echo $0 | sed 's/^\(.*\)\.sh$/\1.metadata/'`
- rv=0
;;
validate-all|verify-all)
- ##
- # We can safely ignore clustered volume groups (VGs handled by CLVM)
- ##
- if ! clvm_check $OCF_RESKEY_vg_name; then
- ocf_log notice "$OCF_RESKEY_vg_name is a cluster volume. Ignoring..."
- exit 0
- fi
-
if [ -z $OCF_RESKEY_lv_name ]; then
vg_verify || exit 1
else
lv_verify || exit 1
fi
- rv=0
;;
*)
echo "usage: $0 {start|status|monitor|stop|restart|meta-data|validate-all}"
diff --git a/rgmanager/src/resources/lvm_by_lv.sh b/rgmanager/src/resources/lvm_by_lv.sh
index 54e67bf..759062a 100644
--- a/rgmanager/src/resources/lvm_by_lv.sh
+++ b/rgmanager/src/resources/lvm_by_lv.sh
@@ -82,10 +82,22 @@ lv_activate_resilient()
fi
}
+lv_status_clustered()
+{
+ #
+ # Check if device is active
+ #
+ if [[ ! $(lvs -o attr --noheadings $lv_path) =~ ....a. ]]; then
+ return $OCF_ERR_GENERIC
+ fi
+
+ return $OCF_SUCCESS
+}
+
# lv_status
#
# Is the LV active?
-lv_status()
+lv_status_single()
{
declare lv_path="$OCF_RESKEY_vg_name/$OCF_RESKEY_lv_name"
declare dev="/dev/$lv_path"
@@ -148,6 +160,16 @@ lv_status()
return $OCF_SUCCESS
}
+function lv_status
+{
+ # We pass in the VG name to see of the logical volume is clustered
+ if [[ $(vgs -o attr --noheadings $OCF_RESKEY_vg_name) =~ .....c ]]; then
+ lv_status_clustered
+ else
+ lv_status_single
+ fi
+}
+
# lv_activate_and_tag
lv_activate_and_tag()
{
@@ -315,7 +337,29 @@ lv_activate()
return $OCF_SUCCESS
}
-function lv_start
+function lv_start_clustered
+{
+ if ! lvchange -aey $OCF_RESKEY_vg_name/$OCF_RESKEY_lv_name; then
+ ocf_log err "Failed to activate logical volume, $OCF_RESKEY_vg_name/$OCF_RESKEY_lv_name"
+ ocf_log notice "Attempting cleanup of $OCF_RESKEY_vg_name/$OCF_RESKEY_lv_name"
+
+ if ! lvconvert --repair --use-policies $OCF_RESKEY_vg_name/$OCF_RESKEY_lv_name; then
+ ocf_log err "Failed to cleanup $OCF_RESKEY_vg_name/$OCF_RESKEY_lv_name"
+ return $OCF_ERR_GENERIC
+ fi
+
+ if ! lvchange -aey $OCF_RESKEY_vg_name/$OCF_RESKEY_lv_name; then
+ ocf_log err "Failed second attempt to activate $OCF_RESKEY_vg_name/$OCF_RESKEY_lv_name"
+ return $OCF_ERR_GENERIC
+ fi
+
+ ocf_log notice "Second attempt to activate $OCF_RESKEY_vg_name/$OCF_RESKEY_lv_name successful"
+ return $OCF_SUCCESS
+ fi
+ return $OCF_SUCCESS
+}
+
+function lv_start_single
{
if ! lvs $OCF_RESKEY_vg_name >& /dev/null; then
lv_count=0
@@ -336,7 +380,22 @@ function lv_start
return 0
}
-function lv_stop
+function lv_start
+{
+ # We pass in the VG name to see of the logical volume is clustered
+ if [[ $(vgs -o attr --noheadings $OCF_RESKEY_vg_name) =~ .....c ]]; then
+ lv_start_clustered
+ else
+ lv_start_single
+ fi
+}
+
+function lv_stop_clustered
+{
+ lvchange -aln $OCF_RESKEY_vg_name/$OCF_RESKEY_lv_name
+}
+
+function lv_stop_single
{
if ! lv_activate stop; then
return 1
@@ -344,3 +403,13 @@ function lv_stop
return 0
}
+
+function lv_stop
+{
+ # We pass in the VG name to see of the logical volume is clustered
+ if [[ $(vgs -o attr --noheadings $OCF_RESKEY_vg_name) =~ .....c ]]; then
+ lv_stop_clustered
+ else
+ lv_stop_single
+ fi
+}
diff --git a/rgmanager/src/resources/lvm_by_vg.sh b/rgmanager/src/resources/lvm_by_vg.sh
index 0c1bf0b..f0ca671 100644
--- a/rgmanager/src/resources/lvm_by_vg.sh
+++ b/rgmanager/src/resources/lvm_by_vg.sh
@@ -66,14 +66,18 @@ function strip_and_add_tag
return $OCF_SUCCESS
}
+function vg_status_clustered
+{
+ return $OCF_SUCCESS
+}
+
# vg_status
#
# Are all the LVs active?
-function vg_status
+function vg_status_single
{
local i
local dev
- local readdev
local my_name=$(local_node_name)
#
@@ -125,13 +129,88 @@ function vg_status
return $OCF_SUCCESS
}
+##
+# Main status function for volume groups
+##
+function vg_status
+{
+ if [[ $(vgs -o attr --noheadings $OCF_RESKEY_vg_name) =~ .....c ]]; then
+ vg_status_clustered
+ else
+ vg_status_single
+ fi
+}
+
function vg_verify
{
# Anything to verify?
return $OCF_SUCCESS
}
-function vg_start
+function vg_start_clustered
+{
+ local a
+ local results
+ local all_pvs
+ local resilience
+
+ ocf_log info "Starting volume group, $OCF_RESKEY_vg_name"
+
+ if ! vgchange -aey $OCF_RESKEY_vg_name; then
+ ocf_log err "Failed to activate volume group, $OCF_RESKEY_vg_name"
+ ocf_log notice "Attempting cleanup of $OCF_RESKEY_vg_name"
+
+ if ! vgreduce --removemissing $OCF_RESKEY_vg_name; then
+ ocf_log err "Failed to make $OCF_RESKEY_vg_name consistent"
+ return $OCF_ERR_GENERIC
+ fi
+
+ if ! vgchange -aey $OCF_RESKEY_vg_name; then
+ ocf_log err "Failed second attempt to activate $OCF_RESKEY_vg_name"
+ return $OCF_ERR_GENERIC
+ fi
+
+ ocf_log notice "Second attempt to activate $OCF_RESKEY_vg_name successful"
+ return $OCF_SUCCESS
+ else
+ # The activation commands succeeded, but did they do anything?
+ # Make sure all the logical volumes are active
+ results=(`lvs -o name,attr --noheadings 2> /dev/null $OCF_RESKEY_vg_name`)
+ a=0
+ while [ ! -z ${results[$a]} ]; do
+ if [[ ! ${results[$(($a + 1))]} =~ ....a. ]]; then
+ all_pvs=(`pvs --noheadings -o name 2> /dev/null`)
+ resilience=" --config devices{filter=["
+ for i in ${all_pvs[*]}; do
+ resilience=$resilience'"a|'$i'|",'
+ done
+ resilience=$resilience"\"r|.*|\"]}"
+
+ vgchange -aey $OCF_RESKEY_vg_name $resilience
+ break
+ fi
+ a=$(($a + 2))
+ done
+
+ # We need to check the LVs again if we made the command resilient
+ if [ ! -z $resilience ]; then
+ results=(`lvs -o name,attr --noheadings $OCF_RESKEY_vg_name $resilience 2> /dev/null`)
+ a=0
+ while [ ! -z ${results[$a]} ]; do
+ if [[ ! ${results[$(($a + 1))]} =~ ....a. ]]; then
+ ocf_log err "Failed to activate $OCF_RESKEY_vg_name"
+ return $OCF_ERR_GENERIC
+ fi
+ a=$(($a + 2))
+ done
+ ocf_log err "Orphan storage device in $OCF_RESKEY_vg_name slowing operations"
+ fi
+ fi
+
+ return $OCF_SUCCESS
+}
+
+function vg_start_single
{
local a
local results
@@ -219,7 +298,55 @@ function vg_start
return $OCF_SUCCESS
}
-function vg_stop
+##
+# Main start function for volume groups
+##
+function vg_start
+{
+ if [[ $(vgs -o attr --noheadings $OCF_RESKEY_vg_name) =~ .....c ]]; then
+ vg_start_clustered
+ else
+ vg_start_single
+ fi
+}
+
+function vg_stop_clustered
+{
+ local a
+ local results
+ typeset self_fence=""
+
+ case ${OCF_RESKEY_self_fence} in
+ "yes") self_fence=1 ;;
+ 1) self_fence=1 ;;
+ *) self_fence="" ;;
+ esac
+
+ # Shut down the volume group
+ # Do we need to make this resilient?
+ vgchange -aln $OCF_RESKEY_vg_name
+
+ # Make sure all the logical volumes are inactive
+ results=(`lvs -o name,attr --noheadings $OCF_RESKEY_vg_name 2> /dev/null`)
+ a=0
+ while [ ! -z ${results[$a]} ]; do
+ if [[ ${results[$(($a + 1))]} =~ ....a. ]]; then
+ if [ "$self_fence" ]; then
+ ocf_log err "Unable to deactivate $lv_path REBOOT"
+ sync
+ reboot -fn
+ else
+ ocf_log err "Logical volume $OCF_RESKEY_vg_name/${results[$a]} failed to shutdown"
+ fi
+ return $OCF_ERR_GENERIC
+ fi
+ a=$(($a + 2))
+ done
+
+ return $OCF_SUCCESS
+}
+
+function vg_stop_single
{
local a
local results
@@ -260,3 +387,15 @@ function vg_stop
return $OCF_SUCCESS
}
+
+##
+# Main stop function for volume groups
+##
+function vg_stop
+{
+ if [[ $(vgs -o attr --noheadings $OCF_RESKEY_vg_name) =~ .....c ]]; then
+ vg_stop_clustered
+ else
+ vg_stop_single
+ fi
+}
14 years
cluster: RHEL56 - fence_ipmilan: add information needed for automatic man page generation
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 4b4ac43455ebfe95aac903fdd4c67a8a09e4e180
Parent: bab42c2b278dc3006f22155c1bec0e62fdf4eee9
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Fri Apr 23 14:37:24 2010 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Fri Apr 23 14:37:24 2010 +0200
fence_ipmilan: add information needed for automatic man page generation
Resolves: rhbz#488959 (partially)
---
fence/agents/ipmilan/ipmilan.c | 70 +++++++++++++++++++++++++++++-----------
1 files changed, 51 insertions(+), 19 deletions(-)
diff --git a/fence/agents/ipmilan/ipmilan.c b/fence/agents/ipmilan/ipmilan.c
index d16dfc9..0bc59d4 100644
--- a/fence/agents/ipmilan/ipmilan.c
+++ b/fence/agents/ipmilan/ipmilan.c
@@ -180,22 +180,27 @@ static struct Etoken power_status[] = {
/* Structure describing one xml metadata value*/
struct xml_parameter_s {
- char *name;
- char *description;
+ const char *name;
+ const char *getopt;
+ const int required;
+ const char *content_type;
+ const char *default_value;
+ const char *description;
};
/* Array of xml metadatas*/
struct xml_parameter_s xml_parameters[]={
- {"auth","IPMI Lan Auth type (md5, password, or none)"},
- {"ipaddr","IPMI Lan IP to talk to"},
- {"passwd","Password (if required) to control power on IPMI device"},
- {"passwd_script","Script to retrieve password (if required)"},
- {"lanplus","Use Lanplus"},
- {"login","Username/Login (if required) to control power on IPMI device"},
- {"action","Operation to perform. Valid operations: on, off, reboot, status, list, monitor or metadata"},
- {"timeout","Timeout (sec) for IPMI operation"},
- {"cipher","Ciphersuite to use (same as ipmitool -C parameter)"},
- {"verbose","Verbose mode"}};
+ {"auth","-A",0,"string",NULL,"IPMI Lan Auth type (md5, password, or none)"},
+ {"ipaddr","-a",1,"string",NULL,"IPMI Lan IP to talk to"},
+ {"passwd","-p",0,"string",NULL,"Password (if required) to control power on IPMI device"},
+ {"passwd_script","-S",0,"string",NULL,"Script to retrieve password (if required)"},
+ {"lanplus","-P",0,"boolean",NULL,"Use Lanplus"},
+ {"login","-l",0,"string",NULL,"Username/Login (if required) to control power on IPMI device"},
+ {"action","-o",0,"string","reboot","Operation to perform. Valid operations: on, off, reboot, status, list, monitor or metadata"},
+ {"timeout","-t",0,"string",NULL,"Timeout (sec) for IPMI operation"},
+ {"cipher","-C",0,"string",NULL,"Ciphersuite to use (same as ipmitool -C parameter)"},
+ {"method","-M",0,"string",DEFAULT_METHOD,"Method to fence (onoff or cycle)"},
+ {"verbose","-v",0,"boolean",NULL,"Verbose mode"}};
/*
Search for ipmitool
@@ -1076,18 +1081,41 @@ void print_xml_metadata(char *pname) {
int i;
printf("%s\n","<?xml version=\"1.0\" ?>");
- printf("%s%s%s\n","<resource-agent name=\"",pname,"\" >");
+ printf("%s%s%s\n","<resource-agent name=\"",pname,"\" shortdesc=\"Fence agent for IPMI over LAN\">");
+ printf("<longdesc>\n");
+ printf("fence_ipmilan is an I/O Fencing agent which can be used with "
+ "machines controlled by IPMI. This agent calls support software "
+ "using ipmitool (http://ipmitool.sf.net/).");
+ printf("</longdesc>\n");
printf("%s\n","<parameters>");
for (i=0;i<(sizeof(xml_parameters)/sizeof(struct xml_parameter_s));i++) {
printf("\t<parameter name=\"%s\" unique=\"1\">\n",xml_parameters[i].name);
- printf("\t\t<shortdesc lang=\"C\">");
+ printf("\t\t<getopt mixed=\"%s\" />\n",xml_parameters[i].getopt);
+ if (xml_parameters[i].default_value == NULL) {
+ printf("\t\t<content type=\"%s\" />\n",xml_parameters[i].content_type);
+ } else {
+ printf("\t\t<content type=\"%s\" default=\"%s\"/>\n", \
+ xml_parameters[i].content_type, \
+ xml_parameters[i].default_value );
+ }
+
+ printf("\t\t<shortdesc lang=\"en\">");
printf("%s",xml_parameters[i].description);
printf("</shortdesc>\n");
printf("\t</parameter>\n");
}
printf("%s\n","</parameters>");
+ printf("%s\n","<actions>");
+ printf("\t<action name=\"%s\" />\n", "on");
+ printf("\t<action name=\"%s\" />\n", "off");
+ printf("\t<action name=\"%s\" />\n", "reboot");
+ printf("\t<action name=\"%s\" />\n", "status");
+ printf("\t<action name=\"%s\" />\n", "list");
+ printf("\t<action name=\"%s\" />\n", "monitor");
+ printf("\t<action name=\"%s\" />\n", "metadata");
+ printf("%s\n","</actions>");
printf("%s\n","</resource-agent>");
}
@@ -1218,6 +1246,14 @@ main(int argc, char **argv)
}
}
+ if (!strcasecmp(op, "metadata")) {
+ print_xml_metadata(pname);
+ translated_ret = ERR_OK;
+ ret=0;
+ print_final_status=0;
+ goto metaout;
+ }
+
/*
Validate the operating parameters
*/
@@ -1326,11 +1362,6 @@ main(int argc, char **argv)
ret=0;
translated_ret = ERR_OK;
print_final_status=0;
- } else if (!strcasecmp(op, "metadata")) {
- print_xml_metadata(pname);
- ret=0;
- translated_ret = ERR_OK;
- print_final_status=0;
}
@@ -1338,6 +1369,7 @@ out:
ipmi_destroy(i);
free(i);
+metaout:
if (print_final_status) {
if (ret == 0)
printf("Done\n");
14 years
cluster: RHEL56 - fence_ipmilan: Correct exit codes for status operation
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: bab42c2b278dc3006f22155c1bec0e62fdf4eee9
Parent: d4ae5b0f197288fafe884046ba9d9cd1c9c556b0
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Fri Apr 23 14:35:13 2010 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Fri Apr 23 14:35:13 2010 +0200
fence_ipmilan: Correct exit codes for status operation
According to standard operation status should return 0 (if ON) and 2 (if OFF).
In all other cases if operation was succesfull then agent return 0.
Resolves: rhbz#583034 (partially)
---
fence/agents/ipmilan/ipmilan.c | 107 ++++++++++++++++++++++++++++++++++------
1 files changed, 92 insertions(+), 15 deletions(-)
diff --git a/fence/agents/ipmilan/ipmilan.c b/fence/agents/ipmilan/ipmilan.c
index d8d76ff..d16dfc9 100644
--- a/fence/agents/ipmilan/ipmilan.c
+++ b/fence/agents/ipmilan/ipmilan.c
@@ -57,6 +57,19 @@ do { \
#define DEFAULT_METHOD "onoff"
+/* We should follow FenceAgentsAPI standard*/
+#define ERR_OFF_SUCCESSFUL 0
+#define ERR_OFF_FAIL 1
+
+#define ERR_ON_SUCCESSFUL 0
+#define ERR_ON_FAIL 1
+
+#define ERR_STATUS_ON 0
+#define ERR_STATUS_FAIL 1
+#define ERR_STATUS_OFF 2
+
+#define ERR_OK 0
+
#define log(lvl, fmt, args...) fprintf(stderr, fmt, ##args)
#include <libgen.h>
@@ -165,6 +178,24 @@ static struct Etoken power_status[] = {
{NULL, 0, 0}
};
+/* Structure describing one xml metadata value*/
+struct xml_parameter_s {
+ char *name;
+ char *description;
+};
+
+/* Array of xml metadatas*/
+struct xml_parameter_s xml_parameters[]={
+ {"auth","IPMI Lan Auth type (md5, password, or none)"},
+ {"ipaddr","IPMI Lan IP to talk to"},
+ {"passwd","Password (if required) to control power on IPMI device"},
+ {"passwd_script","Script to retrieve password (if required)"},
+ {"lanplus","Use Lanplus"},
+ {"login","Username/Login (if required) to control power on IPMI device"},
+ {"action","Operation to perform. Valid operations: on, off, reboot, status, list, monitor or metadata"},
+ {"timeout","Timeout (sec) for IPMI operation"},
+ {"cipher","Ciphersuite to use (same as ipmitool -C parameter)"},
+ {"verbose","Verbose mode"}};
/*
Search for ipmitool
@@ -1015,7 +1046,7 @@ printf(" -S <path> Script to retrieve password (if required)\n");
printf(" -l <login> Username/Login (if required) to control power\n"
" on IPMI device\n");
printf(" -o <op> Operation to perform.\n");
-printf(" Valid operations: on, off, reboot, status\n");
+printf(" Valid operations: on, off, reboot, status, list or monitor\n");
printf(" -t <timeout> Timeout (sec) for IPMI operation (default %d)\n",DEFAULT_TIMEOUT);
printf(" -C <cipher> Ciphersuite to use (same as ipmitool -C parameter)\n");
printf(" -M <method> Method to fence (onoff or cycle (default %s)\n", DEFAULT_METHOD);
@@ -1040,6 +1071,26 @@ printf(" verbose Same as -v\n\n");
}
+/** Print XML metadata of fence agent*/
+void print_xml_metadata(char *pname) {
+ int i;
+
+ printf("%s\n","<?xml version=\"1.0\" ?>");
+ printf("%s%s%s\n","<resource-agent name=\"",pname,"\" >");
+ printf("%s\n","<parameters>");
+
+ for (i=0;i<(sizeof(xml_parameters)/sizeof(struct xml_parameter_s));i++) {
+ printf("\t<parameter name=\"%s\" unique=\"1\">\n",xml_parameters[i].name);
+
+ printf("\t\t<shortdesc lang=\"C\">");
+ printf("%s",xml_parameters[i].description);
+ printf("</shortdesc>\n");
+ printf("\t</parameter>\n");
+ }
+ printf("%s\n","</parameters>");
+ printf("%s\n","</resource-agent>");
+}
+
int
main(int argc, char **argv)
{
@@ -1057,7 +1108,9 @@ main(int argc, char **argv)
char *pname = basename(argv[0]);
struct ipmi *i;
int timeout=DEFAULT_TIMEOUT;
- int cipher=-1;
+ int cipher=-1;
+ int print_final_status=1;
+ int translated_ret = -1;
memset(ip, 0, sizeof(ip));
memset(authtype, 0, sizeof(authtype));
@@ -1178,9 +1231,11 @@ main(int argc, char **argv)
snprintf(method, sizeof(method), "onoff");
if (strcasecmp(op, "off") && strcasecmp(op, "on") &&
- strcasecmp(op, "status") && strcasecmp(op, "reboot")) {
+ strcasecmp(op, "status") && strcasecmp(op, "reboot") &&
+ strcasecmp(op, "monitor") && strcasecmp(op, "list") &&
+ strcasecmp(op, "metadata")) {
fail_exit("operation must be 'on', 'off', 'status', "
- "or 'reboot'");
+ "'reboot', 'list', 'monitor' or 'metadata'");
}
if (strlen(authtype) &&
@@ -1226,47 +1281,69 @@ main(int argc, char **argv)
} else {
/* Original onoff method */
ret = ipmi_off(i);
- if (ret != 0)
+ translated_ret = (ret==0?ERR_OFF_SUCCESSFUL:ERR_OFF_FAIL);
+ if (ret != 0) {
goto out;
+ }
ret = ipmi_on(i);
}
} else if (!strcasecmp(op, "on")) {
printf("Powering on machine @ IPMI:%s...", ip);
fflush(stdout);
ret = ipmi_on(i);
-
+ translated_ret = (ret==0?ERR_ON_SUCCESSFUL:ERR_ON_FAIL);
} else if (!strcasecmp(op, "off")) {
printf("Powering off machine @ IPMI:%s...", ip);
fflush(stdout);
ret = ipmi_off(i);
- } else if (!strcasecmp(op, "status")) {
+ translated_ret = (ret==0?ERR_ON_SUCCESSFUL:ERR_ON_FAIL);
+ } else if (!strcasecmp(op, "status") || !strcasecmp(op, "monitor")) {
printf("Getting status of IPMI:%s...",ip);
fflush(stdout);
ret = ipmi_op(i, ST_STATUS, power_status);
switch(ret) {
case STATE_ON:
- printf("Chassis power = On\n");
+ if (!strcasecmp(op, "status"))
+ printf("Chassis power = On\n");
+ translated_ret = ERR_STATUS_ON;
ret = 0;
break;
case STATE_OFF:
- printf("Chassis power = Off\n");
+ if (!strcasecmp(op, "status"))
+ printf("Chassis power = Off\n");
+ translated_ret = ERR_STATUS_OFF;
ret = 0;
break;
default:
- printf("Chassis power = Unknown\n");
+ if (!strcasecmp(op, "status"))
+ printf("Chassis power = Unknown\n");
+ translated_ret = ERR_STATUS_FAIL;
ret = 1;
break;
}
+ } else if (!strcasecmp(op, "list")) {
+ printf("%s\n","N/A");
+ ret=0;
+ translated_ret = ERR_OK;
+ print_final_status=0;
+ } else if (!strcasecmp(op, "metadata")) {
+ print_xml_metadata(pname);
+ ret=0;
+ translated_ret = ERR_OK;
+ print_final_status=0;
}
out:
ipmi_destroy(i);
free(i);
- if (ret == 0)
- printf("Done\n");
- else
- printf("Failed\n");
- return ret;
+
+ if (print_final_status) {
+ if (ret == 0)
+ printf("Done\n");
+ else
+ printf("Failed\n");
+ }
+ return translated_ret;
}
#endif /* fence */
14 years
cluster: RHEL56 - fence-agents: Work around bad nss/nspr prototypes
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: d4ae5b0f197288fafe884046ba9d9cd1c9c556b0
Parent: c57d8c5a6b3ba804a0d3242fdbd9daeb9476b58d
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Wed Apr 21 11:35:28 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Wed Apr 21 11:35:28 2010 -0400
fence-agents: Work around bad nss/nspr prototypes
This patch allows fence_xvm[d] to compile with
nss/nspr installations which have bad prototypes.
Resolves: bz#575157
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
fence/agents/xvm/Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fence/agents/xvm/Makefile b/fence/agents/xvm/Makefile
index 4118e34..a8c8b56 100644
--- a/fence/agents/xvm/Makefile
+++ b/fence/agents/xvm/Makefile
@@ -28,7 +28,7 @@ INCLUDE=-I${top_srcdir}/include -I${top_srcdir}/config \
-I../../../cman/lib -I../../../ccs/lib -I/usr/include/libxml2
CFLAGS+=-DFENCE_RELEASE_NAME=\"${RELEASE}\" \
- -Wall -Werror -Wstrict-prototypes -Wshadow -ggdb -D_GNU_SOURCE
+ -Wall -Wstrict-prototypes -Wshadow -ggdb -D_GNU_SOURCE
LIBS+=-L../../../cman/lib -L../../../ccs/lib -L${libdir}/openais \
-L../../../dlm/lib -lnss3 -lxml2
14 years
cluster: the annotated tag cluster-3.0.11 has been created
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 47fff9d1993eddbffc4b0c7dd34b3af99607bbc9
Parent: 0000000000000000000000000000000000000000
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: 2010-04-21 07:04 +0000
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: 2010-04-21 07:04 +0000
annotated tag: cluster-3.0.11 has been created
at 47fff9d1993eddbffc4b0c7dd34b3af99607bbc9 (tag)
tagging 32dc73f5e8ed4a4266985905770a8ff4eee84dbe (commit)
replaces cluster-3.0.10
cluster-3.0.11 release
Abhijith Das (2):
libgfs2: fix build break caused by patch to bz 455300
gfs2_convert: Does not convert full gfs1 filesystems
Bob Peterson (1):
gfs2_fsck segfault when statfs system file is missing
Christine Caulfield (1):
cman: make libcman /dev/zero fd close-on-exec
David Teigland (1):
dlm_controld: don't log errors after disabling plocks
Fabio M. Di Nitto (2):
fence-agents: fix build with locales other than C
fence_ilo_mp: fix release version
Lon Hohberger (4):
Revert "resource-agents: Kill correct PIDs during force_unmount"
rgmanager: Kill processes correctly w/ force_unmount
rgmanager: Allow spaces in fs.sh mount points
rgmanager: Minor cleanups for file system agents
Marek 'marx' Grac (3):
fence_egenera: log file path should be absolute not relative
fence_ilo_mp: Proper error message instead of python traceback
fencing: Creating manual pages fails when default value is a list
14 years
cluster: STABLE3 - rgmanager: Minor cleanups for file system agents
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 32dc73f5e8ed4a4266985905770a8ff4eee84dbe
Parent: d258ba6948f1eeda3f813190b9da2728985978cd
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Tue Apr 20 18:52:05 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Tue Apr 20 18:52:05 2010 -0400
rgmanager: Minor cleanups for file system agents
- don't double-check if the mount point exists; once
is enough
- report an error if creation of the mount point fails
Resolves: rhbz#581533
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/resources/clusterfs.sh | 22 +++++++---------------
rgmanager/src/resources/fs.sh.in | 20 ++++++--------------
rgmanager/src/resources/netfs.sh | 8 +++++++-
3 files changed, 20 insertions(+), 30 deletions(-)
diff --git a/rgmanager/src/resources/clusterfs.sh b/rgmanager/src/resources/clusterfs.sh
index bb0acfd..f90f865 100644
--- a/rgmanager/src/resources/clusterfs.sh
+++ b/rgmanager/src/resources/clusterfs.sh
@@ -534,7 +534,13 @@ startFilesystem: Mount point $mp exists but is not a directory"
else
ocf_log info "\
startFilesystem: Creating mount point $mp for device $dev"
- mkdir -p $mp
+ mkdir -p "$mp"
+ ret_val=$?
+ if [ $ret_val -ne 0 ]; then
+ ocf_log err "\
+startFilesystem: Unable to create $mp. Error code: $ret_val"
+ return $OCF_ERR_GENERIC
+ fi
fi
#
@@ -593,20 +599,6 @@ Cannot mount $dev on $mp, the device or mount point is already in use!"
esac
#
- # Make sure the mount point exists.
- #
- if [ ! -d $mp ]; then
- rm -f $mp # rm in case its a plain file
- mkdir -p $mp # create the mount point
- ret_val=$?
- if [ $ret_val -ne 0 ]; then
- ocf_log err \
- "'mkdir -p $mp' failed, error=$ret_val"
- return $FAIL
- fi
- fi
-
- #
# Get the mount options, if they exist.
#
mount_options=""
diff --git a/rgmanager/src/resources/fs.sh.in b/rgmanager/src/resources/fs.sh.in
index 5a6348b..ffa721f 100644
--- a/rgmanager/src/resources/fs.sh.in
+++ b/rgmanager/src/resources/fs.sh.in
@@ -816,6 +816,12 @@ startFilesystem: Mount point $mp exists but is not a directory"
ocf_log err "\
startFilesystem: Creating mount point $mp for device $dev"
mkdir -p "$mp"
+ ret_val=$?
+ if [ $ret_val -ne 0 ]; then
+ ocf_log err "\
+startFilesystem: Unable to create $mp. Error code: $ret_val"
+ return $OCF_ERR_GENERIC
+ fi
fi
#
@@ -874,20 +880,6 @@ Cannot mount $dev on $mp, the device or mount point is already in use!"
esac
#
- # Make sure the mount point exists.
- #
- if [ ! -d $mp ]; then
- rm -f $mp # rm in case its a plain file
- mkdir -p $mp # create the mount point
- ret_val=$?
- if [ $ret_val -ne 0 ]; then
- ocf_log err \
- "'mkdir -p $mp' failed, error=$ret_val"
- return $FAIL
- fi
- fi
-
- #
# Get the mount options, if they exist.
#
mount_options=""
diff --git a/rgmanager/src/resources/netfs.sh b/rgmanager/src/resources/netfs.sh
index b85027a..bb749f7 100644
--- a/rgmanager/src/resources/netfs.sh
+++ b/rgmanager/src/resources/netfs.sh
@@ -386,7 +386,13 @@ startFilesystem: Mount point $mp exists but is not a directory"
else
ocf_log info "\
startFilesystem: Creating mount point $mp for $fullpath"
- mkdir -p $mp
+ mkdir -p "$mp"
+ ret_val=$?
+ if [ $ret_val -ne 0 ]; then
+ ocf_log err "\
+startFilesystem: Unable to create $mp. Error code: $ret_val"
+ return $OCF_ERR_GENERIC
+ fi
fi
#
14 years
cluster: STABLE3 - rgmanager: Allow spaces in fs.sh mount points
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: d258ba6948f1eeda3f813190b9da2728985978cd
Parent: 95fdebbfb7c62ac69b63e2b34d30fde9ecea4640
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Mon Apr 19 16:51:42 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Tue Apr 20 18:48:17 2010 -0400
rgmanager: Allow spaces in fs.sh mount points
Resolves: rhbz#582573
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/resources/fs.sh.in | 32 ++++++++++++++++----------------
1 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/rgmanager/src/resources/fs.sh.in b/rgmanager/src/resources/fs.sh.in
index adc66e3..5a6348b 100644
--- a/rgmanager/src/resources/fs.sh.in
+++ b/rgmanager/src/resources/fs.sh.in
@@ -747,12 +747,12 @@ enable_fs_quotas()
if [ $need_check -eq 1 ]; then
ocf_log info "Checking quota info in $mp"
- quotacheck -$quotaopts $mp
+ quotacheck -$quotaopts "$mp"
fi
ocf_log info "Enabling Quotas on $mp"
- ocf_log debug "quotaon -$quotaopts $mp"
- quotaon -$quotaopts $mp
+ ocf_log debug "quotaon -$quotaopts \"$mp\""
+ quotaon -$quotaopts "$mp"
rv=$?
if [ $rv -ne 0 ]; then
# Just a warning
@@ -815,7 +815,7 @@ startFilesystem: Mount point $mp exists but is not a directory"
else
ocf_log err "\
startFilesystem: Creating mount point $mp for device $dev"
- mkdir -p $mp
+ mkdir -p "$mp"
fi
#
@@ -835,7 +835,7 @@ startFilesystem: Creating mount point $mp for device $dev"
#
# See if the device is already mounted.
#
- isMounted $dev $mp
+ isMounted $dev "$mp"
case $? in
$YES) # already mounted
ocf_log debug "$dev already mounted"
@@ -855,7 +855,7 @@ startFilesystem: Creating mount point $mp for device $dev"
# function checks to see if either the device or mount point are in
# use somewhere else on the system.
#
- mountInUse $dev $mp
+ mountInUse $dev "$mp"
case $? in
$YES) # uh oh, someone is using the device or mount point
ocf_log err "\
@@ -954,7 +954,7 @@ Unknown file system type '$fstype' for device $dev. Assuming fsck is required."
#
ocf_log info "mounting $dev on $mp"
ocf_log debug "mount $fstype_option $mount_options $dev $mp"
- mount $fstype_option $mount_options $dev $mp
+ mount $fstype_option $mount_options $dev "$mp"
ret_val=$?
if [ $ret_val -ne 0 ]; then
ocf_log err "\
@@ -968,12 +968,12 @@ Unknown file system type '$fstype' for device $dev. Assuming fsck is required."
if [ $NFS_TRICKS -eq 0 ]; then
if [ "$OCF_RESKEY_nfslock" = "yes" ] || \
[ "$OCF_RESKEY_nfslock" = "1" ]; then
- mkdir -p $mp/.clumanager/statd
- notify_list_merge $mp/.clumanager/statd
+ mkdir -p "$mp"/.clumanager/statd
+ notify_list_merge "$mp"/.clumanager/statd
fi
fi
- enable_fs_quotas $opts $mp
+ enable_fs_quotas $opts "$mp"
return $SUCCESS
}
@@ -1050,7 +1050,7 @@ stop: Could not match $OCF_RESKEY_device with a real device"
# Unmount the device.
#
while [ ! "$done" ]; do
- isMounted $dev $mp
+ isMounted $dev "$mp"
case $? in
$NO)
ocf_log info "$dev is not mounted"
@@ -1065,12 +1065,12 @@ stop: Could not match $OCF_RESKEY_device with a real device"
quotaopts=$(quota_opts $OCF_RESKEY_options)
if [ -n "$quotaopts" ]; then
ocf_log debug "Turning off quotas for $mp"
- quotaoff -$quotaopts $mp &> /dev/null
+ quotaoff -$quotaopts "$mp" &> /dev/null
fi
ocf_log info "unmounting $mp"
- umount $mp
+ umount "$mp"
if [ $? -eq 0 ]; then
umount_failed=
done=$YES
@@ -1088,10 +1088,10 @@ stop: Could not match $OCF_RESKEY_device with a real device"
ocf_log warning \
"Dropping node-wide NFS locks"
pkill -KILL -x lockd
- mkdir -p $mp/.clumanager/statd
+ mkdir -p "$mp"/.clumanager/statd
# Copy out the notify list; our
# IPs are already torn down
- notify_list_store $mp/.clumanager/statd
+ notify_list_store "$mp"/.clumanager/statd
nfslock_reclaim=1
fi
else
@@ -1115,7 +1115,7 @@ stop: Could not match $OCF_RESKEY_device with a real device"
if [ $nfslock_reclaim -eq 1 ]; then
# If we have this flag set, do a full reclaim broadcast
- notify_list_broadcast $mp/.clumanager/statd
+ notify_list_broadcast "$mp"/.clumanager/statd
fi
if [ -n "$umount_failed" ]; then
14 years
cluster: STABLE3 - rgmanager: Kill processes correctly w/ force_unmount
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 95fdebbfb7c62ac69b63e2b34d30fde9ecea4640
Parent: 1343c79c50e8314299756a76d0ba52e2a3921590
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Wed Apr 14 17:29:54 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Tue Apr 20 18:36:46 2010 -0400
rgmanager: Kill processes correctly w/ force_unmount
The killMountProcesses function was written about 10 years ago.
It was designed to work with lsof or fuser, and to log messages
for each process killed. This is not a bad idea. The problem
is that parsing the output of either is and error-prone,
particularly when mountpoints are similar to other directories
on the system.
A far less error-prone method to cleaning up a mount point is to
use 'fuser -kvm' on it. Not only is this less error-prone, it's
a good bit faster at doing its job than iterating through output
in a shell script.
This patch makes force_unmount very reliable at killing the correct
processes, but we lose the logging functionality. It is a fair
trade-off because there have been several bugs in the
killMountProcesses function over the years which have caused several
problems.
Resolves: bz555901 bz582754
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/resources/clusterfs.sh | 113 ++----------------------------
rgmanager/src/resources/fs.sh.in | 121 ++------------------------------
rgmanager/src/resources/netfs.sh | 128 ++++------------------------------
3 files changed, 23 insertions(+), 339 deletions(-)
diff --git a/rgmanager/src/resources/clusterfs.sh b/rgmanager/src/resources/clusterfs.sh
index 0ccc93d..bb0acfd 100644
--- a/rgmanager/src/resources/clusterfs.sh
+++ b/rgmanager/src/resources/clusterfs.sh
@@ -484,113 +484,6 @@ isAlive()
#
-# killMountProcesses device mount_point
-#
-# Using lsof or fuser try to unmount the mount by killing of the processes
-# that might be keeping it busy.
-#
-killMountProcesses()
-{
- typeset -i ret=$SUCCESS
- typeset have_lsof=""
- typeset have_fuser=""
- typeset try
-
- if [ $# -ne 1 ]; then
- ocf_log err \
- "Usage: killMountProcesses mount_point"
- return $FAIL
- fi
-
- typeset mp=$1
-
- ocf_log notice "Forcefully unmounting $mp"
-
- #
- # Not all distributions have lsof. If not use fuser. If it
- # does, try both.
- #
- file=$(which lsof 2>/dev/null)
- if [ -f "$file" ]; then
- have_lsof=$YES
- fi
-
- file=$(which fuser 2>/dev/null)
- if [ -f "$file" ]; then
- have_fuser=$YES
- fi
-
- if [ -z "$have_lsof" -a -z "$have_fuser" ]; then
- ocf_log warn \
- "Cannot forcefully unmount $mp; cannot find lsof or fuser commands"
- return $FAIL
- fi
-
- for try in 1 2 3; do
- if [ -n "$have_lsof" ]; then
- #
- # Use lsof to free up mount point
- #
- while read command pid user
- do
- if [ -z "$pid" ]; then
- continue
- fi
-
- if [ $try -eq 1 ]; then
- ocf_log warn \
- "killing process $pid ($user $command $mp)"
- elif [ $try -eq 3 ]; then
- ocf_log crit \
- "Could not clean up mountpoint $mp"
- ret=$FAIL
- fi
-
- if [ $try -gt 1 ]; then
- kill -9 $pid
- else
- kill -TERM $pid
- fi
- done < <(lsof -b 2>/dev/null | \
- grep -E "$mp(/.*|)\$" | \
- awk '{print $1,$2,$3}' | \
- sort -u -k 1,3)
- elif [ -n "$have_fuser" ]; then
- #
- # Use fuser to free up mount point
- #
- while read command pid user
- do
- if [ -z "$pid" ]; then
- continue
- fi
-
- if [ $try -eq 1 ]; then
- ocf_log warn \
- "killing process $pid ($user $command $mp)"
- elif [ $try -eq 3 ]; then
- ocf_log crit \
- "Could not clean up mount point $mp"
- ret=$FAIL
- fi
-
- if [ $try -gt 1 ]; then
- kill -9 $pid
- else
- kill -TERM $pid
- fi
- done < <(fuser -vm $mp 2>&1 | \
- grep -v PID | \
- sed 's;^'$mp:';;' | \
- awk '{print $4,$2,$1}' | \
- sort -u -k 1,3)
- fi
- done
-
- return $ret
-}
-
-#
# startFilesystem
#
startFilesystem() {
@@ -871,7 +764,11 @@ stop: Could not match $OCF_RESKEY_device with a real device"
umount_failed=yes
if [ "$force_umount" ]; then
- killMountProcesses $mp
+ if [ $try -eq 1 ]; then
+ fuser -TERM -kvm "$mp"
+ else
+ fuser -kvm "$mp"
+ fi
fi
if [ $try -ge $max_tries ]; then
diff --git a/rgmanager/src/resources/fs.sh.in b/rgmanager/src/resources/fs.sh.in
index 1454295..adc66e3 100644
--- a/rgmanager/src/resources/fs.sh.in
+++ b/rgmanager/src/resources/fs.sh.in
@@ -680,114 +680,6 @@ isAlive()
#
-# killMountProcesses mount_point
-#
-# Using lsof or fuser try to unmount the mount by killing of the processes
-# that might be keeping it busy.
-#
-killMountProcesses()
-{
- typeset -i ret=$SUCCESS
- typeset have_lsof=""
- typeset have_fuser=""
- typeset try
-
- if [ $# -ne 1 ]; then
- ocf_log err \
- "Usage: killMountProcesses mount_point"
- return $FAIL
- fi
-
- typeset mp=$1
-
- ocf_log notice "Forcefully unmounting $mp"
-
- #
- # Not all distributions have lsof. If not use fuser. If it
- # does, try both.
- #
- file=$(which lsof 2>/dev/null)
- if [ -f "$file" ]; then
- have_lsof=$YES
- fi
-
- file=$(which fuser 2>/dev/null)
- if [ -f "$file" ]; then
- have_fuser=$YES
- fi
-
- if [ -z "$have_lsof" -a -z "$have_fuser" ]; then
- ocf_log warn \
- "Cannot forcefully unmount $mp; cannot find lsof or fuser commands"
- return $FAIL
- fi
-
- for try in 1 2 3; do
- if [ -n "$have_lsof" ]; then
- #
- # Use lsof to free up mount point
- #
- while read command pid user
- do
- if [ -z "$pid" ]; then
- continue
- fi
-
- if [ $try -eq 1 ]; then
- ocf_log warn \
- "killing process $pid ($user $command $mp)"
- elif [ $try -eq 3 ]; then
- ocf_log crit \
- "Could not clean up mountpoint $mp"
- ret=$FAIL
- fi
-
- if [ $try -gt 1 ]; then
- kill -9 $pid
- else
- kill -TERM $pid
- fi
- done < <(lsof -bn 2>/dev/null | \
- grep -E " $mp(/| |$)" | \
- awk '{print $1,$2,$3}' | \
- sort -u -k 1,3)
- elif [ -n "$have_fuser" ]; then
- #
- # Use fuser to free up mount point
- #
- while read command pid user
- do
- if [ -z "$pid" ]; then
- continue
- fi
-
- if [ $try -eq 1 ]; then
- ocf_log warn \
- "killing process $pid ($user $command $mp)"
- elif [ $try -eq 3 ]; then
- ocf_log crit \
- "Could not clean up mount point $mp"
- ret=$FAIL
- fi
-
- if [ $try -gt 1 ]; then
- kill -9 $pid
- else
- kill -TERM $pid
- fi
- done < <(fuser -vm $mp 2>&1 | \
- grep -v PID | \
- sed 's;^'$mp:';;' | \
- awk '{print $4,$2,$1}' | \
- sort -u -k 1,3)
- fi
- done
-
- return $ret
-}
-
-
-#
# Decide which quota options are enabled and return a string
# which we can pass to quotaon
#
@@ -1188,8 +1080,9 @@ stop: Could not match $OCF_RESKEY_device with a real device"
umount_failed=yes
if [ "$force_umount" ]; then
- killMountProcesses $mp
if [ $try -eq 1 ]; then
+ fuser -TERM -kvm "$mp"
+
if [ "$OCF_RESKEY_nfslock" = "yes" ] || \
[ "$OCF_RESKEY_nfslock" = "1" ]; then
ocf_log warning \
@@ -1201,15 +1094,11 @@ stop: Could not match $OCF_RESKEY_device with a real device"
notify_list_store $mp/.clumanager/statd
nfslock_reclaim=1
fi
+ else
+ fuser -kvm "$mp"
fi
fi
- if [ $try -ge $max_tries ]; then
- done=$YES
- else
- sleep $sleep_time
- let try=try+1
- fi
;;
*)
return $FAIL
@@ -1218,7 +1107,7 @@ stop: Could not match $OCF_RESKEY_device with a real device"
if [ $try -ge $max_tries ]; then
done=$YES
- elif [ "$done" -ne "$YES" ]; then
+ elif [ "$done" != "$YES" ]; then
sleep $sleep_time
let try=try+1
fi
diff --git a/rgmanager/src/resources/netfs.sh b/rgmanager/src/resources/netfs.sh
index 24b89ec..b85027a 100644
--- a/rgmanager/src/resources/netfs.sh
+++ b/rgmanager/src/resources/netfs.sh
@@ -339,113 +339,6 @@ isMounted () {
}
#
-# killMountProcesses mount_point
-#
-# Using lsof or fuser try to unmount the mount by killing of the processes
-# that might be keeping it busy.
-#
-killMountProcesses()
-{
- typeset -i ret=$SUCCESS
- typeset have_lsof=""
- typeset have_fuser=""
- typeset try
-
- if [ $# -ne 1 ]; then
- ocf_log err \
- "Usage: killMountProcesses mount_point"
- return $FAIL
- fi
-
- typeset mp=$1
-
- ocf_log notice "Forcefully unmounting $mp"
-
- #
- # Not all distributions have lsof. If not use fuser. If it
- # does, try both.
- #
- file=$(which lsof 2>/dev/null)
- if [ -f "$file" ]; then
- have_lsof=$YES
- fi
-
- file=$(which fuser 2>/dev/null)
- if [ -f "$file" ]; then
- have_fuser=$YES
- fi
-
- if [ -z "$have_lsof" -a -z "$have_fuser" ]; then
- ocf_log warn \
- "Cannot forcefully unmount $mp; cannot find lsof or fuser commands"
- return $FAIL
- fi
-
- for try in 1 2 3; do
- if [ -n "$have_lsof" ]; then
- #
- # Use lsof to free up mount point
- #
- while read command pid user
- do
- if [ -z "$pid" ]; then
- continue
- fi
-
- if [ $try -eq 1 ]; then
- ocf_log warn \
- "killing process $pid ($user $command $mp)"
- elif [ $try -eq 3 ]; then
- ocf_log crit \
- "Could not clean up mountpoint $mp"
- ret=$FAIL
- fi
-
- if [ $try -gt 1 ]; then
- kill -9 $pid
- else
- kill -TERM $pid
- fi
- done < <(lsof -w -bn 2>/dev/null | \
- grep -w -E "$mp(/.*|)\$" | \
- awk '{print $1,$2,$3}' | \
- sort -u -k 1,3)
- elif [ -n "$have_fuser" ]; then
- #
- # Use fuser to free up mount point
- #
- while read command pid user
- do
- if [ -z "$pid" ]; then
- continue
- fi
-
- if [ $try -eq 1 ]; then
- ocf_log warn \
- "killing process $pid ($user $command $mp)"
- elif [ $try -eq 3 ]; then
- ocf_log crit \
- "Could not clean up mount point $mp"
- ret=$FAIL
- fi
-
- if [ $try -gt 1 ]; then
- kill -9 $pid
- else
- kill -TERM $pid
- fi
- done < <(fuser -vm $mp 2>&1 | \
- grep -v PID | \
- sed 's;^'$mp:';;' | \
- awk '{print $4,$2,$1}' | \
- sort -u -k 1,3)
- fi
- done
-
- return $ret
-}
-
-#
# startNFSFilesystem
#
startNFSFilesystem() {
@@ -639,15 +532,20 @@ stopNFSFilesystem() {
umount_failed=yes
- if [ "$force_umount" ]; then
- killMountProcesses $mp
- fi
+ if [ "$force_umount" ]; then
+ if [ $try -eq 1 ]; then
+ fuser -TERM -kvm "$mp"
+ else
+ fuser -kvm "$mp"
+ fi
+ fi
- if [ $try -ge $max_tries ]; then
- done=$YES
- else
- sleep $sleep_time
- let try=try+1
+
+ if [ $try -ge $max_tries ]; then
+ done=$YES
+ else
+ sleep $sleep_time
+ let try=try+1
fi
;;
*)
14 years
cluster: STABLE3 - Revert "resource-agents: Kill correct PIDs during force_unmount"
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 1343c79c50e8314299756a76d0ba52e2a3921590
Parent: e525126429881a286149c04d140082b86dcf5339
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Wed Apr 14 15:41:52 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Tue Apr 20 18:36:46 2010 -0400
Revert "resource-agents: Kill correct PIDs during force_unmount"
This reverts commit c5f279928da14f72fac458bd2439b43ea95e66df.
The bug did not apply to STABLE3.
---
rgmanager/src/resources/fs.sh.in | 27 +++++++++++++--------------
1 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/rgmanager/src/resources/fs.sh.in b/rgmanager/src/resources/fs.sh.in
index b037796..1454295 100644
--- a/rgmanager/src/resources/fs.sh.in
+++ b/rgmanager/src/resources/fs.sh.in
@@ -691,7 +691,6 @@ killMountProcesses()
typeset have_lsof=""
typeset have_fuser=""
typeset try
- typeset command pid user line
if [ $# -ne 1 ]; then
ocf_log err \
@@ -728,30 +727,30 @@ killMountProcesses()
#
# Use lsof to free up mount point
#
- while read line
+ while read command pid user
do
- path=$(echo $line | awk '{for (i=9;i<NF+1;i++) {printf "%s ",$i};}')
- #if [ -z $(echo $path | grep -E "$mp(/| |$)") ]
- if [ -z $(echo $path | grep -E "^$mp/.*") ]; then
+ if [ -z "$pid" ]; then
continue
fi
- command=$(echo $line | awk '{print $1}')
- pid=$(echo $line | awk '{print $2}')
- user=$(echo $line | awk '{print $3}')
+
if [ $try -eq 1 ]; then
- ocf_log warn "killing process $pid ($user $command $mp)"
+ ocf_log warn \
+ "killing process $pid ($user $command $mp)"
elif [ $try -eq 3 ]; then
- ocf_log crit "Could not clean up mountpoint $mp"
- ret=$FAIL
+ ocf_log crit \
+ "Could not clean up mountpoint $mp"
+ ret=$FAIL
fi
+
if [ $try -gt 1 ]; then
kill -9 $pid
else
kill -TERM $pid
fi
- done< <(lsof -bn 2>/dev/null | \
- grep -E " $mp(/| |$)" | \
- sort -u -k 1,3)
+ done < <(lsof -bn 2>/dev/null | \
+ grep -E " $mp(/| |$)" | \
+ awk '{print $1,$2,$3}' | \
+ sort -u -k 1,3)
elif [ -n "$have_fuser" ]; then
#
# Use fuser to free up mount point
14 years
dlm: master - dlm_controld: don't log errors after disabling plocks
by David Teigland
Gitweb: http://git.fedorahosted.org/git/dlm.git?p=dlm.git;a=commitdiff;h=fae6ee39...
Commit: fae6ee3915d0d1ba3add3082ccd159955b120e45
Parent: fc714e99ee117288c3cc35e20cefb4d55df234ea
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Apr 13 15:40:55 2010 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Apr 20 17:06:20 2010 -0500
dlm_controld: don't log errors after disabling plocks
Once plocks are disabled due to bad checkpoint data, don't spam
the logs with irrelevant plock errors.
bz 582017
Signed-off-by: David Teigland <teigland(a)redhat.com>
---
group/dlm_controld/cpg.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/group/dlm_controld/cpg.c b/group/dlm_controld/cpg.c
index af7ac40..2eb3d65 100644
--- a/group/dlm_controld/cpg.c
+++ b/group/dlm_controld/cpg.c
@@ -1595,26 +1595,32 @@ static void deliver_cb(cpg_handle_t handle,
break;
case DLM_MSG_PLOCK:
+ if (ls->disable_plock)
+ break;
if (cfgd_enable_plock)
receive_plock(ls, hd, len);
- else if (!ls->disable_plock)
+ else
log_error("msg %d nodeid %d enable_plock %d",
hd->type, nodeid, cfgd_enable_plock);
break;
case DLM_MSG_PLOCK_OWN:
+ if (ls->disable_plock)
+ break;
if (cfgd_enable_plock && cfgd_plock_ownership)
receive_own(ls, hd, len);
- else if (!ls->disable_plock)
+ else
log_error("msg %d nodeid %d enable_plock %d owner %d",
hd->type, nodeid, cfgd_enable_plock,
cfgd_plock_ownership);
break;
case DLM_MSG_PLOCK_DROP:
+ if (ls->disable_plock)
+ break;
if (cfgd_enable_plock && cfgd_plock_ownership)
receive_drop(ls, hd, len);
- else if (!ls->disable_plock)
+ else
log_error("msg %d nodeid %d enable_plock %d owner %d",
hd->type, nodeid, cfgd_enable_plock,
cfgd_plock_ownership);
@@ -1622,18 +1628,22 @@ static void deliver_cb(cpg_handle_t handle,
case DLM_MSG_PLOCK_SYNC_LOCK:
case DLM_MSG_PLOCK_SYNC_WAITER:
+ if (ls->disable_plock)
+ break;
if (cfgd_enable_plock && cfgd_plock_ownership)
receive_sync(ls, hd, len);
- else if (!ls->disable_plock)
+ else
log_error("msg %d nodeid %d enable_plock %d owner %d",
hd->type, nodeid, cfgd_enable_plock,
cfgd_plock_ownership);
break;
case DLM_MSG_PLOCKS_STORED:
+ if (ls->disable_plock)
+ break;
if (cfgd_enable_plock)
receive_plocks_stored(ls, hd, len);
- else if (!ls->disable_plock)
+ else
log_error("msg %d nodeid %d enable_plock %d",
hd->type, nodeid, cfgd_enable_plock);
break;
14 years