From: David Sterba <dsterba@suse.cz>
To: Yangtao Li <frank.li@vivo.com>
Cc: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] btrfs: make error handling more appropriate in btrfs_delayed_ref_init()
Date: Mon, 14 Apr 2025 11:37:26 +0200 [thread overview]
Message-ID: <20250414093725.GC16750@suse.cz> (raw)
In-Reply-To: <20250410113858.149032-1-frank.li@vivo.com>
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@vivo.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.
prev parent reply other threads:[~2025-04-14 9:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-10 11:38 [PATCH] btrfs: make error handling more appropriate in btrfs_delayed_ref_init() Yangtao Li
2025-04-14 9:37 ` David Sterba [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250414093725.GC16750@suse.cz \
--to=dsterba@suse.cz \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=frank.li@vivo.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox