]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: move transaction aborts to the error site in remove_from_free_space_tree()
authorDavid Sterba <dsterba@suse.com>
Wed, 30 Apr 2025 16:45:20 +0000 (18:45 +0200)
committerDavid Sterba <dsterba@suse.com>
Thu, 15 May 2025 12:30:54 +0000 (14:30 +0200)
Transaction aborts should be done next to the place the error happens,
which was not done in remove_from_free_space_tree().

Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/free-space-tree.c

index ef39d1034435249b750b8dfbbfbb65e65c219331..ffe98bea6927f9a292a7cbd49969077e9d5724e6 100644 (file)
@@ -850,6 +850,7 @@ int remove_from_free_space_tree(struct btrfs_trans_handle *trans,
        path = btrfs_alloc_path();
        if (!path) {
                ret = -ENOMEM;
+               btrfs_abort_transaction(trans, ret);
                goto out;
        }
 
@@ -857,6 +858,7 @@ int remove_from_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;
        }
 
@@ -864,12 +866,12 @@ int remove_from_free_space_tree(struct btrfs_trans_handle *trans,
        ret = __remove_from_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;
 }