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)
{
- debugfs_remove_recursive(debug_dir);
+ if (debug_dir)
+ debugfs_remove_recursive(debug_dir);
}
/* open ORANGEFS_KMOD_DEBUG_HELP_FILE */
*/
int orangefs_kernel_debug_init(void)
{
-
int rc = -ENOMEM;
struct dentry *ret;
char *k_buffer = NULL;
rc = 0;
out:
- if (rc)
- orangefs_debugfs_cleanup();
gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: rc:%d:\n", __func__, rc);
return rc;
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;
rc = 0;
out:
- if (rc)
- orangefs_debugfs_cleanup();
gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: rc:%d:\n", __func__, rc);
return rc;
*/
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);
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);
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,
&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);
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);
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);
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,
&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);
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,
&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);
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,
&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;
}