From: Sun YangKai <sunk67188@gmail.com>
To: dsterba@suse.cz
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/2] btrfs: more trivial BTRFS_PATH_AUTO_FREE conversions
Date: Wed, 27 Aug 2025 20:24:33 +0800 [thread overview]
Message-ID: <5006600.GXAFRqVoOG@saltykitkat> (raw)
In-Reply-To: <20250826165619.GC29826@twin.jikos.cz>
> On Fri, Aug 22, 2025 at 11:51:18PM +0800, Sun YangKai wrote:
> > > Please split the patch to parts that have the described trivial changes,
> > > and then one patch per function in case it's not trivial and needs some
> > > adjustments.
> >
> > After learning more about the auto-free/cleanup mechanism, I realized that
> > its only advantage is to eliminate the need for the goto out; pattern.
> > Therefore, it seems unnecessary to apply this conversion in non-trivial
> > cases.
> I wouldn't say it's the only advantage, the code readability is also
> improved. The path is an auxiliary object and if the freeing is handled
> automatically then it reduces the cognitive load and the error cleanup
> paths.
>
> > Moreover, if the cleanup code contains other logic, it might be better to
> > leave it unchanged even in trivial cases.
>
> Depends on what we want. So far we've started with the path auto
> cleaning but there are more possibilities like using the raw __free
> cleanup with kfree. If this is combined and leads to simpler exit and
> cleanup blocks I think it's worth. In the trivial cases it's clear it
> does not interfere with the rest of the code and does not complicate any
> logic there.
>
> > > The freeing followed by other code can be still converted to auto
> > > cleaning but there must be an explicit path = NULL after the free.
> >
> > I'm sorry, I didn't understand. If the freeing is followed by other code,
> > maybe we could just leave them untouched?
>
> Maybe yes, this is up to consideration on a per site basis, I've seen
> examples where conversion to auto path cleaning would not hurt.
>
> Let me know if you want to continue with this because I think you don't
> seem to see the value in the conversions (which is fine of course).
I apologize if my previous comments came across as unclear — I certainly see
the value in the conversions. My intention was actually to discuss in which
specific scenarios these conversions would be most proper, so that we can align
on how to apply them.
Based on your suggestions, I'll restrict the conversions to the following
scenarios:
1. Cases where there are no operations between btrfs_free_path and the
function return.
2. Cases where only simple cleanup operations (such as kfree, kvfree,
clear_bit, and fs_path_free) are present between btrfs_free_path and the
function return.
Please let me know if these criteria align with what you had in mind.
Thanks,
Sun Yangkai
next prev parent reply other threads:[~2025-08-27 12:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-21 13:12 [PATCH v2 0/2] btrfs: more trivial BTRFS_PATH_AUTO_FREE conversions Sun YangKai
2025-08-21 13:12 ` [PATCH 1/2] btrfs: get_inode_info(): check NULL info parameter early Sun YangKai
2025-08-22 12:50 ` David Sterba
2025-08-22 12:58 ` Sun YangKai
2025-08-30 7:00 ` kernel test robot
2025-08-21 13:12 ` [PATCH 2/2] btrfs: more trivial BTRFS_PATH_AUTO_FREE conversions Sun YangKai
2025-08-22 13:01 ` David Sterba
2025-08-22 13:08 ` Sun YangKai
2025-08-22 15:51 ` Sun YangKai
2025-08-26 16:56 ` David Sterba
2025-08-27 12:24 ` Sun YangKai [this message]
2025-08-29 0:02 ` David Sterba
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=5006600.GXAFRqVoOG@saltykitkat \
--to=sunk67188@gmail.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@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;
as well as URLs for NNTP newsgroup(s).