Whamcloud - gitweb
LU-12374 lustre: push rcu_barrier() before destroying slab
[fs/lustre-release.git] / lustre / llite / super25.c
index c2ebb76..5158d0a 100644 (file)
@@ -39,6 +39,7 @@
 #include <lustre_dlm.h>
 #include <linux/init.h>
 #include <linux/fs.h>
+#include <linux/random.h>
 #include <lprocfs_status.h>
 #include "llite_internal.h"
 #include "vvp_internal.h"
@@ -95,15 +96,10 @@ struct super_operations lustre_super_operations =
         .show_options  = ll_show_options,
 };
 
-
-void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg));
-
 static int __init lustre_init(void)
 {
-       struct proc_dir_entry *entry;
-       lnet_process_id_t lnet_id;
-       struct timeval tv;
-       int i, rc, seed[2];
+       struct lnet_process_id lnet_id;
+       int i, rc;
 
        CLASSERT(sizeof(LUSTRE_VOLATILE_HDR) == LUSTRE_VOLATILE_HDR_LEN + 1);
 
@@ -125,17 +121,9 @@ static int __init lustre_init(void)
        if (ll_file_data_slab == NULL)
                GOTO(out_cache, rc = -ENOMEM);
 
-       entry = lprocfs_register("llite", proc_lustre_root, NULL, NULL);
-       if (IS_ERR(entry)) {
-               rc = PTR_ERR(entry);
-               CERROR("cannot register '/proc/fs/lustre/llite': rc = %d\n",
-                      rc);
+       rc = llite_tunables_register();
+       if (rc)
                GOTO(out_cache, rc);
-       }
-
-       proc_lustre_fs_root = entry;
-
-       cfs_get_random_bytes(seed, sizeof(seed));
 
        /* Nodes with small feet have little entropy. The NID for this
         * node gives the most entropy in the low bits. */
@@ -143,16 +131,12 @@ static int __init lustre_init(void)
                if (LNetGetId(i, &lnet_id) == -ENOENT)
                        break;
 
-               if (LNET_NETTYP(LNET_NIDNET(lnet_id.nid)) != LOLND)
-                       seed[0] ^= LNET_NIDADDR(lnet_id.nid);
+               add_device_randomness(&lnet_id.nid, sizeof(lnet_id.nid));
        }
 
-       do_gettimeofday(&tv);
-       cfs_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]);
-
        rc = vvp_global_init();
        if (rc != 0)
-               GOTO(out_proc, rc);
+               GOTO(out_tunables, rc);
 
        cl_inode_fini_env = cl_env_alloc(&cl_inode_fini_refcheck,
                                         LCT_REMEMBER | LCT_NOREF);
@@ -167,7 +151,6 @@ static int __init lustre_init(void)
 
        lustre_register_client_fill_super(ll_fill_super);
        lustre_register_kill_super_cb(ll_kill_super);
-       lustre_register_client_process_config(ll_process_config);
 
        RETURN(0);
 
@@ -175,15 +158,11 @@ out_inode_fini_env:
        cl_env_put(cl_inode_fini_env, &cl_inode_fini_refcheck);
 out_vvp:
        vvp_global_fini();
-out_proc:
-       lprocfs_remove(&proc_lustre_fs_root);
+out_tunables:
+       llite_tunables_unregister();
 out_cache:
-       if (ll_inode_cachep != NULL)
-               kmem_cache_destroy(ll_inode_cachep);
-
-       if (ll_file_data_slab != NULL)
-               kmem_cache_destroy(ll_file_data_slab);
-
+       kmem_cache_destroy(ll_inode_cachep);
+       kmem_cache_destroy(ll_file_data_slab);
        return rc;
 }
 
@@ -191,14 +170,20 @@ static void __exit lustre_exit(void)
 {
        lustre_register_client_fill_super(NULL);
        lustre_register_kill_super_cb(NULL);
-       lustre_register_client_process_config(NULL);
 
-       lprocfs_remove(&proc_lustre_fs_root);
+       llite_tunables_unregister();
 
        ll_xattr_fini();
        cl_env_put(cl_inode_fini_env, &cl_inode_fini_refcheck);
        vvp_global_fini();
 
+#ifdef HAVE_INODE_I_RCU
+       /*
+        * Make sure all delayed rcu free inodes are flushed before we
+        * destroy cache.
+        */
+       rcu_barrier();
+#endif
        kmem_cache_destroy(ll_inode_cachep);
        kmem_cache_destroy(ll_file_data_slab);
 }