]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephfs/test_client_limits.py: invalidate kernel dcache according to client_cache_size
authorYan, Zheng <zyan@redhat.com>
Wed, 13 May 2015 03:17:53 +0000 (11:17 +0800)
committerYan, Zheng <zyan@redhat.com>
Wed, 13 May 2015 06:40:28 +0000 (14:40 +0800)
Signed-off-by: Yan, Zheng <zyan@redhat.com>
tasks/cephfs/fuse_mount.py
tasks/cephfs/test_client_limits.py

index c0fbcde4b2897a1fa3361d51ac88513a51afd612..a655fa607dc3fe1e3767c20fb42879c9a83f4668 100644 (file)
@@ -340,3 +340,13 @@ print find_socket("{client_name}")
         """
         status = self._admin_socket(['status'])
         return status['osd_epoch'], status['osd_epoch_barrier']
+
+    def get_dentry_count(self):
+        """
+        Return 2-tuple of dentry_count, dentry_pinned_count
+        """
+        status = self._admin_socket(['status'])
+        return status['dentry_count'], status['dentry_pinned_count']
+
+    def set_cache_size(self, size):
+        return self._admin_socket(['config', 'set', 'client_cache_size', str(size)])
index decc6a86ba27bb0ba39e531088a5525dad478c1d..f415ed82efca467165df7e206d424f1b4d470d7e 100644 (file)
@@ -5,11 +5,13 @@ exceed the limits of how many caps/inodes they should hold.
 """
 
 import logging
+from textwrap import dedent
 from unittest import SkipTest
 from teuthology.orchestra.run import CommandFailedError
 from tasks.cephfs.cephfs_test_case import CephFSTestCase
-
 from tasks.cephfs.fuse_mount import FuseMount
+import os
+import time
 
 
 log = logging.getLogger(__name__)
@@ -169,3 +171,37 @@ class TestClientLimits(CephFSTestCase):
 
         # Wait for the health warnings. Assume mds can handle 10 request per second at least
         self.wait_for_health("failing to advance its oldest_client_tid", max_requests / 10)
+
+    def test_client_cache_size(self):
+        """
+        check if client invalidate kernel dcache according to its cache size config
+        """
+
+        # The debug hook to inject the failure only exists in the fuse client
+        if not isinstance(self.mount_a, FuseMount):
+            raise SkipTest("Require FUSE client to inject client release failure")
+
+        dir_path = os.path.join(self.mount_a.mountpoint, "testdir")
+
+        mkdir_script = dedent("""
+            import os
+            os.mkdir("{path}")
+            for n in range(0, {num_dirs}):
+                os.mkdir("{path}/dir{{0}}".format(n))
+            """);
+
+        num_dirs = 1000
+        self.mount_a.run_python(mkdir_script.format(path=dir_path, num_dirs=num_dirs))
+        self.mount_a.run_shell(["sync"])
+
+        dentry_count, dentry_pinned_count = self.mount_a.get_dentry_count();
+        self.assertGreaterEqual(dentry_count, num_dirs);
+        self.assertGreaterEqual(dentry_pinned_count, num_dirs);
+
+        cache_size = num_dirs / 10;
+        self.mount_a.set_cache_size(cache_size);
+        time.sleep(30);
+
+        dentry_count, dentry_pinned_count =  self.mount_a.get_dentry_count();
+        self.assertLessEqual(dentry_count, cache_size);
+        self.assertLessEqual(dentry_pinned_count, cache_size);