Skip to content

Commit a788183

Browse files
kdavegregkh
authored andcommitted
btrfs: move transaction aborts to the error site in add_block_group_free_space()
[ Upstream commit b63c8c1 ] 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 <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> Stable-dep-of: 1f06c94 ("btrfs: always abort transaction on failure to add block group to free space tree") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9d0c2d1 commit a788183

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/btrfs/free-space-tree.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,16 +1456,17 @@ int add_block_group_free_space(struct btrfs_trans_handle *trans,
14561456
path = btrfs_alloc_path();
14571457
if (!path) {
14581458
ret = -ENOMEM;
1459+
btrfs_abort_transaction(trans, ret);
14591460
goto out;
14601461
}
14611462

14621463
ret = __add_block_group_free_space(trans, block_group, path);
1464+
if (ret)
1465+
btrfs_abort_transaction(trans, ret);
14631466

14641467
out:
14651468
btrfs_free_path(path);
14661469
mutex_unlock(&block_group->free_space_lock);
1467-
if (ret)
1468-
btrfs_abort_transaction(trans, ret);
14691470
return ret;
14701471
}
14711472

0 commit comments

Comments
 (0)