diff options
| author | David Sterba <dsterba@suse.com> | 2025-04-30 19:45:21 +0300 |
|---|---|---|
| committer | David Sterba <dsterba@suse.com> | 2025-05-15 15:30:54 +0300 |
| commit | 8c4cfa99c2cdf90c2444167d9aab075885019936 (patch) | |
| tree | 01e1151044032be9cdc31863a09fd3954e097081 | |
| parent | 11f25fad92ade05c5f84907222ea3f88afdc1767 (diff) | |
| download | linux-8c4cfa99c2cdf90c2444167d9aab075885019936.tar.xz | |
btrfs: move transaction aborts to the error site in add_to_free_space_tree()
Transaction aborts should be done next to the place the error happens,
which was not done in add_to_free_space_tree().
Signed-off-by: David Sterba <dsterba@suse.com>
| -rw-r--r-- | fs/btrfs/free-space-tree.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c index ffe98bea6927..0c573d46639a 100644 --- a/fs/btrfs/free-space-tree.c +++ b/fs/btrfs/free-space-tree.c @@ -1045,6 +1045,7 @@ int add_to_free_space_tree(struct btrfs_trans_handle *trans, path = btrfs_alloc_path(); if (!path) { ret = -ENOMEM; + btrfs_abort_transaction(trans, ret); goto out; } @@ -1052,18 +1053,19 @@ int add_to_free_space_tree(struct btrfs_trans_handle *trans, if (!block_group) { DEBUG_WARN("no block group found for start=%llu", start); ret = -ENOENT; + btrfs_abort_transaction(trans, ret); goto out; } mutex_lock(&block_group->free_space_lock); ret = __add_to_free_space_tree(trans, block_group, path, start, size); mutex_unlock(&block_group->free_space_lock); + if (ret) + btrfs_abort_transaction(trans, ret); btrfs_put_block_group(block_group); out: btrfs_free_path(path); - if (ret) - btrfs_abort_transaction(trans, ret); return ret; } |
