]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/workunits/fs/misc: fix filelock_interrupt.py
authorYan, Zheng <zyan@redhat.com>
Mon, 2 Mar 2015 13:04:25 +0000 (21:04 +0800)
committerGreg Farnum <gfarnum@redhat.com>
Fri, 1 May 2015 17:37:16 +0000 (10:37 -0700)
Handle the case that kernel does not support fcntl.F_OFD_SETLK.
Also fix the code that checks if fnctl fails with errno == EINTR.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
(cherry picked from commit 4ececa3dc4a21b98f61a592da9e2be60a0d71625)
Reviewed-by: Greg Farnum <gfarnum@redhat.com>
qa/workunits/fs/misc/filelock_interrupt.py

index 386fbd7163541f80027624b2b820a13586e129ea..a17fa39e9dc621ffe242525660f8a36e264ea95f 100755 (executable)
@@ -30,15 +30,22 @@ def main():
     try:
         fcntl.flock(f2, fcntl.LOCK_EX)
     except IOError, e:
-        if e.errno == errno.EINTR:
-            pass
+        if e.errno != errno.EINTR:
+            raise
     else:
         raise RuntimeError("expect flock to block")
 
     fcntl.flock(f1, fcntl.LOCK_UN)
 
     lockdata = struct.pack('hhllhh', fcntl.F_WRLCK, 0, 0, 10, 0, 0)
-    fcntl.fcntl(f1, fcntl.F_OFD_SETLK, lockdata)
+    try:
+        fcntl.fcntl(f1, fcntl.F_OFD_SETLK, lockdata)
+    except IOError, e:
+        if e.errno != errno.EINVAL:
+            raise
+        else:
+            print 'kernel does not support fcntl.F_OFD_SETLK'
+            return
 
     lockdata = struct.pack('hhllhh', fcntl.F_WRLCK, 0, 10, 10, 0, 0)
     fcntl.fcntl(f2, fcntl.F_OFD_SETLK, lockdata)
@@ -52,8 +59,8 @@ def main():
         lockdata = struct.pack('hhllhh', fcntl.F_WRLCK, 0, 0, 0, 0, 0)
         fcntl.fcntl(f2, fcntl.F_OFD_SETLKW, lockdata)
     except IOError, e:
-        if e.errno == errno.EINTR:
-            pass
+        if e.errno != errno.EINTR:
+            raise
     else:
         raise RuntimeError("expect posix lock to block")