Re: [PATCH 1/7] btrfs: do more trivial BTRFS_PATH_AUTO_FREE conversions

David Disseldorp
2025-04-02T23:14:21Z

On Thu, 3 Apr 2025 00:02:25 +0200, David Sterba wrote:

> On Wed, Apr 02, 2025 at 11:39:51AM +1100, David Disseldorp wrote:
> > Hi David
> >
> > On Wed, 2 Apr 2025 01:18:06 +0200, David Sterba wrote:
> >
> > > @@ -308,7 +308,7 @@ int btrfs_truncate_free_space_cache(struct btrfs_trans_handle *trans,
> > > bool locked = false;
> > >
> > > if (block_group) {
> > > - struct btrfs_path *path = btrfs_alloc_path();
> > > + BTRFS_PATH_AUTO_FREE(path);
> > >
> > > if (!path) {
> > > ret = -ENOMEM;
> >
> > This one looks broken. btrfs_search_slot() needs it allocated.
>
> Sorry, I don't see what you mean. There's no btrfs_search_slot() in
> btrfs_truncate_free_space_cache(), perhaps you mean a different
> function?

This will jump straight through to the -ENOMEM goto fail path... What am
I missing here?
With 91e5bfe317d8f8471fbaa3e70cf66cae1314a516 I see:
#define BTRFS_PATH_AUTO_FREE(path_name) \
struct btrfs_path *path_name __free(btrfs_free_path) = NULL

I would expect your change to instead be something like:

BTRFS_PATH_AUTO_FREE(path);
path = btrfs_alloc_path();