]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: add file/filesystem sync crash test case 46496/head
authorXiubo Li <xiubli@redhat.com>
Thu, 14 Apr 2022 03:50:19 +0000 (11:50 +0800)
committerXiubo Li <xiubli@redhat.com>
Thu, 2 Jun 2022 04:41:21 +0000 (12:41 +0800)
This is one test case for the possible kernel crash bug when doing
the file sync or filesystem sync.

Fixes: https://tracker.ceph.com/issues/55329
Signed-off-by: Xiubo Li <xiubli@redhat.com>
(cherry picked from commit cd3e903b0c525c7946794b5fbf002da482b3b4bc)

qa/tasks/cephfs/test_misc.py

index 5fd6b94117399c97187667070e0b6877dab038a7..e819dbbe19c973ad1bf88663fdb4d37899830294 100644 (file)
@@ -4,6 +4,7 @@ from tasks.cephfs.fuse_mount import FuseMount
 from tasks.cephfs.cephfs_test_case import CephFSTestCase
 from teuthology.exceptions import CommandFailedError
 from textwrap import dedent
+from threading import Thread
 import errno
 import platform
 import time
@@ -293,6 +294,71 @@ class TestMisc(CephFSTestCase):
         dir_path = "file_sync_do_not_wait_mdlog_testdir"
         self._test_sync_stuck_for_around_5s(dir_path, True)
 
+    def test_file_filesystem_sync_crash(self):
+        """
+        To check whether the kernel crashes when doing the file/filesystem sync.
+        """
+
+        stop_thread = False
+        dir_path = "file_filesystem_sync_crash_testdir"
+        self.mount_a.run_shell(["mkdir", dir_path])
+
+        def mkdir_rmdir_thread(mount, path):
+            #global stop_thread
+
+            log.info(" mkdir_rmdir_thread starting...")
+            num = 0
+            while not stop_thread:
+                n = num
+                m = num
+                for __ in range(10):
+                    mount.run_shell(["mkdir", os.path.join(path, f"{n}")])
+                    n += 1
+                for __ in range(10):
+                    mount.run_shell(["rm", "-rf", os.path.join(path, f"{m}")])
+                    m += 1
+                num += 10
+            log.info(" mkdir_rmdir_thread stopped")
+
+        def filesystem_sync_thread(mount, path):
+            #global stop_thread
+
+            log.info(" filesystem_sync_thread starting...")
+            while not stop_thread:
+                mount.run_shell(["sync"])
+            log.info(" filesystem_sync_thread stopped")
+
+        def file_sync_thread(mount, path):
+            #global stop_thread
+
+            log.info(" file_sync_thread starting...")
+            pyscript = dedent("""
+                    import os
+
+                    path = "{path}"
+                    dfd = os.open(path, os.O_DIRECTORY)
+                    os.fsync(dfd)
+                    os.close(dfd)
+                """.format(path=path))
+
+            while not stop_thread:
+                mount.run_shell(['python3', '-c', pyscript])
+            log.info(" file_sync_thread stopped")
+
+        td1 = Thread(target=mkdir_rmdir_thread, args=(self.mount_a, dir_path,))
+        td2 = Thread(target=filesystem_sync_thread, args=(self.mount_a, dir_path,))
+        td3 = Thread(target=file_sync_thread, args=(self.mount_a, dir_path,))
+
+        td1.start()
+        td2.start()
+        td3.start()
+        time.sleep(1200) # run 20 minutes
+        stop_thread = True
+        td1.join()
+        td2.join()
+        td3.join()
+        self.mount_a.run_shell(["rm", "-rf", dir_path])
+
 
 class TestCacheDrop(CephFSTestCase):
     CLIENTS_REQUIRED = 1