Skip to content

Commit f61aa7b

Browse files
fdmananakdave
authored andcommitted
btrfs: do not BUG_ON() on tree mod log failure at insert_new_root()
At insert_new_root(), instead of doing a BUG_ON() in case we fail to record the tree mod log operation, just return the error to the callers after releasing the allocated tree block. At this point we haven't made any changes to the b+tree, so we haven't left it in an inconsistent state and therefore have no need to abort the transaction. All we need to do is to unlock and free the extent buffer we just allocated with the purpose of making it the new root. Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 11d6ae0 commit f61aa7b

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

fs/btrfs/ctree.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2964,7 +2964,12 @@ static noinline int insert_new_root(struct btrfs_trans_handle *trans,
29642964

29652965
old = root->node;
29662966
ret = btrfs_tree_mod_log_insert_root(root->node, c, false);
2967-
BUG_ON(ret < 0);
2967+
if (ret < 0) {
2968+
btrfs_free_tree_block(trans, btrfs_root_id(root), c, 0, 1);
2969+
btrfs_tree_unlock(c);
2970+
free_extent_buffer(c);
2971+
return ret;
2972+
}
29682973
rcu_assign_pointer(root->node, c);
29692974

29702975
/* the super has an extra ref to root->node */

0 commit comments

Comments
 (0)