Re: [PATCH v2] btrfs: decentralize transaction aborts in create_reloc_root

Filipe Manana <[email protected]>
Newsgroups org.kernel.vger.linux-btrfs
Message-ID <CAL3q7H7Xfo+=E1D=uxNX=7NsZoeBMKxVdvwd_qwi6-R2McMNzQ@mail.gmail.com>
On Mon, Jun 22, 2026 at 9:27 AM Johannes Thumshirn
<[email protected]> wrote:
>
> Decentralize transaction aborts in create_reloc_root(), so that it is
> obvious which call failed and what caused the transaction abort.
>
> Signed-off-by: Johannes Thumshirn <[email protected]>

Reviewed-by: Filipe Manana <[email protected]>

Thanks.

> ---
>  Changes to v1:
>  - don't assign ret in case btrfs_read_tree_root() fails
>
>  fs/btrfs/relocation.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index 8cac49fa6f6f..73d9948b5382 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -720,21 +720,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 (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);
>  }
>
>  /*
> --
> 2.54.0
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.