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 <xiubli@redhat.com>
This commit is contained in:
Xiubo Li 2021-01-04 13:26:19 +08:00
parent a05f6bf6a5
commit 0cb06740a9

View 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.