aboutsummaryrefslogtreecommitdiffstats
path: root/fs/orangefs
diff options
context:
space:
mode:
authorMike Marshall <hubcap@omnibond.com>2016-03-14 15:30:39 -0400
committerMike Marshall <hubcap@omnibond.com>2016-03-14 15:48:28 -0400
commit2180c52cc72993b3b097573aaa550f273f795c8a (patch)
treea68459be5a0284947331fd86855a6b858730e1a9 /fs/orangefs
parenta7d3e78ab53ff479fee3ad5a674a74c54c337b3b (diff)
Orangefs: fix sloppy cleanups of debugfs and sysfs init failures.
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
Diffstat (limited to 'fs/orangefs')
-rw-r--r--fs/orangefs/orangefs-debugfs.c20
-rw-r--r--fs/orangefs/orangefs-mod.c29
-rw-r--r--fs/orangefs/orangefs-sysfs.c89
3 files changed, 76 insertions, 62 deletions
diff --git a/fs/orangefs/orangefs-debugfs.c b/fs/orangefs/orangefs-debugfs.c
index 9eb7972ae10d..19670b8b4053 100644
--- a/fs/orangefs/orangefs-debugfs.c
+++ b/fs/orangefs/orangefs-debugfs.c
@@ -101,30 +101,33 @@ int orangefs_debugfs_init(void)
101 int rc = -ENOMEM; 101 int rc = -ENOMEM;
102 102
103 debug_dir = debugfs_create_dir("orangefs", NULL); 103 debug_dir = debugfs_create_dir("orangefs", NULL);
104 if (!debug_dir) 104 if (!debug_dir) {
105 pr_info("%s: debugfs_create_dir failed.\n", __func__);
105 goto out; 106 goto out;
107 }
106 108
107 help_file_dentry = debugfs_create_file(ORANGEFS_KMOD_DEBUG_HELP_FILE, 109 help_file_dentry = debugfs_create_file(ORANGEFS_KMOD_DEBUG_HELP_FILE,
108 0444, 110 0444,
109 debug_dir, 111 debug_dir,
110 debug_help_string, 112 debug_help_string,
111 &debug_help_fops); 113 &debug_help_fops);
112 if (!help_file_dentry) 114 if (!help_file_dentry) {
115 pr_info("%s: debugfs_create_file failed.\n", __func__);
113 goto out; 116 goto out;
117 }
114 118
115 orangefs_debug_disabled = 0; 119 orangefs_debug_disabled = 0;
116 rc = 0; 120 rc = 0;
117 121
118out: 122out:
119 if (rc)
120 orangefs_debugfs_cleanup();
121 123
122 return rc; 124 return rc;
123} 125}
124 126
125void orangefs_debugfs_cleanup(void) 127void orangefs_debugfs_cleanup(void)
126{ 128{
127 debugfs_remove_recursive(debug_dir); 129 if (debug_dir)
130 debugfs_remove_recursive(debug_dir);
128} 131}
129 132
130/* open ORANGEFS_KMOD_DEBUG_HELP_FILE */ 133/* open ORANGEFS_KMOD_DEBUG_HELP_FILE */
@@ -198,7 +201,6 @@ static int help_show(struct seq_file *m, void *v)
198 */ 201 */
199int orangefs_kernel_debug_init(void) 202int orangefs_kernel_debug_init(void)
200{ 203{
201
202 int rc = -ENOMEM; 204 int rc = -ENOMEM;
203 struct dentry *ret; 205 struct dentry *ret;
204 char *k_buffer = NULL; 206 char *k_buffer = NULL;
@@ -232,8 +234,6 @@ int orangefs_kernel_debug_init(void)
232 rc = 0; 234 rc = 0;
233 235
234out: 236out:
235 if (rc)
236 orangefs_debugfs_cleanup();
237 237
238 gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: rc:%d:\n", __func__, rc); 238 gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: rc:%d:\n", __func__, rc);
239 return rc; 239 return rc;
@@ -268,7 +268,7 @@ int orangefs_client_debug_init(void)
268 c_buffer, 268 c_buffer,
269 &kernel_debug_fops); 269 &kernel_debug_fops);
270 if (!client_debug_dentry) { 270 if (!client_debug_dentry) {
271 pr_info("%s: failed to create %s.\n", 271 pr_info("%s: failed to create updated %s.\n",
272 __func__, 272 __func__,
273 ORANGEFS_CLIENT_DEBUG_FILE); 273 ORANGEFS_CLIENT_DEBUG_FILE);
274 goto out; 274 goto out;
@@ -277,8 +277,6 @@ int orangefs_client_debug_init(void)
277 rc = 0; 277 rc = 0;
278 278
279out: 279out:
280 if (rc)
281 orangefs_debugfs_cleanup();
282 280
283 gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: rc:%d:\n", __func__, rc); 281 gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: rc:%d:\n", __func__, rc);
284 return rc; 282 return rc;
diff --git a/fs/orangefs/orangefs-mod.c b/fs/orangefs/orangefs-mod.c
index 91a4293d1cd7..abc41fa2d2c4 100644
--- a/fs/orangefs/orangefs-mod.c
+++ b/fs/orangefs/orangefs-mod.c
@@ -185,22 +185,39 @@ static int __init orangefs_init(void)
185 */ 185 */
186 ret = orangefs_prepare_debugfs_help_string(1); 186 ret = orangefs_prepare_debugfs_help_string(1);
187 if (ret) 187 if (ret)
188 goto out; 188 goto prepare_helpstring_failed;
189
190 ret = orangefs_debugfs_init();
191 if (ret)
192 goto debugfs_init_failed;
189 193
190 orangefs_debugfs_init(); 194 ret = orangefs_kernel_debug_init();
191 orangefs_kernel_debug_init(); 195 if (ret)
192 orangefs_sysfs_init(); 196 goto kernel_debug_init_failed;
197
198 ret = orangefs_sysfs_init();
199 if (ret)
200 goto sysfs_init_failed;
193 201
194 ret = register_filesystem(&orangefs_fs_type); 202 ret = register_filesystem(&orangefs_fs_type);
195 if (ret == 0) { 203 if (ret == 0) {
196 pr_info("orangefs: module version %s loaded\n", ORANGEFS_VERSION); 204 pr_info("orangefs: module version %s loaded\n", ORANGEFS_VERSION);
197 return 0; 205 ret = 0;
206 goto out;
198 } 207 }
199 208
200 orangefs_debugfs_cleanup();
201 orangefs_sysfs_exit(); 209 orangefs_sysfs_exit();
202 fsid_key_table_finalize(); 210 fsid_key_table_finalize();
203 211
212sysfs_init_failed:
213
214kernel_debug_init_failed:
215
216debugfs_init_failed:
217 orangefs_debugfs_cleanup();
218
219prepare_helpstring_failed:
220
204cleanup_progress_table: 221cleanup_progress_table:
205 kfree(htable_ops_in_progress); 222 kfree(htable_ops_in_progress);
206 223
diff --git a/fs/orangefs/orangefs-sysfs.c b/fs/orangefs/orangefs-sysfs.c
index 83f4053bd11b..5c03113e3ad2 100644
--- a/fs/orangefs/orangefs-sysfs.c
+++ b/fs/orangefs/orangefs-sysfs.c
@@ -1611,27 +1611,22 @@ static struct stats_orangefs_obj *stats_orangefs_obj;
1611 1611
1612int orangefs_sysfs_init(void) 1612int orangefs_sysfs_init(void)
1613{ 1613{
1614 int rc; 1614 int rc = -EINVAL;
1615 1615
1616 gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_init: start\n"); 1616 gossip_debug(GOSSIP_SYSFS_DEBUG, "orangefs_sysfs_init: start\n");
1617 1617
1618 /* create /sys/fs/orangefs. */ 1618 /* create /sys/fs/orangefs. */
1619 orangefs_obj = kzalloc(sizeof(*orangefs_obj), GFP_KERNEL); 1619 orangefs_obj = kzalloc(sizeof(*orangefs_obj), GFP_KERNEL);
1620 if (!orangefs_obj) { 1620 if (!orangefs_obj)
1621 rc = -EINVAL;
1622 goto out; 1621 goto out;
1623 }
1624 1622
1625 rc = kobject_init_and_add(&orangefs_obj->kobj, 1623 rc = kobject_init_and_add(&orangefs_obj->kobj,
1626 &orangefs_ktype, 1624 &orangefs_ktype,
1627 fs_kobj, 1625 fs_kobj,
1628 ORANGEFS_KOBJ_ID); 1626 ORANGEFS_KOBJ_ID);
1629 1627
1630 if (rc) { 1628 if (rc)
1631 kobject_put(&orangefs_obj->kobj); 1629 goto ofs_obj_bail;
1632 rc = -EINVAL;
1633 goto out;
1634 }
1635 1630
1636 kobject_uevent(&orangefs_obj->kobj, KOBJ_ADD); 1631 kobject_uevent(&orangefs_obj->kobj, KOBJ_ADD);
1637 1632
@@ -1639,7 +1634,7 @@ int orangefs_sysfs_init(void)
1639 acache_orangefs_obj = kzalloc(sizeof(*acache_orangefs_obj), GFP_KERNEL); 1634 acache_orangefs_obj = kzalloc(sizeof(*acache_orangefs_obj), GFP_KERNEL);
1640 if (!acache_orangefs_obj) { 1635 if (!acache_orangefs_obj) {
1641 rc = -EINVAL; 1636 rc = -EINVAL;
1642 goto out; 1637 goto ofs_obj_bail;
1643 } 1638 }
1644 1639
1645 rc = kobject_init_and_add(&acache_orangefs_obj->kobj, 1640 rc = kobject_init_and_add(&acache_orangefs_obj->kobj,
@@ -1647,11 +1642,8 @@ int orangefs_sysfs_init(void)
1647 &orangefs_obj->kobj, 1642 &orangefs_obj->kobj,
1648 ACACHE_KOBJ_ID); 1643 ACACHE_KOBJ_ID);
1649 1644
1650 if (rc) { 1645 if (rc)
1651 kobject_put(&acache_orangefs_obj->kobj); 1646 goto acache_obj_bail;
1652 rc = -EINVAL;
1653 goto out;
1654 }
1655 1647
1656 kobject_uevent(&acache_orangefs_obj->kobj, KOBJ_ADD); 1648 kobject_uevent(&acache_orangefs_obj->kobj, KOBJ_ADD);
1657 1649
@@ -1660,18 +1652,15 @@ int orangefs_sysfs_init(void)
1660 kzalloc(sizeof(*capcache_orangefs_obj), GFP_KERNEL); 1652 kzalloc(sizeof(*capcache_orangefs_obj), GFP_KERNEL);
1661 if (!capcache_orangefs_obj) { 1653 if (!capcache_orangefs_obj) {
1662 rc = -EINVAL; 1654 rc = -EINVAL;
1663 goto out; 1655 goto acache_obj_bail;
1664 } 1656 }
1665 1657
1666 rc = kobject_init_and_add(&capcache_orangefs_obj->kobj, 1658 rc = kobject_init_and_add(&capcache_orangefs_obj->kobj,
1667 &capcache_orangefs_ktype, 1659 &capcache_orangefs_ktype,
1668 &orangefs_obj->kobj, 1660 &orangefs_obj->kobj,
1669 CAPCACHE_KOBJ_ID); 1661 CAPCACHE_KOBJ_ID);
1670 if (rc) { 1662 if (rc)
1671 kobject_put(&capcache_orangefs_obj->kobj); 1663 goto capcache_obj_bail;
1672 rc = -EINVAL;
1673 goto out;
1674 }
1675 1664
1676 kobject_uevent(&capcache_orangefs_obj->kobj, KOBJ_ADD); 1665 kobject_uevent(&capcache_orangefs_obj->kobj, KOBJ_ADD);
1677 1666
@@ -1680,18 +1669,15 @@ int orangefs_sysfs_init(void)
1680 kzalloc(sizeof(*ccache_orangefs_obj), GFP_KERNEL); 1669 kzalloc(sizeof(*ccache_orangefs_obj), GFP_KERNEL);
1681 if (!ccache_orangefs_obj) { 1670 if (!ccache_orangefs_obj) {
1682 rc = -EINVAL; 1671 rc = -EINVAL;
1683 goto out; 1672 goto capcache_obj_bail;
1684 } 1673 }
1685 1674
1686 rc = kobject_init_and_add(&ccache_orangefs_obj->kobj, 1675 rc = kobject_init_and_add(&ccache_orangefs_obj->kobj,
1687 &ccache_orangefs_ktype, 1676 &ccache_orangefs_ktype,
1688 &orangefs_obj->kobj, 1677 &orangefs_obj->kobj,
1689 CCACHE_KOBJ_ID); 1678 CCACHE_KOBJ_ID);
1690 if (rc) { 1679 if (rc)
1691 kobject_put(&ccache_orangefs_obj->kobj); 1680 goto ccache_obj_bail;
1692 rc = -EINVAL;
1693 goto out;
1694 }
1695 1681
1696 kobject_uevent(&ccache_orangefs_obj->kobj, KOBJ_ADD); 1682 kobject_uevent(&ccache_orangefs_obj->kobj, KOBJ_ADD);
1697 1683
@@ -1699,7 +1685,7 @@ int orangefs_sysfs_init(void)
1699 ncache_orangefs_obj = kzalloc(sizeof(*ncache_orangefs_obj), GFP_KERNEL); 1685 ncache_orangefs_obj = kzalloc(sizeof(*ncache_orangefs_obj), GFP_KERNEL);
1700 if (!ncache_orangefs_obj) { 1686 if (!ncache_orangefs_obj) {
1701 rc = -EINVAL; 1687 rc = -EINVAL;
1702 goto out; 1688 goto ccache_obj_bail;
1703 } 1689 }
1704 1690
1705 rc = kobject_init_and_add(&ncache_orangefs_obj->kobj, 1691 rc = kobject_init_and_add(&ncache_orangefs_obj->kobj,
@@ -1707,11 +1693,8 @@ int orangefs_sysfs_init(void)
1707 &orangefs_obj->kobj, 1693 &orangefs_obj->kobj,
1708 NCACHE_KOBJ_ID); 1694 NCACHE_KOBJ_ID);
1709 1695
1710 if (rc) { 1696 if (rc)
1711 kobject_put(&ncache_orangefs_obj->kobj); 1697 goto ncache_obj_bail;
1712 rc = -EINVAL;
1713 goto out;
1714 }
1715 1698
1716 kobject_uevent(&ncache_orangefs_obj->kobj, KOBJ_ADD); 1699 kobject_uevent(&ncache_orangefs_obj->kobj, KOBJ_ADD);
1717 1700
@@ -1719,7 +1702,7 @@ int orangefs_sysfs_init(void)
1719 pc_orangefs_obj = kzalloc(sizeof(*pc_orangefs_obj), GFP_KERNEL); 1702 pc_orangefs_obj = kzalloc(sizeof(*pc_orangefs_obj), GFP_KERNEL);
1720 if (!pc_orangefs_obj) { 1703 if (!pc_orangefs_obj) {
1721 rc = -EINVAL; 1704 rc = -EINVAL;
1722 goto out; 1705 goto ncache_obj_bail;
1723 } 1706 }
1724 1707
1725 rc = kobject_init_and_add(&pc_orangefs_obj->kobj, 1708 rc = kobject_init_and_add(&pc_orangefs_obj->kobj,
@@ -1727,11 +1710,8 @@ int orangefs_sysfs_init(void)
1727 &orangefs_obj->kobj, 1710 &orangefs_obj->kobj,
1728 "perf_counters"); 1711 "perf_counters");
1729 1712
1730 if (rc) { 1713 if (rc)
1731 kobject_put(&pc_orangefs_obj->kobj); 1714 goto pc_obj_bail;
1732 rc = -EINVAL;
1733 goto out;
1734 }
1735 1715
1736 kobject_uevent(&pc_orangefs_obj->kobj, KOBJ_ADD); 1716 kobject_uevent(&pc_orangefs_obj->kobj, KOBJ_ADD);
1737 1717
@@ -1739,7 +1719,7 @@ int orangefs_sysfs_init(void)
1739 stats_orangefs_obj = kzalloc(sizeof(*stats_orangefs_obj), GFP_KERNEL); 1719 stats_orangefs_obj = kzalloc(sizeof(*stats_orangefs_obj), GFP_KERNEL);
1740 if (!stats_orangefs_obj) { 1720 if (!stats_orangefs_obj) {
1741 rc = -EINVAL; 1721 rc = -EINVAL;
1742 goto out; 1722 goto pc_obj_bail;
1743 } 1723 }
1744 1724
1745 rc = kobject_init_and_add(&stats_orangefs_obj->kobj, 1725 rc = kobject_init_and_add(&stats_orangefs_obj->kobj,
@@ -1747,13 +1727,32 @@ int orangefs_sysfs_init(void)
1747 &orangefs_obj->kobj, 1727 &orangefs_obj->kobj,
1748 STATS_KOBJ_ID); 1728 STATS_KOBJ_ID);
1749 1729
1750 if (rc) { 1730 if (rc)
1751 kobject_put(&stats_orangefs_obj->kobj); 1731 goto stats_obj_bail;
1752 rc = -EINVAL;
1753 goto out;
1754 }
1755 1732
1756 kobject_uevent(&stats_orangefs_obj->kobj, KOBJ_ADD); 1733 kobject_uevent(&stats_orangefs_obj->kobj, KOBJ_ADD);
1734 goto out;
1735
1736stats_obj_bail:
1737 kobject_put(&stats_orangefs_obj->kobj);
1738
1739pc_obj_bail:
1740 kobject_put(&pc_orangefs_obj->kobj);
1741
1742ncache_obj_bail:
1743 kobject_put(&ncache_orangefs_obj->kobj);
1744
1745ccache_obj_bail:
1746 kobject_put(&ccache_orangefs_obj->kobj);
1747
1748capcache_obj_bail:
1749 kobject_put(&capcache_orangefs_obj->kobj);
1750
1751acache_obj_bail:
1752 kobject_put(&acache_orangefs_obj->kobj);
1753
1754ofs_obj_bail:
1755 kobject_put(&orangefs_obj->kobj);
1757out: 1756out:
1758 return rc; 1757 return rc;
1759} 1758}