cluster: RHEL4 - fence_scsi: replace open3 calls with qx commands
by rohara
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: eb8ab370049d458eae33773826b8f7ece31b21df
Parent: abf96e2fbe89852fa67e9c5120a0cbe4b9d8d090
Author: Ryan O'Hara <rohara(a)redhat.com>
AuthorDate: Wed Apr 7 11:26:43 2010 -0500
Committer: Ryan O'Hara <rohara(a)redhat.com>
CommitterDate: Wed Apr 7 11:26:43 2010 -0500
fence_scsi: replace open3 calls with qx commands
The open3 calls will block when the buffer becomes full, which causes
fence_scsi to block. This can occur if fence_scsi needs to process
several devices. All open3 calls should be replaced with qx commands,
which does not suffer from this problem. (BZ 545193)
Signed-off-by: Ryan O'Hara <rohara(a)redhat.com>
---
fence/agents/scsi/fence_scsi.pl | 134 ++++++++++-----------------------------
1 files changed, 33 insertions(+), 101 deletions(-)
diff --git a/fence/agents/scsi/fence_scsi.pl b/fence/agents/scsi/fence_scsi.pl
index 9c0a5c3..7ab621e 100755
--- a/fence/agents/scsi/fence_scsi.pl
+++ b/fence/agents/scsi/fence_scsi.pl
@@ -2,9 +2,17 @@
use Getopt::Std;
use XML::LibXML;
-use IPC::Open3;
use POSIX;
+my $ME = $0;
+
+END {
+ defined fileno STDOUT or return;
+ close STDOUT and return;
+ warn "$ME: failed to close standard output: $!\n";
+ $? ||= 1;
+}
+
my @device_list;
$_ = $0;
@@ -63,32 +71,23 @@ sub get_cluster_id
{
my $cluster_id;
- my ($in, $out, $err);
my $cmd = "cman_tool status";
-
- my $pid = open3($in, $out, $err, $cmd) or die "$!\n";
-
- waitpid($pid, 0);
+ my @out = qx { $cmd };
die "Unable to execute cman_tool.\n" if ($?>>8);
- while (<$out>)
+ foreach (@out)
{
chomp;
- my ($name, $value) = split(/\s*:\s*/, $_);
+ my ($param, $value) = split(/\s*:\s*/, $_);
- if ($name eq "Cluster ID")
- {
+ if ($param =~ /^cluster\s+id/i) {
$cluster_id = $value;
last;
}
}
- close($in);
- close($out);
- close($err);
-
print "[$pname]: get_cluster_id: cluster_id=$cluster_id\n" if $opt_v;
return $cluster_id;
@@ -121,32 +120,23 @@ sub get_host_id
{
my $host_id;
- my ($in, $out, $err);
my $cmd = "cman_tool status";
-
- my $pid = open3($in, $out, $err, $cmd) or die "$!\n";
-
- waitpid($pid, 0);
+ my @out = qx { $cmd };
die "Unable to execute cman_tool.\n" if ($?>>8);
- while (<$out>)
+ foreach (@out)
{
chomp;
- my ($name, $value) = split(/\s*:\s*/, $_);
+ my ($param, $value) = split(/\s*:\s*/, $_);
- if ($name eq "Node ID")
- {
+ if ($param =~ /^node\s+id/i) {
$host_id = $value;
last;
}
}
- close($in);
- close($out);
- close($err);
-
print "[$pname]: get_host_id: host_id=$host_id\n" if $opt_v;
return $host_id;
@@ -156,32 +146,23 @@ sub get_host_name
{
my $host_name;
- my ($in, $out, $err);
my $cmd = "cman_tool status";
-
- my $pid = open3($in, $out, $err, $cmd) or die "$!\n";
-
- waitpid($pid, 0);
+ my @out = qx { $cmd };
die "Unable to execute cman_tool.\n" if ($?>>8);
- while (<$out>)
+ foreach (@out)
{
chomp;
- my ($name, $value) = split(/\s*:\s*/, $_);
+ my ($param, $value) = split(/\s*:\s*/, $_);
- if ($name eq "Node name")
- {
+ if ($param =~ /^node\s+name/i) {
$host_name = $value;
last;
}
}
- close($in);
- close($out);
- close($err);
-
print "[$pname]: get_host_name: host_name=$host_name\n" if $opt_v;
return $host_name;
@@ -260,26 +241,23 @@ sub get_key_list
{
($dev) = @_;
- my ($in, $out, $err);
-
my $cmd = "sg_persist -d $dev -i -k";
- my $pid = open3($in, $out, $err, $cmd) or die "$!\n";
-
- waitpid($pid, 0);
+ my @out = qx { $cmd };
die "Unable to execute sg_persist.\n" if ($?>>8);
my %key_list;
- while (<$out>)
+ foreach (@out)
{
chomp;
+
if ($_ =~ /^\s*0x/)
{
s/^\s+0x//;
s/\s+$//;
- $key_list{$_} = 1;
+ $key_list{$_} = undef;
}
}
@@ -299,27 +277,19 @@ sub get_key_list
}
}
- close($in);
- close($out);
- close($err);
-
return %key_list;
}
sub get_scsi_devices
{
- my ($in, $out, $err);
-
my $cmd = "vgs --config 'global { locking_type = 0 }'" .
- " --noheadings --separator : -o vg_attr,pv_name 2> /dev/null";
+ " --noheadings --separator : -o vg_attr,pv_name";
- my $pid = open3($in, $out, $err, $cmd) or die "$!\n";
-
- waitpid($pid, 0);
+ my @out = qx { $cmd 2> /dev/null};
die "Unable to execute vgs.\n" if ($?>>8);
- while (<$out>)
+ foreach (@out)
{
chomp;
@@ -347,42 +317,14 @@ sub get_scsi_devices
$index++;
}
}
-
- close($in);
- close($out);
- close($err);
}
sub check_sg_persist
{
- my ($in, $out, $err);
my $cmd = "sg_persist -V";
- my $pid = open3($in, $out, $err, $cmd) or die "$!\n";
-
- waitpid($pid, 0);
+ my $out = qx { $cmd };
die "Unable to execute sg_persist.\n" if ($?>>8);
-
- close($in);
- close($out);
- close($err);
-}
-
-sub do_register
-{
- ($dev, $key) = @_;
-
- my ($in, $out, $err);
- my $cmd = "sg_persist -n -d $dev -o -G -S $key";
- my $pid = open3($in, $out, $err, $cmd) or die "$!\n";
-
- waitpid($pid, 0);
-
- die "Unable to execute sg_persist ($dev).\n" if ($?>>8);
-
- close($in);
- close($out);
- close($err);
}
sub fence_node
@@ -406,17 +348,13 @@ sub fence_node
print "[$pname]: unregister key 0x$node_key from device $dev\n";
}
- if (!$key_list{$host_key})
+ if (! exists $key_list{$host_key})
{
- do_register($dev, $host_key);
+ fail "Unable to perform fence operation.";
}
- if (!$key_list{$node_key})
+ if (! exists $key_list{$node_key})
{
- if ($opt_v)
- {
- print "[$pname]: key 0x$node_key is not registered with device $dev\n";
- }
next;
}
@@ -429,15 +367,9 @@ sub fence_node
$cmd = "sg_persist -n -d $dev -o -A -K $host_key -S $node_key -T 5";
}
- my $pid = open3($in, $out, $err, $cmd) or die "$!\n";
-
- waitpid($pid, 0);
+ my $out = qx { $cmd };
die "Unable to execute sg_persist ($dev).\n" if ($?>>8);
-
- close($in);
- close($out);
- close($err);
}
}
14 years
cluster: RHEL48 - rgmanager: fix netfsclient cache handling
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 1ebe0d71a2cc822e3c805da33b815af3e3393ef0
Parent: 04d4b4acc681f8af1a467ffac077e5898ad19592
Author: Juanjo Villaplana <villapla(a)si.uji.es>
AuthorDate: Thu Feb 26 10:33:34 2009 -0500
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Mon Apr 5 09:56:03 2010 -0400
rgmanager: fix netfsclient cache handling
Ensures correct removal of temporary file when client
caching is disabled.
Resolves: rhbz506152 rhbz572632
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/resources/nfsclient.sh | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/rgmanager/src/resources/nfsclient.sh b/rgmanager/src/resources/nfsclient.sh
index 70e69f1..7e8104a 100755
--- a/rgmanager/src/resources/nfsclient.sh
+++ b/rgmanager/src/resources/nfsclient.sh
@@ -413,13 +413,13 @@ status|monitor)
rv=$?
if [ $rv -eq 0 ]; then
- [ -z "$OCF_RESKEY_service_name" ] && rm -f $tmpfn
+ [ "$OCF_RESKEY_use_cache" = "1" ] || rm -f $tmpfn
exit 0
fi
declare OCF_RESKEY_target_tmp=$(clufindhostname -i "$OCF_RESKEY_target")
if [ $? -ne 0 ]; then
- [ -z "$OCF_RESKEY_service_name" ] && rm -f $tmpfn
+ [ "$OCF_RESKEY_use_cache" = "1" ] || rm -f $tmpfn
ocf_log err "nfsclient:$OCF_RESKEY_name is missing!"
exit 1
fi
@@ -428,7 +428,7 @@ status|monitor)
"^${OCF_RESKEY_path}[\t ]*.*${OCF_RESKEY_target_tmp}"
rv=$?
- [ -z "$OCF_RESKEY_service_name" ] && rm -f $tmpfn
+ [ "$OCF_RESKEY_use_cache" = "1" ] || rm -f $tmpfn
if [ $rv -eq 0 ]; then
exit 0
fi
14 years
cluster: RHEL48 - rgmanager: Kill correct PIDs during force_unmount
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 04d4b4acc681f8af1a467ffac077e5898ad19592
Parent: 23ac11b4d1ee465ab8cf377008740156ca1ebc25
Author: Shane Bradley <sbradley(a)redhat.com>
AuthorDate: Mon Feb 15 16:16:55 2010 -0500
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Mon Apr 5 09:55:35 2010 -0400
rgmanager: Kill correct PIDs during force_unmount
When stopping a service that contains a filesystem resource that is
managed by fs.sh, on a stop operation it can kill a process that is
not located on that mount point.
There was a couple of scenarios that would kill a process that was
not on that mount point when it was stopped:
These processes should not have been killed:
$ less /tmp/media/demo1/tmp.txt
$ less /tmp/test\ /media/demo1/tmp.txt
These processes was and should have been killed:
$ less /media/demo1/tmp.txt
Resolves: rhbz#555901 rhbz#572248
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/resources/fs.sh | 27 ++++++++++++++-------------
1 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/rgmanager/src/resources/fs.sh b/rgmanager/src/resources/fs.sh
index 5b3a3bc..46a5189 100755
--- a/rgmanager/src/resources/fs.sh
+++ b/rgmanager/src/resources/fs.sh
@@ -690,6 +690,7 @@ killMountProcesses()
typeset have_lsof=""
typeset have_fuser=""
typeset try
+ typeset command pid user line
if [ $# -ne 1 ]; then
ocf_log err \
@@ -726,30 +727,30 @@ killMountProcesses()
#
# Use lsof to free up mount point
#
- while read command pid user
+ while read line
do
- if [ -z "$pid" ]; then
+ 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
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(/.*|)\$" | \
- awk '{print $1,$2,$3}' | \
- sort -u -k 1,3)
+ done< <(lsof -bn 2>/dev/null | \
+ grep -E " $mp(/| |$)" | \
+ sort -u -k 1,3)
elif [ -n "$have_fuser" ]; then
#
# Use fuser to free up mount point
14 years
cluster: RHEL48 - magma-plugins: Handle other errors from dlm_lock
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 23ac11b4d1ee465ab8cf377008740156ca1ebc25
Parent: 19bb0c8920a245c58f1a96d8e37387f7d83d1f17
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Tue Feb 16 16:33:19 2010 -0500
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Mon Apr 5 09:55:00 2010 -0400
magma-plugins: Handle other errors from dlm_lock
If writing to the dlm lockspace file descriptor failed
due to delivery of a signal, libdlm and magma-plugins were
passing EINTR back up back up to the caller instead of
retrying the lock or unlock request like they should have.
Additionally, when any error except EAGAIN occurred, we
were overwriting errno with the value of lksb->sb_status,
which was always EINPROG (65539), causing the caller to
have an incorrect errno value.
Resolves: rhbz#294491 rhbz#572792
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
magma-plugins/sm/sm.c | 42 +++++++++++++++++++++++++++++++-----------
1 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/magma-plugins/sm/sm.c b/magma-plugins/sm/sm.c
index 666bb4f..3503d16 100644
--- a/magma-plugins/sm/sm.c
+++ b/magma-plugins/sm/sm.c
@@ -36,7 +36,7 @@
#include <sys/select.h>
#include <sys/stat.h>
-#define MODULE_DESCRIPTION "CMAN/SM Plugin v1.1.7.6"
+#define MODULE_DESCRIPTION "CMAN/SM Plugin v1.1.7.7"
#define MODULE_AUTHOR "Lon Hohberger"
#define DLM_LS_NAME "Magma"
@@ -571,12 +571,18 @@ _dlm_lock(sm_priv_t *p, int mode, struct dlm_lksb *lksb, int options,
int ret;
/* Ok, we have the NL lock. Now convert it. */
- ret = dlm_ls_lock(p->ls, mode, lksb, options,
+ /* Check for EINTR returned from write() in libdlm.c */
+ do {
+ ret = dlm_ls_lock(p->ls, mode, lksb, options,
resource, strlen(resource), 0, ast_function,
lksb, NULL, NULL);
- if (ret < 0)
- return -1;
+ if (ret < 0) {
+ if (errno == EINTR)
+ continue;
+ return -1;
+ }
+ } while (0);
while (lksb->sb_status == EINPROG) {
if (wait_for_dlm_event(p->ls) < 0) {
@@ -645,13 +651,18 @@ _dlm_unlock(sm_priv_t *p, struct dlm_lksb *lksb)
{
int ret;
- ret = dlm_ls_unlock(p->ls, lksb->sb_lkid, 0, lksb, NULL);
+ /* Check for EINTR returned from write() in libdlm.c */
+ do {
+ ret = dlm_ls_unlock(p->ls, lksb->sb_lkid, 0, lksb, NULL);
- if (ret != 0)
- return ret;
+ if (ret < 0) {
+ if (errno == EINTR)
+ continue;
+ return -1;
+ }
+ } while (0);
/* lksb->sb_status should be EINPROG at this point */
-
while (lksb->sb_status == EINPROG) {
if (wait_for_dlm_event(p->ls) < 0) {
if (lksb->sb_status == EINPROG)
@@ -799,7 +810,7 @@ sm_lock(cluster_plugin_t *self,
the CLK_CONVERT flag, then assume it's a previous lksb with
a held lock. */
if ((flags & CLK_CONVERT) && *lockpp) {
- lksb = (struct lksb *)(*lockpp);
+ lksb = (struct dlm_lksb *)(*lockpp);
options |= LKF_CONVERT;
} else {
lksb = malloc(sz);
@@ -838,8 +849,17 @@ sm_lock(cluster_plugin_t *self,
errno = EAGAIN;
return -1;
default:
- fprintf(stderr, "_dlm_lock: %d / %d\n", ret, errno);
- ret = lksb->sb_status;
+ /* Other error conditions: Pass back to caller.
+ * Note that 'ret' is still the indicator for a
+ * successful call to dlm_ls_lock. So, in the
+ * successful case, we want to pass the
+ * lock state back, otherwise errno in the event
+ * of a failed call. */
+ if (ret == 0) {
+ ret = lksb->sb_status;
+ } else {
+ ret = errno;
+ }
free(lksb);
errno = ret;
return -1;
14 years
cluster: STABLE3 - fencing: Remove 'ipport' option from WTI fence agent
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: d443af4fa07c64dd50dae4ea771c8f93bfd7cba6
Parent: f6994d1db1688140ae011c733efdbaa0af6808fb
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Fri Apr 2 14:04:49 2010 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Fri Apr 2 14:04:49 2010 +0200
fencing: Remove 'ipport' option from WTI fence agent
WTI devices do not support change of default TCP/IP ports so this
option is useless for them. Option was not working properly because
there is a non-standard login process used for these devices.
---
fence/agents/wti/fence_wti.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
index 92b362a..bc25f26 100644
--- a/fence/agents/wti/fence_wti.py
+++ b/fence/agents/wti/fence_wti.py
@@ -76,7 +76,7 @@ def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
"cmd_prompt", "secure", "identity_file", "port", "no_login", "no_password",
- "test", "separator", "inet4_only", "inet6_only", "ipport",
+ "test", "separator", "inet4_only", "inet6_only",
"power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
14 years
fence-agents: master - fence_wti: Remove ipport option
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/fence-agents.git?p=fence-agents.git;a=com...
Commit: 3be82d287b4212bfca3db679983b8687746417ef
Parent: fa9d0561d813b2d2002623e0aad665a5949fcc59
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Fri Apr 2 14:00:08 2010 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Fri Apr 2 14:00:08 2010 +0200
fence_wti: Remove ipport option
WTI devices do not support change of default TCP/IP ports so this option
is useless. It is not working correctly as there is a separate login
process for WTI devices.
---
fence/agents/wti/fence_wti.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
index 3ece06e..e8f63ec 100644
--- a/fence/agents/wti/fence_wti.py
+++ b/fence/agents/wti/fence_wti.py
@@ -76,7 +76,7 @@ def main():
device_opt = [ "help", "version", "agent", "quiet", "verbose", "debug",
"action", "ipaddr", "login", "passwd", "passwd_script",
"cmd_prompt", "secure", "identity_file", "port", "no_login", "no_password",
- "test", "separator", "inet4_only", "inet6_only", "ipport",
+ "test", "separator", "inet4_only", "inet6_only",
"power_timeout", "shell_timeout", "login_timeout", "power_wait" ]
atexit.register(atexit_handler)
14 years