From: Xiubo Li Date: Mon, 4 Jan 2021 05:26:19 +0000 (+0800) Subject: qa: enable dynamic debug support to kclient X-Git-Tag: v17.1.0~629^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=0cb06740a98e8f841bbf905d2df162146b8a8ae7;p=ceph.git qa: enable dynamic debug support to kclient 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 --- diff --git a/qa/tasks/cephfs/kernel_mount.py b/qa/tasks/cephfs/kernel_mount.py index 55fdae5d9e84d..bb0562471a755 100644 --- a/qa/tasks/cephfs/kernel_mount.py +++ b/qa/tasks/cephfs/kernel_mount.py @@ -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.