]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tasks/cephfs/mount: use seperate for testing flock and posix lock
authorYan, Zheng <zyan@redhat.com>
Thu, 6 Nov 2014 08:01:50 +0000 (16:01 +0800)
committerYan, Zheng <zyan@redhat.com>
Fri, 7 Nov 2014 01:07:27 +0000 (09:07 +0800)
Old version libfuse treats both flock and posix lock requests as posix
lock request. This is a workaround for the bug.

Fixes: #9995
Signed-off-by: Yan, Zheng <zyan@redhat.com>
tasks/cephfs/mount.py
tasks/mds_client_recovery.py

index 57f9cb30064b6269ad70656f28886c1efe797b3a..cf44ed7a8ab441bdd08fa457fc60542470e2edab 100644 (file)
@@ -160,10 +160,12 @@ class CephFSMount(object):
             import fcntl
             import struct
 
-            f = open("{path}", 'w')
-            fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
+            f1 = open("{path}-1", 'w')
+            fcntl.flock(f1, fcntl.LOCK_EX | fcntl.LOCK_NB)
+
+            f2 = open("{path}-2", 'w')
             lockdata = struct.pack('hhllhh', fcntl.F_WRLCK, 0, 0, 0, 0, 0)
-            fcntl.fcntl(f, fcntl.F_SETLK, lockdata)
+            fcntl.fcntl(f2, fcntl.F_SETLK, lockdata)
             while True:
                 time.sleep(1)
             """).format(path=path)
@@ -183,22 +185,24 @@ class CephFSMount(object):
             import errno
             import struct
 
-            f = open("{path}", 'r')
+            f1 = open("{path}-1", 'r')
             try:
-                fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
+                fcntl.flock(f1, fcntl.LOCK_EX | fcntl.LOCK_NB)
             except IOError, e:
                 if e.errno == errno.EAGAIN:
                     pass
             else:
-                raise RuntimeError("flock on file {path} not found")
+                raise RuntimeError("flock on file {path}-1 not found")
+
+            f2 = open("{path}-2", 'r')
             try:
                 lockdata = struct.pack('hhllhh', fcntl.F_WRLCK, 0, 0, 0, 0, 0)
-                fcntl.fcntl(f, fcntl.F_SETLK, lockdata)
+                fcntl.fcntl(f2, fcntl.F_SETLK, lockdata)
             except IOError, e:
                 if e.errno == errno.EAGAIN:
                     pass
             else:
-                raise RuntimeError("posix lock on file {path} not found")
+                raise RuntimeError("posix lock on file {path}-2 not found")
             """).format(path=path)
 
         log.info("check lock on file {0}".format(basename))
index d92c0a9aa8a31b33e9ee2d20e478f8037d2b0e11..ea9541f2c5c62e78ad18794b89d0b62c451d5c27 100644 (file)
@@ -335,7 +335,7 @@ class TestClientRecovery(CephFSTestCase):
         # =====================================
         lock_holder = self.mount_a.lock_background()
 
-        self.mount_b.wait_for_visible();
+        self.mount_b.wait_for_visible("background_file-2");
         self.mount_b.check_filelock();
 
         self.fs.mds_stop()