From: David Sterba Date: Sat, 17 May 2025 19:03:57 +0000 (+0200) Subject: btrfs: move transaction aborts to the error site in add_block_group_free_space() X-Git-Tag: block-6.17-20250808~77^2~196 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=b63c8c1ede4407835cb8c8bed2014d96619389f3;p=linux-block.git btrfs: move transaction aborts to the error site in add_block_group_free_space() Transaction aborts should be done next to the place the error happens, which was not done in add_block_group_free_space(). Reviewed-by: Filipe Manana Signed-off-by: David Sterba --- diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c index 0755656a270e..9eb9858e8e99 100644 --- a/fs/btrfs/free-space-tree.c +++ b/fs/btrfs/free-space-tree.c @@ -1456,16 +1456,17 @@ int add_block_group_free_space(struct btrfs_trans_handle *trans, path = btrfs_alloc_path(); if (!path) { ret = -ENOMEM; + btrfs_abort_transaction(trans, ret); goto out; } ret = __add_block_group_free_space(trans, block_group, path); + if (ret) + btrfs_abort_transaction(trans, ret); out: btrfs_free_path(path); mutex_unlock(&block_group->free_space_lock); - if (ret) - btrfs_abort_transaction(trans, ret); return ret; }