[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250414093725.GC16750@suse.cz>
Date: Mon, 14 Apr 2025 11:37:26 +0200
From: David Sterba <dsterba@...e.cz>
To: Yangtao Li <frank.li@...o.com>
Cc: clm@...com, josef@...icpanda.com, dsterba@...e.com,
linux-btrfs@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] btrfs: make error handling more appropriate in
btrfs_delayed_ref_init()
On Thu, Apr 10, 2025 at 05:38:58AM -0600, Yangtao Li wrote:
> 1. Remove unnecessary goto
> 2. Make the execution logic of the function jumped by goto more appropriate
>
> Signed-off-by: Yangtao Li <frank.li@...o.com>
> ---
> fs/btrfs/delayed-ref.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
> index 98c5b61dabe8..e984f1761afa 100644
> --- a/fs/btrfs/delayed-ref.c
> +++ b/fs/btrfs/delayed-ref.c
> @@ -1339,11 +1339,11 @@ int __init btrfs_delayed_ref_init(void)
> {
> btrfs_delayed_ref_head_cachep = KMEM_CACHE(btrfs_delayed_ref_head, 0);
> if (!btrfs_delayed_ref_head_cachep)
> - goto fail;
> + return -ENOMEM;
>
> btrfs_delayed_ref_node_cachep = KMEM_CACHE(btrfs_delayed_ref_node, 0);
> if (!btrfs_delayed_ref_node_cachep)
> - goto fail;
> + goto out;
>
> btrfs_delayed_extent_op_cachep = KMEM_CACHE(btrfs_delayed_extent_op, 0);
> if (!btrfs_delayed_extent_op_cachep)
> @@ -1351,6 +1351,8 @@ int __init btrfs_delayed_ref_init(void)
>
> return 0;
> fail:
> - btrfs_delayed_ref_exit();
> + kmem_cache_destroy(btrfs_delayed_ref_node_cachep);
> +out:
> + kmem_cache_destroy(btrfs_delayed_ref_head_cachep);
This is partially duplicating btrfs_delayed_ref_exit(), I'd rather reuse
the exit helper.
I've checked if this can be done elsewhere, seems that there's only one
other case btrfs_bioset_init(), which is partially duplicating
btrfs_bioset_exit(). All other init/exit functions are trivial and
allocate one structure. So if you want to do that cleanup, please update
btrfs_bioset_init() to the preferred pattern. Thanks.
Powered by blists - more mailing lists