Commit 8f443e23 authored by Linus Torvalds's avatar Linus Torvalds

Revert "ocfs2: incorrect check for debugfs returns"

This reverts commit e2ac55b6.

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: default avatarHuang Ying <ying.huang@intel.com>
Acked-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Acked-by: default avatarChengyu Song <csong84@gatech.edu>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 646da631
...@@ -1312,9 +1312,7 @@ static int o2hb_debug_init(void) ...@@ -1312,9 +1312,7 @@ static int o2hb_debug_init(void)
int ret = -ENOMEM; int ret = -ENOMEM;
o2hb_debug_dir = debugfs_create_dir(O2HB_DEBUG_DIR, NULL); o2hb_debug_dir = debugfs_create_dir(O2HB_DEBUG_DIR, NULL);
if (IS_ERR_OR_NULL(o2hb_debug_dir)) { if (!o2hb_debug_dir) {
ret = o2hb_debug_dir ?
PTR_ERR(o2hb_debug_dir) : -ENOMEM;
mlog_errno(ret); mlog_errno(ret);
goto bail; goto bail;
} }
...@@ -1327,9 +1325,7 @@ static int o2hb_debug_init(void) ...@@ -1327,9 +1325,7 @@ static int o2hb_debug_init(void)
sizeof(o2hb_live_node_bitmap), sizeof(o2hb_live_node_bitmap),
O2NM_MAX_NODES, O2NM_MAX_NODES,
o2hb_live_node_bitmap); o2hb_live_node_bitmap);
if (IS_ERR_OR_NULL(o2hb_debug_livenodes)) { if (!o2hb_debug_livenodes) {
ret = o2hb_debug_livenodes ?
PTR_ERR(o2hb_debug_livenodes) : -ENOMEM;
mlog_errno(ret); mlog_errno(ret);
goto bail; goto bail;
} }
...@@ -1342,9 +1338,7 @@ static int o2hb_debug_init(void) ...@@ -1342,9 +1338,7 @@ static int o2hb_debug_init(void)
sizeof(o2hb_live_region_bitmap), sizeof(o2hb_live_region_bitmap),
O2NM_MAX_REGIONS, O2NM_MAX_REGIONS,
o2hb_live_region_bitmap); o2hb_live_region_bitmap);
if (IS_ERR_OR_NULL(o2hb_debug_liveregions)) { if (!o2hb_debug_liveregions) {
ret = o2hb_debug_liveregions ?
PTR_ERR(o2hb_debug_liveregions) : -ENOMEM;
mlog_errno(ret); mlog_errno(ret);
goto bail; goto bail;
} }
...@@ -1358,9 +1352,7 @@ static int o2hb_debug_init(void) ...@@ -1358,9 +1352,7 @@ static int o2hb_debug_init(void)
sizeof(o2hb_quorum_region_bitmap), sizeof(o2hb_quorum_region_bitmap),
O2NM_MAX_REGIONS, O2NM_MAX_REGIONS,
o2hb_quorum_region_bitmap); o2hb_quorum_region_bitmap);
if (IS_ERR_OR_NULL(o2hb_debug_quorumregions)) { if (!o2hb_debug_quorumregions) {
ret = o2hb_debug_quorumregions ?
PTR_ERR(o2hb_debug_quorumregions) : -ENOMEM;
mlog_errno(ret); mlog_errno(ret);
goto bail; goto bail;
} }
...@@ -1374,9 +1366,7 @@ static int o2hb_debug_init(void) ...@@ -1374,9 +1366,7 @@ static int o2hb_debug_init(void)
sizeof(o2hb_failed_region_bitmap), sizeof(o2hb_failed_region_bitmap),
O2NM_MAX_REGIONS, O2NM_MAX_REGIONS,
o2hb_failed_region_bitmap); o2hb_failed_region_bitmap);
if (IS_ERR_OR_NULL(o2hb_debug_failedregions)) { if (!o2hb_debug_failedregions) {
ret = o2hb_debug_failedregions ?
PTR_ERR(o2hb_debug_failedregions) : -ENOMEM;
mlog_errno(ret); mlog_errno(ret);
goto bail; goto bail;
} }
...@@ -2010,8 +2000,7 @@ static int o2hb_debug_region_init(struct o2hb_region *reg, struct dentry *dir) ...@@ -2010,8 +2000,7 @@ static int o2hb_debug_region_init(struct o2hb_region *reg, struct dentry *dir)
reg->hr_debug_dir = reg->hr_debug_dir =
debugfs_create_dir(config_item_name(&reg->hr_item), dir); debugfs_create_dir(config_item_name(&reg->hr_item), dir);
if (IS_ERR_OR_NULL(reg->hr_debug_dir)) { if (!reg->hr_debug_dir) {
ret = reg->hr_debug_dir ? PTR_ERR(reg->hr_debug_dir) : -ENOMEM;
mlog_errno(ret); mlog_errno(ret);
goto bail; goto bail;
} }
...@@ -2024,9 +2013,7 @@ static int o2hb_debug_region_init(struct o2hb_region *reg, struct dentry *dir) ...@@ -2024,9 +2013,7 @@ static int o2hb_debug_region_init(struct o2hb_region *reg, struct dentry *dir)
O2HB_DB_TYPE_REGION_LIVENODES, O2HB_DB_TYPE_REGION_LIVENODES,
sizeof(reg->hr_live_node_bitmap), sizeof(reg->hr_live_node_bitmap),
O2NM_MAX_NODES, reg); O2NM_MAX_NODES, reg);
if (IS_ERR_OR_NULL(reg->hr_debug_livenodes)) { if (!reg->hr_debug_livenodes) {
ret = reg->hr_debug_livenodes ?
PTR_ERR(reg->hr_debug_livenodes) : -ENOMEM;
mlog_errno(ret); mlog_errno(ret);
goto bail; goto bail;
} }
...@@ -2038,9 +2025,7 @@ static int o2hb_debug_region_init(struct o2hb_region *reg, struct dentry *dir) ...@@ -2038,9 +2025,7 @@ static int o2hb_debug_region_init(struct o2hb_region *reg, struct dentry *dir)
sizeof(*(reg->hr_db_regnum)), sizeof(*(reg->hr_db_regnum)),
O2HB_DB_TYPE_REGION_NUMBER, O2HB_DB_TYPE_REGION_NUMBER,
0, O2NM_MAX_NODES, reg); 0, O2NM_MAX_NODES, reg);
if (IS_ERR_OR_NULL(reg->hr_debug_regnum)) { if (!reg->hr_debug_regnum) {
ret = reg->hr_debug_regnum ?
PTR_ERR(reg->hr_debug_regnum) : -ENOMEM;
mlog_errno(ret); mlog_errno(ret);
goto bail; goto bail;
} }
...@@ -2052,9 +2037,7 @@ static int o2hb_debug_region_init(struct o2hb_region *reg, struct dentry *dir) ...@@ -2052,9 +2037,7 @@ static int o2hb_debug_region_init(struct o2hb_region *reg, struct dentry *dir)
sizeof(*(reg->hr_db_elapsed_time)), sizeof(*(reg->hr_db_elapsed_time)),
O2HB_DB_TYPE_REGION_ELAPSED_TIME, O2HB_DB_TYPE_REGION_ELAPSED_TIME,
0, 0, reg); 0, 0, reg);
if (IS_ERR_OR_NULL(reg->hr_debug_elapsed_time)) { if (!reg->hr_debug_elapsed_time) {
ret = reg->hr_debug_elapsed_time ?
PTR_ERR(reg->hr_debug_elapsed_time) : -ENOMEM;
mlog_errno(ret); mlog_errno(ret);
goto bail; goto bail;
} }
...@@ -2066,16 +2049,13 @@ static int o2hb_debug_region_init(struct o2hb_region *reg, struct dentry *dir) ...@@ -2066,16 +2049,13 @@ static int o2hb_debug_region_init(struct o2hb_region *reg, struct dentry *dir)
sizeof(*(reg->hr_db_pinned)), sizeof(*(reg->hr_db_pinned)),
O2HB_DB_TYPE_REGION_PINNED, O2HB_DB_TYPE_REGION_PINNED,
0, 0, reg); 0, 0, reg);
if (IS_ERR_OR_NULL(reg->hr_debug_pinned)) { if (!reg->hr_debug_pinned) {
ret = reg->hr_debug_pinned ?
PTR_ERR(reg->hr_debug_pinned) : -ENOMEM;
mlog_errno(ret); mlog_errno(ret);
goto bail; goto bail;
} }
return 0; ret = 0;
bail: bail:
debugfs_remove_recursive(reg->hr_debug_dir);
return ret; return ret;
} }
......
...@@ -2959,7 +2959,7 @@ static int ocfs2_dlm_init_debug(struct ocfs2_super *osb) ...@@ -2959,7 +2959,7 @@ static int ocfs2_dlm_init_debug(struct ocfs2_super *osb)
osb->osb_debug_root, osb->osb_debug_root,
osb, osb,
&ocfs2_dlm_debug_fops); &ocfs2_dlm_debug_fops);
if (IS_ERR_OR_NULL(dlm_debug->d_locking_state)) { if (!dlm_debug->d_locking_state) {
ret = -EINVAL; ret = -EINVAL;
mlog(ML_ERROR, mlog(ML_ERROR,
"Unable to create locking state debugfs file.\n"); "Unable to create locking state debugfs file.\n");
......
...@@ -1112,7 +1112,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) ...@@ -1112,7 +1112,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
osb->osb_debug_root = debugfs_create_dir(osb->uuid_str, osb->osb_debug_root = debugfs_create_dir(osb->uuid_str,
ocfs2_debugfs_root); ocfs2_debugfs_root);
if (IS_ERR_OR_NULL(osb->osb_debug_root)) { if (!osb->osb_debug_root) {
status = -EINVAL; status = -EINVAL;
mlog(ML_ERROR, "Unable to create per-mount debugfs root.\n"); mlog(ML_ERROR, "Unable to create per-mount debugfs root.\n");
goto read_super_error; goto read_super_error;
...@@ -1122,7 +1122,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) ...@@ -1122,7 +1122,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
osb->osb_debug_root, osb->osb_debug_root,
osb, osb,
&ocfs2_osb_debug_fops); &ocfs2_osb_debug_fops);
if (IS_ERR_OR_NULL(osb->osb_ctxt)) { if (!osb->osb_ctxt) {
status = -EINVAL; status = -EINVAL;
mlog_errno(status); mlog_errno(status);
goto read_super_error; goto read_super_error;
...@@ -1606,9 +1606,8 @@ static int __init ocfs2_init(void) ...@@ -1606,9 +1606,8 @@ static int __init ocfs2_init(void)
} }
ocfs2_debugfs_root = debugfs_create_dir("ocfs2", NULL); ocfs2_debugfs_root = debugfs_create_dir("ocfs2", NULL);
if (IS_ERR_OR_NULL(ocfs2_debugfs_root)) { if (!ocfs2_debugfs_root) {
status = ocfs2_debugfs_root ? status = -ENOMEM;
PTR_ERR(ocfs2_debugfs_root) : -ENOMEM;
mlog(ML_ERROR, "Unable to create ocfs2 debugfs root.\n"); mlog(ML_ERROR, "Unable to create ocfs2 debugfs root.\n");
goto out4; goto out4;
} }
......
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