Whamcloud - gitweb
LU-11986 libcfs: lnet_remove_debugfs() compat for RHEL6 16/38716/3
authorJian Yu <yujian@whamcloud.com>
Mon, 25 May 2020 18:27:22 +0000 (11:27 -0700)
committerOleg Drokin <green@whamcloud.com>
Sat, 11 Jul 2020 07:27:58 +0000 (07:27 +0000)
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 <yujian@whamcloud.com>
Change-Id: Ib63a40afe8926f56cd1d2873975855c226098418
Reviewed-on: https://review.whamcloud.com/38716
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
libcfs/libcfs/module.c

index b0e9c94..92d410b 100644 (file)
@@ -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));