提交 2180c52c 编写于 作者: M Mike Marshall

Orangefs: fix sloppy cleanups of debugfs and sysfs init failures.

Signed-off-by: NMike Marshall <hubcap@omnibond.com>
上级 a7d3e78a
......@@ -101,29 +101,32 @@ int orangefs_debugfs_init(void)
int rc = -ENOMEM;
debug_dir = debugfs_create_dir("orangefs", NULL);
if (!debug_dir)
if (!debug_dir) {
pr_info("%s: debugfs_create_dir failed.\n", __func__);
goto out;
}
help_file_dentry = debugfs_create_file(ORANGEFS_KMOD_DEBUG_HELP_FILE,
0444,
debug_dir,
debug_help_string,
&debug_help_fops);
if (!help_file_dentry)
if (!help_file_dentry) {
pr_info("%s: debugfs_create_file failed.\n", __func__);
goto out;
}
orangefs_debug_disabled = 0;
rc = 0;
out:
if (rc)
orangefs_debugfs_cleanup();
return rc;
}
void orangefs_debugfs_cleanup(void)
{
if (debug_dir)
debugfs_remove_recursive(debug_dir);
}
......@@ -198,7 +201,6 @@ static int help_show(struct seq_file *m, void *v)
*/
int orangefs_kernel_debug_init(void)
{
int rc = -ENOMEM;
struct dentry *ret;
char *k_buffer = NULL;
......@@ -232,8 +234,6 @@ int orangefs_kernel_debug_init(void)
rc = 0;
out:
if (rc)
orangefs_debugfs_cleanup();
gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: rc:%d:\n", __func__, rc);
return rc;
......@@ -268,7 +268,7 @@ int orangefs_client_debug_init(void)
c_buffer,
&kernel_debug_fops);
if (!client_debug_dentry) {
pr_info("%s: failed to create %s.\n",
pr_info("%s: failed to create updated %s.\n",
__func__,
ORANGEFS_CLIENT_DEBUG_FILE);
goto out;
......@@ -277,8 +277,6 @@ int orangefs_client_debug_init(void)
rc = 0;
out:
if (rc)
orangefs_debugfs_cleanup();
gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: rc:%d:\n", __func__, rc);
return rc;
......
......@@ -185,22 +185,39 @@ static int __init orangefs_init(void)
*/
ret = orangefs_prepare_debugfs_help_string(1);
if (ret)
goto out;
goto prepare_helpstring_failed;
ret = orangefs_debugfs_init();
if (ret)
goto debugfs_init_failed;
orangefs_debugfs_init();
orangefs_kernel_debug_init();
orangefs_sysfs_init();
ret = orangefs_kernel_debug_init();
if (ret)
goto kernel_debug_init_failed;
ret = orangefs_sysfs_init();
if (ret)
goto sysfs_init_failed;
ret = register_filesystem(&orangefs_fs_type);
if (ret == 0) {
pr_info("orangefs: module version %s loaded\n", ORANGEFS_VERSION);
return 0;
ret = 0;
goto out;
}
orangefs_debugfs_cleanup();
orangefs_sysfs_exit();
fsid_key_table_finalize();
sysfs_init_failed:
kernel_debug_init_failed:
debugfs_init_failed:
orangefs_debugfs_cleanup();
prepare_helpstring_failed:
cleanup_progress_table:
kfree(htable_ops_in_progress);
......
......@@ -1611,27 +1611,22 @@ static struct stats_orangefs_obj *stats_orangefs_obj;
int orangefs_sysfs_init(void)
{
int rc;
int rc = -EINVAL;
gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_init: start\n");
/* create /sys/fs/orangefs. */
orangefs_obj = kzalloc(sizeof(*orangefs_obj), GFP_KERNEL);
if (!orangefs_obj) {
rc = -EINVAL;
if (!orangefs_obj)
goto out;
}
rc = kobject_init_and_add(&orangefs_obj->kobj,
&orangefs_ktype,
fs_kobj,
ORANGEFS_KOBJ_ID);
if (rc) {
kobject_put(&orangefs_obj->kobj);
rc = -EINVAL;
goto out;
}
if (rc)
goto ofs_obj_bail;
kobject_uevent(&orangefs_obj->kobj, KOBJ_ADD);
......@@ -1639,7 +1634,7 @@ int orangefs_sysfs_init(void)
acache_orangefs_obj = kzalloc(sizeof(*acache_orangefs_obj), GFP_KERNEL);
if (!acache_orangefs_obj) {
rc = -EINVAL;
goto out;
goto ofs_obj_bail;
}
rc = kobject_init_and_add(&acache_orangefs_obj->kobj,
......@@ -1647,11 +1642,8 @@ int orangefs_sysfs_init(void)
&orangefs_obj->kobj,
ACACHE_KOBJ_ID);
if (rc) {
kobject_put(&acache_orangefs_obj->kobj);
rc = -EINVAL;
goto out;
}
if (rc)
goto acache_obj_bail;
kobject_uevent(&acache_orangefs_obj->kobj, KOBJ_ADD);
......@@ -1660,18 +1652,15 @@ int orangefs_sysfs_init(void)
kzalloc(sizeof(*capcache_orangefs_obj), GFP_KERNEL);
if (!capcache_orangefs_obj) {
rc = -EINVAL;
goto out;
goto acache_obj_bail;
}
rc = kobject_init_and_add(&capcache_orangefs_obj->kobj,
&capcache_orangefs_ktype,
&orangefs_obj->kobj,
CAPCACHE_KOBJ_ID);
if (rc) {
kobject_put(&capcache_orangefs_obj->kobj);
rc = -EINVAL;
goto out;
}
if (rc)
goto capcache_obj_bail;
kobject_uevent(&capcache_orangefs_obj->kobj, KOBJ_ADD);
......@@ -1680,18 +1669,15 @@ int orangefs_sysfs_init(void)
kzalloc(sizeof(*ccache_orangefs_obj), GFP_KERNEL);
if (!ccache_orangefs_obj) {
rc = -EINVAL;
goto out;
goto capcache_obj_bail;
}
rc = kobject_init_and_add(&ccache_orangefs_obj->kobj,
&ccache_orangefs_ktype,
&orangefs_obj->kobj,
CCACHE_KOBJ_ID);
if (rc) {
kobject_put(&ccache_orangefs_obj->kobj);
rc = -EINVAL;
goto out;
}
if (rc)
goto ccache_obj_bail;
kobject_uevent(&ccache_orangefs_obj->kobj, KOBJ_ADD);
......@@ -1699,7 +1685,7 @@ int orangefs_sysfs_init(void)
ncache_orangefs_obj = kzalloc(sizeof(*ncache_orangefs_obj), GFP_KERNEL);
if (!ncache_orangefs_obj) {
rc = -EINVAL;
goto out;
goto ccache_obj_bail;
}
rc = kobject_init_and_add(&ncache_orangefs_obj->kobj,
......@@ -1707,11 +1693,8 @@ int orangefs_sysfs_init(void)
&orangefs_obj->kobj,
NCACHE_KOBJ_ID);
if (rc) {
kobject_put(&ncache_orangefs_obj->kobj);
rc = -EINVAL;
goto out;
}
if (rc)
goto ncache_obj_bail;
kobject_uevent(&ncache_orangefs_obj->kobj, KOBJ_ADD);
......@@ -1719,7 +1702,7 @@ int orangefs_sysfs_init(void)
pc_orangefs_obj = kzalloc(sizeof(*pc_orangefs_obj), GFP_KERNEL);
if (!pc_orangefs_obj) {
rc = -EINVAL;
goto out;
goto ncache_obj_bail;
}
rc = kobject_init_and_add(&pc_orangefs_obj->kobj,
......@@ -1727,11 +1710,8 @@ int orangefs_sysfs_init(void)
&orangefs_obj->kobj,
"perf_counters");
if (rc) {
kobject_put(&pc_orangefs_obj->kobj);
rc = -EINVAL;
goto out;
}
if (rc)
goto pc_obj_bail;
kobject_uevent(&pc_orangefs_obj->kobj, KOBJ_ADD);
......@@ -1739,7 +1719,7 @@ int orangefs_sysfs_init(void)
stats_orangefs_obj = kzalloc(sizeof(*stats_orangefs_obj), GFP_KERNEL);
if (!stats_orangefs_obj) {
rc = -EINVAL;
goto out;
goto pc_obj_bail;
}
rc = kobject_init_and_add(&stats_orangefs_obj->kobj,
......@@ -1747,13 +1727,32 @@ int orangefs_sysfs_init(void)
&orangefs_obj->kobj,
STATS_KOBJ_ID);
if (rc) {
kobject_put(&stats_orangefs_obj->kobj);
rc = -EINVAL;
goto out;
}
if (rc)
goto stats_obj_bail;
kobject_uevent(&stats_orangefs_obj->kobj, KOBJ_ADD);
goto out;
stats_obj_bail:
kobject_put(&stats_orangefs_obj->kobj);
pc_obj_bail:
kobject_put(&pc_orangefs_obj->kobj);
ncache_obj_bail:
kobject_put(&ncache_orangefs_obj->kobj);
ccache_obj_bail:
kobject_put(&ccache_orangefs_obj->kobj);
capcache_obj_bail:
kobject_put(&capcache_orangefs_obj->kobj);
acache_obj_bail:
kobject_put(&acache_orangefs_obj->kobj);
ofs_obj_bail:
kobject_put(&orangefs_obj->kobj);
out:
return rc;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册