fence_scsi: remove unlink of fence_scsi.dev file
PATCH 1/1 fence_scsi: remove unlink of fence_scsi.dev file
This patch removes the call to unlink the fence_scsi.dev file during unfencing (action=on). Instead of unlinking the file, check to see if the current device is already in the fence_scsi.dev file before writing it to the file. Note that since this file exists in /var/run/cluster directory, it should be removed on reboot.
Resolves: rhbz#741339
--- fence/agents/scsi/fence_scsi.pl | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-)
fence/agents/scsi/fence_scsi.pl +11 -3
@@ -41,7 +41,6 @@ sub do_action_on ($@) my $self = (caller(0))[3]; my ($node_key, @devices) = @_; - dev_unlink (); key_write ($node_key); foreach $dev (@devices) {
@@ -369,8 +368,17 @@ sub dev_write ($) mkpath ("/var/run/cluster"); } - open (\*FILE, ">>$file") or die "$!\n"; - print FILE "$dev\n"; + open (\*FILE, "+>>$file") or die "$!\n"; + + ## since the file is opened for read, write and append, + ## we need to seek to the beginning of the file before grep. + + seek (FILE, 0, 0); + + if (! grep { /^$dev$/ } <FILE>) { + print FILE "$dev\n"; + } + close (FILE); return;
Signature · 1 line
1.7.3.4
PATCH 1/1 fence_scsi: remove unlink of fence_scsi.dev file
Oh cool! that was a nice and quick fix for the BZ.
ACK for upstream/master/RHEl, but please hold the cherry pick to RHEL till next tuesday.
Thanks
Fabio
Quoted 45 lines · Ryan O'Hara
This patch removes the call to unlink the fence_scsi.dev file during unfencing (action=on). Instead of unlinking the file, check to see if the current device is already in the fence_scsi.dev file before writing it to the file. Note that since this file exists in
/var/run/clusterdirectory, it should be removed on reboot.Resolves: rhbz#741339
Signed-off-by Ryan O'Hara <[email protected]>--- fence/agents/scsi/fence_scsi.pl | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-)fence/agents/scsi/fence_scsi.pl +11
-3@@ -41,7 +41,6 @@ sub do_action_on ($@) my $self = (caller(0))[3]; my ($node_key, @devices) = @_; - dev_unlink (); key_write ($node_key); foreach $dev (@devices) {@@ -369,8 +368,17 @@ sub dev_write ($) mkpath ("/var/run/cluster"); } - open (\*FILE, ">>$file") or die "$!\n"; - print FILE "$dev\n"; + open (\*FILE, "+>>$file") or die "$!\n"; + + ## since the file is opened for read, write and append, + ## we need to seek to the beginning of the file before grep. + + seek (FILE, 0, 0); + + if (! grep { /^$dev$/ } <FILE>) { + print FILE "$dev\n"; + } + close (FILE); return;