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

David Sterba
2025-04-02T22:02:29Z

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?

The macro BTRFS_PATH_AUTO_FREE still declares a pointer, only adds the
__cleanup parameter that calls btrfs_free_path() when the variable
leaves its scope. It's not declaring 'path' as plain variable, if I
interpret the comment 'needs it allocated' in that context.