Commit 081fa9df authored by John L. Hammond's avatar John L. Hammond Committed by Greg Kroah-Hartman

staging/lustre/llite: remove llite proc root on init failure

In init_lustre_lite() ensure that /proc/fs/lustre/llite is removed in
case of failure. Generally rework the cleanup code in this function.
Signed-off-by: default avatarJohn L. Hammond <john.hammond@intel.com>
Reviewed-on: http://review.whamcloud.com/6420
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3331Reviewed-by: default avatarBob Glossman <bob.glossman@intel.com>
Reviewed-by: default avatarJames Simmons <uja.ornl@gmail.com>
Signed-off-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c2fcdf6c
...@@ -72,21 +72,6 @@ static void ll_destroy_inode(struct inode *inode) ...@@ -72,21 +72,6 @@ static void ll_destroy_inode(struct inode *inode)
call_rcu(&inode->i_rcu, ll_inode_destroy_callback); call_rcu(&inode->i_rcu, ll_inode_destroy_callback);
} }
static int ll_init_inodecache(void)
{
ll_inode_cachep = kmem_cache_create("lustre_inode_cache",
sizeof(struct ll_inode_info),
0, SLAB_HWCACHE_ALIGN, NULL);
if (ll_inode_cachep == NULL)
return -ENOMEM;
return 0;
}
static void ll_destroy_inodecache(void)
{
kmem_cache_destroy(ll_inode_cachep);
}
/* exported operations */ /* exported operations */
struct super_operations lustre_super_operations = { struct super_operations lustre_super_operations = {
.alloc_inode = ll_alloc_inode, .alloc_inode = ll_alloc_inode,
...@@ -104,9 +89,10 @@ void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg)); ...@@ -104,9 +89,10 @@ void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg));
static int __init init_lustre_lite(void) static int __init init_lustre_lite(void)
{ {
int i, rc, seed[2]; struct proc_dir_entry *entry;
struct timeval tv;
lnet_process_id_t lnet_id; lnet_process_id_t lnet_id;
struct timeval tv;
int i, rc, seed[2];
CLASSERT(sizeof(LUSTRE_VOLATILE_HDR) == LUSTRE_VOLATILE_HDR_LEN + 1); CLASSERT(sizeof(LUSTRE_VOLATILE_HDR) == LUSTRE_VOLATILE_HDR_LEN + 1);
...@@ -116,60 +102,53 @@ static int __init init_lustre_lite(void) ...@@ -116,60 +102,53 @@ static int __init init_lustre_lite(void)
CDEBUG(D_INFO, "Lustre client module (%p).\n", CDEBUG(D_INFO, "Lustre client module (%p).\n",
&lustre_super_operations); &lustre_super_operations);
rc = ll_init_inodecache(); rc = -ENOMEM;
if (rc) ll_inode_cachep = kmem_cache_create("lustre_inode_cache",
return -ENOMEM; sizeof(struct ll_inode_info),
0, SLAB_HWCACHE_ALIGN, NULL);
if (ll_inode_cachep == NULL)
goto out_cache;
ll_file_data_slab = kmem_cache_create("ll_file_data", ll_file_data_slab = kmem_cache_create("ll_file_data",
sizeof(struct ll_file_data), 0, sizeof(struct ll_file_data), 0,
SLAB_HWCACHE_ALIGN, NULL); SLAB_HWCACHE_ALIGN, NULL);
if (ll_file_data_slab == NULL) { if (ll_file_data_slab == NULL)
ll_destroy_inodecache(); goto out_cache;
return -ENOMEM;
}
ll_remote_perm_cachep = kmem_cache_create("ll_remote_perm_cache", ll_remote_perm_cachep = kmem_cache_create("ll_remote_perm_cache",
sizeof(struct ll_remote_perm), sizeof(struct ll_remote_perm),
0, 0, NULL); 0, 0, NULL);
if (ll_remote_perm_cachep == NULL) { if (ll_remote_perm_cachep == NULL)
kmem_cache_destroy(ll_file_data_slab); goto out_cache;
ll_file_data_slab = NULL;
ll_destroy_inodecache();
return -ENOMEM;
}
ll_rmtperm_hash_cachep = kmem_cache_create("ll_rmtperm_hash_cache", ll_rmtperm_hash_cachep = kmem_cache_create("ll_rmtperm_hash_cache",
REMOTE_PERM_HASHSIZE * REMOTE_PERM_HASHSIZE *
sizeof(struct list_head), sizeof(struct list_head),
0, 0, NULL); 0, 0, NULL);
if (ll_rmtperm_hash_cachep == NULL) { if (ll_rmtperm_hash_cachep == NULL)
kmem_cache_destroy(ll_remote_perm_cachep); goto out_cache;
ll_remote_perm_cachep = NULL;
kmem_cache_destroy(ll_file_data_slab); entry = lprocfs_register("llite", proc_lustre_root, NULL, NULL);
ll_file_data_slab = NULL; if (IS_ERR(entry)) {
ll_destroy_inodecache(); rc = PTR_ERR(entry);
return -ENOMEM; CERROR("cannot register '/proc/fs/lustre/llite': rc = %d\n",
rc);
goto out_cache;
} }
proc_lustre_fs_root = proc_lustre_root ? proc_lustre_fs_root = entry;
lprocfs_register("llite", proc_lustre_root, NULL, NULL) : NULL;
lustre_register_client_fill_super(ll_fill_super);
lustre_register_kill_super_cb(ll_kill_super);
lustre_register_client_process_config(ll_process_config);
cfs_get_random_bytes(seed, sizeof(seed)); cfs_get_random_bytes(seed, sizeof(seed));
/* Nodes with small feet have little entropy /* Nodes with small feet have little entropy. The NID for this
* the NID for this node gives the most entropy in the low bits */ * node gives the most entropy in the low bits */
for (i = 0; ; i++) { for (i = 0;; i++) {
if (LNetGetId(i, &lnet_id) == -ENOENT) { if (LNetGetId(i, &lnet_id) == -ENOENT)
break; break;
}
if (LNET_NETTYP(LNET_NIDNET(lnet_id.nid)) != LOLND) { if (LNET_NETTYP(LNET_NIDNET(lnet_id.nid)) != LOLND)
seed[0] ^= LNET_NIDADDR(lnet_id.nid); seed[0] ^= LNET_NIDADDR(lnet_id.nid);
} }
}
do_gettimeofday(&tv); do_gettimeofday(&tv);
cfs_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]); cfs_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]);
...@@ -177,20 +156,54 @@ static int __init init_lustre_lite(void) ...@@ -177,20 +156,54 @@ static int __init init_lustre_lite(void)
init_timer(&ll_capa_timer); init_timer(&ll_capa_timer);
ll_capa_timer.function = ll_capa_timer_callback; ll_capa_timer.function = ll_capa_timer_callback;
rc = ll_capa_thread_start(); rc = ll_capa_thread_start();
/* if (rc != 0)
* XXX normal cleanup is needed here. goto out_proc;
*/
if (rc == 0)
rc = vvp_global_init(); rc = vvp_global_init();
if (rc != 0)
goto out_capa;
if (rc == 0)
rc = ll_xattr_init(); rc = ll_xattr_init();
if (rc != 0)
goto out_vvp;
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;
out_vvp:
vvp_global_fini();
out_capa:
del_timer(&ll_capa_timer);
ll_capa_thread_stop();
out_proc:
lprocfs_remove(&proc_lustre_fs_root);
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);
if (ll_remote_perm_cachep != NULL)
kmem_cache_destroy(ll_remote_perm_cachep);
if (ll_rmtperm_hash_cachep != NULL)
kmem_cache_destroy(ll_rmtperm_hash_cachep);
return rc; return rc;
} }
static void __exit exit_lustre_lite(void) static void __exit exit_lustre_lite(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);
ll_xattr_fini(); ll_xattr_fini();
vvp_global_fini(); vvp_global_fini();
del_timer(&ll_capa_timer); del_timer(&ll_capa_timer);
...@@ -199,22 +212,12 @@ static void __exit exit_lustre_lite(void) ...@@ -199,22 +212,12 @@ static void __exit exit_lustre_lite(void)
"client remaining capa count %d\n", "client remaining capa count %d\n",
capa_count[CAPA_SITE_CLIENT]); capa_count[CAPA_SITE_CLIENT]);
lustre_register_client_fill_super(NULL); kmem_cache_destroy(ll_inode_cachep);
lustre_register_kill_super_cb(NULL);
lustre_register_client_process_config(NULL);
ll_destroy_inodecache();
kmem_cache_destroy(ll_rmtperm_hash_cachep); kmem_cache_destroy(ll_rmtperm_hash_cachep);
ll_rmtperm_hash_cachep = NULL;
kmem_cache_destroy(ll_remote_perm_cachep); kmem_cache_destroy(ll_remote_perm_cachep);
ll_remote_perm_cachep = NULL;
kmem_cache_destroy(ll_file_data_slab); kmem_cache_destroy(ll_file_data_slab);
if (proc_lustre_fs_root && !IS_ERR(proc_lustre_fs_root))
lprocfs_remove(&proc_lustre_fs_root);
} }
MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>"); MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment