}
EXPORT_SYMBOL_GPL(lnet_remove_debugfs);
+static DEFINE_MUTEX(libcfs_startup);
+static int libcfs_active;
+
static void *debugfs_state;
-static int __init libcfs_init(void)
+
+int libcfs_setup(void)
{
- int rc;
+ int rc = -EINVAL;
- cfs_arch_init();
+ mutex_lock(&libcfs_startup);
+ if (libcfs_active)
+ goto out;
rc = libcfs_debug_init(5 * 1024 * 1024);
if (rc < 0) {
pr_err("LustreError: libcfs_debug_init: rc = %d\n", rc);
- return (rc);
+ goto cleanup_lock;
}
rc = cfs_cpu_init();
rc = cfs_crypto_register();
if (rc) {
- CERROR("cfs_crypto_regster: error %d\n", rc);
+ CERROR("cfs_crypto_register: error %d\n", rc);
goto cleanup_wq;
}
- lnet_insert_debugfs(lnet_table, THIS_MODULE, &debugfs_state);
- if (!IS_ERR_OR_NULL(lnet_debugfs_root))
- lnet_insert_debugfs_links(lnet_debugfs_symlinks);
-
- rc = llcrypt_init();
- if (rc) {
- CERROR("llcrypt_init: error %d\n", rc);
- goto cleanup_lnet;
- }
-
- CDEBUG(D_OTHER, "portals setup OK\n");
+ CDEBUG(D_OTHER, "libcfs setup OK\n");
+out:
+ libcfs_active = 1;
+ mutex_unlock(&libcfs_startup);
return 0;
-cleanup_lnet:
- if (!IS_ERR_OR_NULL(lnet_debugfs_root)) {
- debugfs_remove_recursive(lnet_debugfs_root);
- lnet_debugfs_root = NULL;
- lnet_debugfs_fini(&debugfs_state);
- }
- cfs_crypto_unregister();
cleanup_wq:
destroy_workqueue(cfs_rehash_wq);
cfs_rehash_wq = NULL;
cfs_cpu_fini();
cleanup_debug:
libcfs_debug_cleanup();
+cleanup_lock:
+ mutex_unlock(&libcfs_startup);
+ return rc;
+}
+EXPORT_SYMBOL(libcfs_setup);
+
+static int __init libcfs_init(void)
+{
+ int rc;
+
+ rc = cfs_arch_init();
+ if (rc < 0) {
+ CERROR("cfs_arch_init: error %d\n", rc);
+ return rc;
+ }
+
+ lnet_insert_debugfs(lnet_table, THIS_MODULE, &debugfs_state);
+ if (!IS_ERR_OR_NULL(lnet_debugfs_root))
+ lnet_insert_debugfs_links(lnet_debugfs_symlinks);
+
return rc;
}
CDEBUG(D_MALLOC, "before Portals cleanup: kmem %lld\n",
libcfs_kmem_read());
- llcrypt_exit();
-
- if (cfs_rehash_wq) {
+ if (cfs_rehash_wq)
destroy_workqueue(cfs_rehash_wq);
- cfs_rehash_wq = NULL;
- }
cfs_crypto_unregister();
rc = libcfs_debug_cleanup();
if (rc)
pr_err("LustreError: libcfs_debug_cleanup: rc = %d\n", rc);
+
+ cfs_arch_exit();
}
MODULE_AUTHOR("OpenSFS, Inc. <http://www.lustre.org/>");