All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH] fence_scsi: remove unlink of fence_scsi.dev file
@ 2011-09-27 22:21 Ryan O'Hara
  2011-09-28  5:31 ` Fabio M. Di Nitto
  0 siblings, 1 reply; 2+ messages in thread
From: Ryan O'Hara @ 2011-09-27 22:21 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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

Signed-off-by: Ryan O'Hara <rohara@redhat.com>
---
 fence/agents/scsi/fence_scsi.pl |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/fence/agents/scsi/fence_scsi.pl b/fence/agents/scsi/fence_scsi.pl
index 93f5056..87a599c 100644
--- a/fence/agents/scsi/fence_scsi.pl
+++ b/fence/agents/scsi/fence_scsi.pl
@@ -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;
-- 
1.7.3.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-09-28  5:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-27 22:21 [Cluster-devel] [PATCH] fence_scsi: remove unlink of fence_scsi.dev file Ryan O'Hara
2011-09-28  5:31 ` Fabio M. Di Nitto

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.