]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: decentralize transaction aborts in create_reloc_root()
authorJohannes Thumshirn <johannes.thumshirn@wdc.com>
Mon, 22 Jun 2026 08:22:24 +0000 (10:22 +0200)
committerDavid Sterba <dsterba@suse.com>
Tue, 30 Jun 2026 00:02:02 +0000 (02:02 +0200)
Decentralize transaction aborts in create_reloc_root(), so that it is
obvious which call failed and what caused the transaction abort.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/relocation.c

index 9447d009a9a0e98ea02e4186fe58faa44d1f5e83..0d63d117db596a0bc5d222e64ffb108617e413be 100644 (file)
@@ -719,21 +719,19 @@ static struct btrfs_root *create_reloc_root(struct btrfs_trans_handle *trans,
 
        ret = btrfs_insert_root(trans, fs_info->tree_root,
                                &root_key, root_item);
-       if (ret)
-               goto abort;
+       if (unlikely(ret)) {
+               btrfs_abort_transaction(trans, ret);
+               return ERR_PTR(ret);
+       }
 
        reloc_root = btrfs_read_tree_root(fs_info->tree_root, &root_key);
        if (IS_ERR(reloc_root)) {
-               ret = PTR_ERR(reloc_root);
-               goto abort;
+               btrfs_abort_transaction(trans, PTR_ERR(reloc_root));
+               return ERR_CAST(reloc_root);
        }
        set_bit(BTRFS_ROOT_SHAREABLE, &reloc_root->state);
        btrfs_set_root_last_trans(reloc_root, trans->transid);
        return reloc_root;
-
-abort:
-       btrfs_abort_transaction(trans, ret);
-       return ERR_PTR(ret);
 }
 
 /*