<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffcc" text="#000066">
<tt>Coly,<br>
<br>
Can you do just one modification? Make the script accept at least the
directory as argument and make $file be created in the specified
directory. If no directory is passed, fail the script. <br>
<br>
Everything else looks fine.<br>
</tt>
<pre class="moz-signature" cols="72">Regards,

Marcos Eduardo Matsunaga

Oracle USA
Linux Engineering

“The statements and opinions expressed here are my own and do not
necessarily represent those of Oracle Corporation.”
</pre>
<br>
<br>
Coly Li wrote:
<blockquote cite="mid:4942338C.4030105@suse.de" type="cite">
  <pre wrap="">This script is initialized by Sunil, to verify lockres mastery race in flock(). For further
information of the lockres mastery race issue, read Novell bugzilla page:
<a class="moz-txt-link-freetext" href="https://bugzilla.novell.com/show_bug.cgi?id=425491">https://bugzilla.novell.com/show_bug.cgi?id=425491</a>

Sunil, Marcos and Tristan, could you kindly give me a SOB ?

Signed-off-by: Coly Li <a class="moz-txt-link-rfc2396E" href="mailto:coly.li@suse.de">&lt;coly.li@suse.de&gt;</a>
---
 programs/flock_tests/Makefile                 |    2 +-
 programs/flock_tests/concurrent_flock_test.pl |   33 +++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/programs/flock_tests/Makefile b/programs/flock_tests/Makefile
index 8b6bc5c..82659ec 100644
--- a/programs/flock_tests/Makefile
+++ b/programs/flock_tests/Makefile
@@ -15,7 +15,7 @@ DIST_FILES = $(SOURCES)

 BIN_PROGRAMS = flock_unit_test

-BIN_EXTRA = run_flock_unit_test.py
+BIN_EXTRA = run_flock_unit_test.py concurrent_flock_test.pl

 flock_unit_test: $(OBJECTS)
         $(LINK)
diff --git a/programs/flock_tests/concurrent_flock_test.pl
b/programs/flock_tests/concurrent_flock_test.pl
new file mode 100644
index 0000000..ac45dfc
--- /dev/null
+++ b/programs/flock_tests/concurrent_flock_test.pl
@@ -0,0 +1,33 @@
+#!/usr/bin/perl
+/* the perl script encloses the 20 fork loop into another loop that changes the
+ * filename. To startwith, touch 5000 files(test.flock%d). umount and mount
+ * again. This will drop the caches. Now before running any ls, run flock.pl.
+ * It will spawn 20 processes to flock() each file and wait till the 20 forks
+ * have exited before letting loose another 20 for the next file. (Makesure
+ * you have another node or two or more that have just mounted that volume.).
+ */
+
+use warnings;
+use Fcntl ':flock';
+
+$| = 1;
+
+for (my $y = 0; $y &lt; 5000; $y ++) {
+        /* modify path here for your environment */
+        $file = '/ocfs2/test.lock' . $y;
+
+        printf "[%s] %s\n", $$, $file;
+
+        for (my $x = 0; $x &lt; 20; $x ++) {
+                my $pid = fork();
+                if ($pid == 0) {
+                        my $fh;
+                        open($fh, "&gt;&gt; $file") or die("Can't open '$file': $!");
+                        printf "[%s] lock %s: %s\n", $$, $file,
+                        flock($fh, LOCK_EX) ? 'done' : $!;
+                        close($fh);
+                        exit(0);
+                }
+        }
+        while (wait &gt; 0) { ; }
+}

  </pre>
</blockquote>
</body>
</html>