aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-04-21 12:17:28 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-21 12:17:28 -0400
commit8f443e2372ba23d51ee365974f54507acd6f69d1 (patch)
tree45491c137f2d684a49a1f01046f1eda6398e2aac /fs/ocfs2
parent646da63172f660ba84f195c1165360a9b73583ee (diff)
Revert "ocfs2: incorrect check for debugfs returns"
This reverts commit e2ac55b6a8e337fac7cc59c6f452caac92ab5ee6. Huang Ying reports that this causes a hang at boot with debugfs disabled. It is true that the debugfs error checks are kind of confusing, and this code certainly merits more cleanup and thinking about it, but there's something wrong with the trivial "check not just for NULL, but for error pointers too" patch. Yes, with debugfs disabled, we will end up setting the o2hb_debug_dir pointer variable to an error pointer (-ENODEV), and then continue as if everything was fine. But since debugfs is disabled, all the _users_ of that pointer end up being compiled away, so even though the pointer can not be dereferenced, that's still fine. So it's confusing and somewhat questionable, but the "more correct" error checks end up causing more trouble than they fix. Reported-by: Huang Ying <ying.huang@intel.com> Acked-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: Chengyu Song <csong84@gatech.edu> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/cluster/heartbeat.c42
-rw-r--r--fs/ocfs2/dlmglue.c2
-rw-r--r--fs/ocfs2/super.c9
3 files changed, 16 insertions, 37 deletions
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 8e19b9d7aba8..16eff45727ee 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -1312,9 +1312,7 @@ static int o2hb_debug_init(void)
1312 int ret = -ENOMEM; 1312 int ret = -ENOMEM;
1313 1313
1314 o2hb_debug_dir = debugfs_create_dir(O2HB_DEBUG_DIR, NULL); 1314 o2hb_debug_dir = debugfs_create_dir(O2HB_DEBUG_DIR, NULL);
1315 if (IS_ERR_OR_NULL(o2hb_debug_dir)) { 1315 if (!o2hb_debug_dir) {
1316 ret = o2hb_debug_dir ?
1317 PTR_ERR(o2hb_debug_dir) : -ENOMEM;
1318 mlog_errno(ret); 1316 mlog_errno(ret);
1319 goto bail; 1317 goto bail;
1320 } 1318 }
@@ -1327,9 +1325,7 @@ static int o2hb_debug_init(void)
1327 sizeof(o2hb_live_node_bitmap), 1325 sizeof(o2hb_live_node_bitmap),
1328 O2NM_MAX_NODES, 1326 O2NM_MAX_NODES,
1329 o2hb_live_node_bitmap); 1327 o2hb_live_node_bitmap);
1330 if (IS_ERR_OR_NULL(o2hb_debug_livenodes)) { 1328 if (!o2hb_debug_livenodes) {
1331 ret = o2hb_debug_livenodes ?
1332 PTR_ERR(o2hb_debug_livenodes) : -ENOMEM;
1333 mlog_errno(ret); 1329 mlog_errno(ret);
1334 goto bail; 1330 goto bail;
1335 } 1331 }
@@ -1342,9 +1338,7 @@ static int o2hb_debug_init(void)
1342 sizeof(o2hb_live_region_bitmap), 1338 sizeof(o2hb_live_region_bitmap),
1343 O2NM_MAX_REGIONS, 1339 O2NM_MAX_REGIONS,
1344 o2hb_live_region_bitmap); 1340 o2hb_live_region_bitmap);
1345 if (IS_ERR_OR_NULL(o2hb_debug_liveregions)) { 1341 if (!o2hb_debug_liveregions) {
1346 ret = o2hb_debug_liveregions ?
1347 PTR_ERR(o2hb_debug_liveregions) : -ENOMEM;
1348 mlog_errno(ret); 1342 mlog_errno(ret);
1349 goto bail; 1343 goto bail;
1350 } 1344 }
@@ -1358,9 +1352,7 @@ static int o2hb_debug_init(void)
1358 sizeof(o2hb_quorum_region_bitmap), 1352 sizeof(o2hb_quorum_region_bitmap),
1359 O2NM_MAX_REGIONS, 1353 O2NM_MAX_REGIONS,
1360 o2hb_quorum_region_bitmap); 1354 o2hb_quorum_region_bitmap);
1361 if (IS_ERR_OR_NULL(o2hb_debug_quorumregions)) { 1355 if (!o2hb_debug_quorumregions) {
1362 ret = o2hb_debug_quorumregions ?
1363 PTR_ERR(o2hb_debug_quorumregions) : -ENOMEM;
1364 mlog_errno(ret); 1356 mlog_errno(ret);
1365 goto bail; 1357 goto bail;
1366 } 1358 }
@@ -1374,9 +1366,7 @@ static int o2hb_debug_init(void)
1374 sizeof(o2hb_failed_region_bitmap), 1366 sizeof(o2hb_failed_region_bitmap),
1375 O2NM_MAX_REGIONS, 1367 O2NM_MAX_REGIONS,
1376 o2hb_failed_region_bitmap); 1368 o2hb_failed_region_bitmap);
1377 if (IS_ERR_OR_NULL(o2hb_debug_failedregions)) { 1369 if (!o2hb_debug_failedregions) {
1378 ret = o2hb_debug_failedregions ?
1379 PTR_ERR(o2hb_debug_failedregions) : -ENOMEM;
1380 mlog_errno(ret); 1370 mlog_errno(ret);
1381 goto bail; 1371 goto bail;
1382 } 1372 }
@@ -2010,8 +2000,7 @@ static int o2hb_debug_region_init(struct o2hb_region *reg, struct dentry *dir)
2010 2000
2011 reg->hr_debug_dir = 2001 reg->hr_debug_dir =
2012 debugfs_create_dir(config_item_name(&reg->hr_item), dir); 2002 debugfs_create_dir(config_item_name(&reg->hr_item), dir);
2013 if (IS_ERR_OR_NULL(reg->hr_debug_dir)) { 2003 if (!reg->hr_debug_dir) {
2014 ret = reg->hr_debug_dir ? PTR_ERR(reg->hr_debug_dir) : -ENOMEM;
2015 mlog_errno(ret); 2004 mlog_errno(ret);
2016 goto bail; 2005 goto bail;
2017 } 2006 }
@@ -2024,9 +2013,7 @@ static int o2hb_debug_region_init(struct o2hb_region *reg, struct dentry *dir)
2024 O2HB_DB_TYPE_REGION_LIVENODES, 2013 O2HB_DB_TYPE_REGION_LIVENODES,
2025 sizeof(reg->hr_live_node_bitmap), 2014 sizeof(reg->hr_live_node_bitmap),
2026 O2NM_MAX_NODES, reg); 2015 O2NM_MAX_NODES, reg);
2027 if (IS_ERR_OR_NULL(reg->hr_debug_livenodes)) { 2016 if (!reg->hr_debug_livenodes) {
2028 ret = reg->hr_debug_livenodes ?
2029 PTR_ERR(reg->hr_debug_livenodes) : -ENOMEM;
2030 mlog_errno(ret); 2017 mlog_errno(ret);
2031 goto bail; 2018 goto bail;
2032 } 2019 }
@@ -2038,9 +2025,7 @@ static int o2hb_debug_region_init(struct o2hb_region *reg, struct dentry *dir)
2038 sizeof(*(reg->hr_db_regnum)), 2025 sizeof(*(reg->hr_db_regnum)),
2039 O2HB_DB_TYPE_REGION_NUMBER, 2026 O2HB_DB_TYPE_REGION_NUMBER,
2040 0, O2NM_MAX_NODES, reg); 2027 0, O2NM_MAX_NODES, reg);
2041 if (IS_ERR_OR_NULL(reg->hr_debug_regnum)) { 2028 if (!reg->hr_debug_regnum) {
2042 ret = reg->hr_debug_regnum ?
2043 PTR_ERR(reg->hr_debug_regnum) : -ENOMEM;
2044 mlog_errno(ret); 2029 mlog_errno(ret);
2045 goto bail; 2030 goto bail;
2046 } 2031 }
@@ -2052,9 +2037,7 @@ static int o2hb_debug_region_init(struct o2hb_region *reg, struct dentry *dir)
2052 sizeof(*(reg->hr_db_elapsed_time)), 2037 sizeof(*(reg->hr_db_elapsed_time)),
2053 O2HB_DB_TYPE_REGION_ELAPSED_TIME, 2038 O2HB_DB_TYPE_REGION_ELAPSED_TIME,
2054 0, 0, reg); 2039 0, 0, reg);
2055 if (IS_ERR_OR_NULL(reg->hr_debug_elapsed_time)) { 2040 if (!reg->hr_debug_elapsed_time) {
2056 ret = reg->hr_debug_elapsed_time ?
2057 PTR_ERR(reg->hr_debug_elapsed_time) : -ENOMEM;
2058 mlog_errno(ret); 2041 mlog_errno(ret);
2059 goto bail; 2042 goto bail;
2060 } 2043 }
@@ -2066,16 +2049,13 @@ static int o2hb_debug_region_init(struct o2hb_region *reg, struct dentry *dir)
2066 sizeof(*(reg->hr_db_pinned)), 2049 sizeof(*(reg->hr_db_pinned)),
2067 O2HB_DB_TYPE_REGION_PINNED, 2050 O2HB_DB_TYPE_REGION_PINNED,
2068 0, 0, reg); 2051 0, 0, reg);
2069 if (IS_ERR_OR_NULL(reg->hr_debug_pinned)) { 2052 if (!reg->hr_debug_pinned) {
2070 ret = reg->hr_debug_pinned ?
2071 PTR_ERR(reg->hr_debug_pinned) : -ENOMEM;
2072 mlog_errno(ret); 2053 mlog_errno(ret);
2073 goto bail; 2054 goto bail;
2074 } 2055 }
2075 2056
2076 return 0; 2057 ret = 0;
2077bail: 2058bail:
2078 debugfs_remove_recursive(reg->hr_debug_dir);
2079 return ret; 2059 return ret;
2080} 2060}
2081 2061
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 956edf67be20..8b23aa2f52dd 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -2959,7 +2959,7 @@ static int ocfs2_dlm_init_debug(struct ocfs2_super *osb)
2959 osb->osb_debug_root, 2959 osb->osb_debug_root,
2960 osb, 2960 osb,
2961 &ocfs2_dlm_debug_fops); 2961 &ocfs2_dlm_debug_fops);
2962 if (IS_ERR_OR_NULL(dlm_debug->d_locking_state)) { 2962 if (!dlm_debug->d_locking_state) {
2963 ret = -EINVAL; 2963 ret = -EINVAL;
2964 mlog(ML_ERROR, 2964 mlog(ML_ERROR,
2965 "Unable to create locking state debugfs file.\n"); 2965 "Unable to create locking state debugfs file.\n");
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 837ddce4b659..403c5660b306 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -1112,7 +1112,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
1112 1112
1113 osb->osb_debug_root = debugfs_create_dir(osb->uuid_str, 1113 osb->osb_debug_root = debugfs_create_dir(osb->uuid_str,
1114 ocfs2_debugfs_root); 1114 ocfs2_debugfs_root);
1115 if (IS_ERR_OR_NULL(osb->osb_debug_root)) { 1115 if (!osb->osb_debug_root) {
1116 status = -EINVAL; 1116 status = -EINVAL;
1117 mlog(ML_ERROR, "Unable to create per-mount debugfs root.\n"); 1117 mlog(ML_ERROR, "Unable to create per-mount debugfs root.\n");
1118 goto read_super_error; 1118 goto read_super_error;
@@ -1122,7 +1122,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
1122 osb->osb_debug_root, 1122 osb->osb_debug_root,
1123 osb, 1123 osb,
1124 &ocfs2_osb_debug_fops); 1124 &ocfs2_osb_debug_fops);
1125 if (IS_ERR_OR_NULL(osb->osb_ctxt)) { 1125 if (!osb->osb_ctxt) {
1126 status = -EINVAL; 1126 status = -EINVAL;
1127 mlog_errno(status); 1127 mlog_errno(status);
1128 goto read_super_error; 1128 goto read_super_error;
@@ -1606,9 +1606,8 @@ static int __init ocfs2_init(void)
1606 } 1606 }
1607 1607
1608 ocfs2_debugfs_root = debugfs_create_dir("ocfs2", NULL); 1608 ocfs2_debugfs_root = debugfs_create_dir("ocfs2", NULL);
1609 if (IS_ERR_OR_NULL(ocfs2_debugfs_root)) { 1609 if (!ocfs2_debugfs_root) {
1610 status = ocfs2_debugfs_root ? 1610 status = -ENOMEM;
1611 PTR_ERR(ocfs2_debugfs_root) : -ENOMEM;
1612 mlog(ML_ERROR, "Unable to create ocfs2 debugfs root.\n"); 1611 mlog(ML_ERROR, "Unable to create ocfs2 debugfs root.\n");
1613 goto out4; 1612 goto out4;
1614 } 1613 }