From 7f821c9382c39fd16156593569737df27dfb0467 Mon Sep 17 00:00:00 2001 From: Jian Yu Date: Mon, 25 May 2020 11:27:22 -0700 Subject: [PATCH] LU-11986 libcfs: lnet_remove_debugfs() compat for RHEL6 Unloading libcfs module on RHEL 6.10 Lustre client with kernel 2.6.32-754.24.3 hit kernel panic issue. The issue doesn't exist in Lustre b2_10 where RHEL 6.10 is supported and debugfs_remove_recursive() is called directly from lnet_remove_debugfs(). This patch adds compat changes to lnet_remove_debugfs() to resolve the issue. Fixes: 9d42660e173e ("LU-11986 lnet: properly cleanup lnet debugfs files") Fixes: ae93a9f21752 ("LU-11986 libcfs: add compat for d_hash_and_lookup()") Test-Parameters: trivial Signed-off-by: Jian Yu Change-Id: Ib63a40afe8926f56cd1d2873975855c226098418 Reviewed-on: https://review.whamcloud.com/38716 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- libcfs/libcfs/module.c | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/libcfs/libcfs/module.c b/libcfs/libcfs/module.c index b0e9c94..92d410b 100644 --- a/libcfs/libcfs/module.c +++ b/libcfs/libcfs/module.c @@ -575,33 +575,14 @@ static void lnet_insert_debugfs_links( symlinks->target); } -#ifndef HAVE_D_HASH_AND_LOOKUP -/** - * d_hash_and_lookup - hash the qstr then search for a dentry - * @dir: Directory to search in - * @name: qstr of name we wish to find - * - * On lookup failure NULL is returned; on bad name - ERR_PTR(-error) - */ -struct dentry *d_hash_and_lookup(struct dentry *dir, struct qstr *name) +void lnet_remove_debugfs(struct ctl_table *table) { - /* - * Check for a fs-specific hash function. Note that we must - * calculate the standard hash first, as the d_op->d_hash() - * routine may choose to leave the hash value unchanged. - */ - name->hash = full_name_hash(name->name, name->len); - if (dir->d_op && dir->d_op->d_hash) { - int err = dir->d_op->d_hash(dir, name); - if (unlikely(err < 0)) - return ERR_PTR(err); - } - return d_lookup(dir, name); -} +#ifndef HAVE_D_HASH_AND_LOOKUP + debugfs_remove_recursive(lnet_debugfs_root); + lnet_debugfs_root = NULL; + return; #endif -void lnet_remove_debugfs(struct ctl_table *table) -{ for (; table && table->procname; table++) { struct qstr dname = QSTR_INIT(table->procname, strlen(table->procname)); @@ -679,8 +660,10 @@ static void __exit libcfs_exit(void) int rc; /* Remove everthing */ - debugfs_remove_recursive(lnet_debugfs_root); - lnet_debugfs_root = NULL; + if (lnet_debugfs_root) { + debugfs_remove_recursive(lnet_debugfs_root); + lnet_debugfs_root = NULL; + } CDEBUG(D_MALLOC, "before Portals cleanup: kmem %d\n", atomic_read(&libcfs_kmemory)); -- 1.8.3.1