summaryrefslogtreecommitdiff
path: root/extent-tree.c
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2018-08-03 13:50:17 +0800
committerDavid Sterba <dsterba@suse.com>2018-10-23 14:48:40 +0200
commitf2cd3f394bb5162cf83708920f518303e246b866 (patch)
tree7ddc68e174dd1b92320dc39b32480073bb7cef17 /extent-tree.c
parent739313d223123b82d2b0ccb9846213f43f6101d1 (diff)
btrfs-progs: exit gracefully if we hit ENOSPC when allocating tree block
When running test fuzz/003, we could hit the following BUG_ON: ====== RUN MAYFAIL btrfs check --init-csum-tree tests//fuzz-tests/images/bko-155621-bad-block-group-offset.raw.restored Unable to find block group for 0 Unable to find block group for 0 Unable to find block group for 0 extent-tree.c:2657: alloc_tree_block: BUG_ON `ret` triggered, value -28 failed (ignored, ret=134): btrfs check --init-csum-tree tests/fuzz-tests/images/bko-155621-bad-block-group-offset.raw.restored mayfail: returned code 134 (SIGABRT), not ignored test failed for case 003-multi-check-unmounted Just remove that BUG_ON() and allow us to exit gracefully, the caller handles the errors. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'extent-tree.c')
-rw-r--r--extent-tree.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/extent-tree.c b/extent-tree.c
index 5d49af5a..955d5653 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -2740,7 +2740,8 @@ static int alloc_tree_block(struct btrfs_trans_handle *trans,
int ret;
ret = btrfs_reserve_extent(trans, root, num_bytes, empty_size,
hint_byte, search_end, ins, 0);
- BUG_ON(ret);
+ if (ret < 0)
+ return ret;
if (root_objectid == BTRFS_EXTENT_TREE_OBJECTID) {
struct pending_extent_op *extent_op;