From f2cd3f394bb5162cf83708920f518303e246b866 Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Fri, 3 Aug 2018 13:50:17 +0800 Subject: 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 Reviewed-by: Nikolay Borisov Signed-off-by: David Sterba --- extent-tree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'extent-tree.c') 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; -- cgit v1.2.3