]> git.proxmox.com Git - ceph.git/blobdiff - ceph/qa/tasks/cephfs/mount.py
update sources to v12.1.0
[ceph.git] / ceph / qa / tasks / cephfs / mount.py
index 5bef25ca66276217953f5c0516779c07cba74a10..4f96e6cdc21742c70ebb1450c37e8148354f5fb6 100644 (file)
@@ -230,11 +230,31 @@ class CephFSMount(object):
 
         pyscript = dedent(script_builder).format(path=path)
 
-        log.info("lock file {0}".format(basename))
+        log.info("lock_background file {0}".format(basename))
         rproc = self._run_python(pyscript)
         self.background_procs.append(rproc)
         return rproc
 
+    def lock_and_release(self, basename="background_file"):
+        assert(self.is_mounted())
+
+        path = os.path.join(self.mountpoint, basename)
+
+        script = """
+            import time
+            import fcntl
+            import struct
+            f1 = open("{path}-1", 'w')
+            fcntl.flock(f1, fcntl.LOCK_EX)
+            f2 = open("{path}-2", 'w')
+            lockdata = struct.pack('hhllhh', fcntl.F_WRLCK, 0, 0, 0, 0, 0)
+            fcntl.fcntl(f2, fcntl.F_SETLK, lockdata)
+            """
+        pyscript = dedent(script).format(path=path)
+
+        log.info("lock_and_release file {0}".format(basename))
+        return self._run_python(pyscript)
+
     def check_filelock(self, basename="background_file", do_flock=True):
         assert(self.is_mounted())
 
@@ -436,36 +456,6 @@ class CephFSMount(object):
         self._kill_background(p)
         self.background_procs.remove(p)
 
-    def spam_dir_background(self, path):
-        """
-        Create directory `path` and do lots of metadata operations
-        in it until further notice.
-        """
-        assert(self.is_mounted())
-        abs_path = os.path.join(self.mountpoint, path)
-
-        pyscript = dedent("""
-            import sys
-            import time
-            import os
-
-            abs_path = "{abs_path}"
-
-            if not os.path.exists(abs_path):
-                os.makedirs(abs_path)
-
-            n = 0
-            while True:
-                file_path = os.path.join(abs_path, "tmp%d" % n)
-                f = open(file_path, 'w')
-                f.close()
-                n = n + 1
-            """).format(abs_path=abs_path)
-
-        rproc = self._run_python(pyscript)
-        self.background_procs.append(rproc)
-        return rproc
-
     def get_global_id(self):
         raise NotImplementedError()