btrfs: replace the BUG_ON() in btrfs_del_root_ref() with proper error handling
PATCH 1/1 btrfs: replace the BUG_ON() in btrfs_del_root_ref() with proper error handling
I hit the BUG_ON() with generic/475 test case, and to my surprise, all callers of btrfs_del_root_ref() are already aborting transaction, thus there is not need for such BUG_ON(), just go to @out label and caller will properly handle the error.
--- fs/btrfs/root-tree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/root-tree.c +2 -1
@@ -334,7 +334,8 @@ int btrfs_del_root_ref(struct btrfs_trans_handle *trans, u64 root_id, key.offset = ref_id; again: ret =btrfs_search_slot (trans, tree_root, &key, path,-1 ,1 ); -BUG_ON (ret <0 ); +if (ret <0 ) + goto out;if (ret ==0 ) { leaf = path->nodes[0 ]; ref = btrfs_item_ptr(leaf, path->slots[0],
Signature · 1 line
2.34.1
Quoted 6 lines · Qu Wenruo
I hit the
BUG_ON()with generic/475 test case, and to my surprise, all callers ofbtrfs_del_root_ref()are already aborting transaction, thus there is not need for suchBUG_ON(), just go to @out label and caller will properly handle the error.Signed-off-by Qu Wenruo <[email protected]>
Thanks,
Josef
Quoted 6 lines · Qu Wenruo
I hit the
BUG_ON()with generic/475 test case, and to my surprise, all callers ofbtrfs_del_root_ref()are already aborting transaction, thus there is not need for suchBUG_ON(), just go to @out label and caller will properly handle the error.Signed-off-by Qu Wenruo <[email protected]>
Added to misc-next, thanks.