]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: enable dynamic debug support to kclient 38752/head
authorXiubo Li <xiubli@redhat.com>
Mon, 4 Jan 2021 05:26:19 +0000 (13:26 +0800)
committerXiubo Li <xiubli@redhat.com>
Wed, 15 Sep 2021 01:31:04 +0000 (09:31 +0800)
Add a 'kmount_count' counter in ctx to make sure the dynamic debug
log won't be disabled until the last kernel mounter is unmounted.

Fixes: https://tracker.ceph.com/issues/48736
Signed-off-by: Xiubo Li <xiubli@redhat.com>
qa/tasks/cephfs/kernel_mount.py

index 55fdae5d9e84d205e4fca7bd4d73c7e78625b777..bb0562471a755892cf8e5bdad2ed433f81da540b 100644 (file)
@@ -27,6 +27,7 @@ class KernelMount(CephFSMount):
             client_keyring_path=client_keyring_path, hostfs_mntpt=hostfs_mntpt,
             cephfs_name=cephfs_name, cephfs_mntpt=cephfs_mntpt, brxnet=brxnet)
 
+        self.dynamic_debug = config.get('dynamic_debug', False)
         self.rbytes = config.get('rbytes', False)
         self.inst = None
         self.addr = None
@@ -50,6 +51,12 @@ class KernelMount(CephFSMount):
 
         self._set_filemode_on_mntpt()
 
+        if self.dynamic_debug:
+            kmount_count = self.ctx.get(f'kmount_count.{self.client_remote.hostname}', 0)
+            if kmount_count == 0:
+                self.enable_dynamic_debug()
+            self.ctx[f'kmount_count.{self.client_remote.hostname}'] = kmount_count + 1
+
         self.mounted = True
 
     def _run_mount_cmd(self, mntopts, check_status):
@@ -113,6 +120,13 @@ class KernelMount(CephFSMount):
                 timeout=(15*60), omit_sudo=False)
             raise e
 
+        if self.dynamic_debug:
+            kmount_count = self.ctx.get(f'kmount_count.{self.client_remote.hostname}')
+            assert kmount_count
+            if kmount_count == 1:
+                self.disable_dynamic_debug()
+            self.ctx[f'kmount_count.{self.client_remote.hostname}'] = kmount_count - 1
+
         self.mounted = False
         self.cleanup()
 
@@ -221,6 +235,32 @@ class KernelMount(CephFSMount):
                 ))
                 raise
 
+    def _dynamic_debug_control(self, enable):
+        """
+        Write to dynamic debug control file.
+        """
+        if enable:
+            fdata = "module ceph +p"
+        else:
+            fdata = "module ceph -p"
+
+        self.run_shell_payload(f"""
+sudo modprobe ceph
+echo '{fdata}' | sudo tee /sys/kernel/debug/dynamic_debug/control
+""")
+
+    def enable_dynamic_debug(self):
+        """
+        Enable the dynamic debug.
+        """
+        self._dynamic_debug_control(True)
+
+    def disable_dynamic_debug(self):
+        """
+        Disable the dynamic debug.
+        """
+        self._dynamic_debug_control(False)
+
     def get_global_id(self):
         """
         Look up the CephFS client ID for this mount, using debugfs.