Skip to content

Commit 873ed72

Browse files
Jia Ruiakpm00
authored andcommitted
ocfs2: replace BUG_ON() at ocfs2_num_free_extents() with ocfs2_error()
The BUG_ON() at ocfs2_num_free_extents() handles the error that l_tree_deepth of leaf extent block just read form disk is invalid. This error is mostly caused by file system metadata corruption on the disk. There is no need to call BUG_ON() to handle such errors. We can return error code, since the caller can deal with errors from ocfs2_num_free_extents(). Also, we should make the file system read-only to avoid the damage from expanding. Therefore, BUG_ON() is removed and ocfs2_error() is called instead. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Jia Rui <[email protected]> Reviewed-by: Joseph Qi <[email protected]> Cc: Mark Fasheh <[email protected]> Cc: Joel Becker <[email protected]> Cc: Junxiao Bi <[email protected]> Cc: Changwei Ge <[email protected]> Cc: Gang He <[email protected]> Cc: Jun Piao <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 5176140 commit 873ed72

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

fs/ocfs2/alloc.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,14 @@ int ocfs2_num_free_extents(struct ocfs2_extent_tree *et)
967967
el = &eb->h_list;
968968
}
969969

970-
BUG_ON(el->l_tree_depth != 0);
970+
if (el->l_tree_depth != 0) {
971+
retval = ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
972+
"Owner %llu has leaf extent block %llu with an invalid l_tree_depth of %u\n",
973+
(unsigned long long)ocfs2_metadata_cache_owner(et->et_ci),
974+
(unsigned long long)last_eb_blk,
975+
le16_to_cpu(el->l_tree_depth));
976+
goto bail;
977+
}
971978

972979
retval = le16_to_cpu(el->l_count) - le16_to_cpu(el->l_next_free_rec);
973980
bail:

0 commit comments

Comments
 (0)