lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAL3q7H5AVVyeNxdXPJyGM9ys7WLncTWnwAciuEtThbWpzZGe2Q@mail.gmail.com>
Date: Wed, 19 Nov 2025 12:21:52 +0000
From: Filipe Manana <fdmanana@...nel.org>
To: Daniel Vacek <neelx@...e.com>
Cc: Chris Mason <clm@...com>, Josef Bacik <josef@...icpanda.com>, David Sterba <dsterba@...e.com>, 
	linux-btrfs@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v7 5/6] btrfs: move inode_to_path higher in backref.c

On Tue, Nov 18, 2025 at 4:16 PM Daniel Vacek <neelx@...e.com> wrote:
>
> From: Josef Bacik <josef@...icpanda.com>
>
> We have a prototype and then the definition lower below, we don't need
> to do this, simply move the function to where the prototype is.

According to our development notes here:

https://btrfs.readthedocs.io/en/latest/dev/Development-notes.html

Under the "Function declarations" section we have:

"avoid prototypes for static functions, order them in new code in a
way that does not need it

but don’t move static functions just to get rid of the prototype"

So what's the motivation for moving the function?



>
> Signed-off-by: Josef Bacik <josef@...icpanda.com>
> ---
>  fs/btrfs/backref.c | 68 ++++++++++++++++++++++------------------------
>  1 file changed, 32 insertions(+), 36 deletions(-)
>
> diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
> index 78da47a3d00e..bd913e3c356f 100644
> --- a/fs/btrfs/backref.c
> +++ b/fs/btrfs/backref.c
> @@ -2574,8 +2574,39 @@ int iterate_inodes_from_logical(u64 logical, struct btrfs_fs_info *fs_info,
>         return iterate_extent_inodes(&walk_ctx, false, build_ino_list, ctx);
>  }
>
> +/*
> + * returns 0 if the path could be dumped (probably truncated)
> + * returns <0 in case of an error
> + */
>  static int inode_to_path(u64 inum, u32 name_len, unsigned long name_off,
> -                        struct extent_buffer *eb, struct inode_fs_paths *ipath);
> +                        struct extent_buffer *eb, struct inode_fs_paths *ipath)
> +{
> +       char *fspath;
> +       char *fspath_min;
> +       int i = ipath->fspath->elem_cnt;
> +       const int s_ptr = sizeof(char *);
> +       u32 bytes_left;
> +
> +       bytes_left = ipath->fspath->bytes_left > s_ptr ? ipath->fspath->bytes_left - s_ptr : 0;
> +
> +       fspath_min = (char *)ipath->fspath->val + (i + 1) * s_ptr;
> +       fspath = btrfs_ref_to_path(ipath->fs_root, ipath->btrfs_path, name_len,
> +                                  name_off, eb, inum, fspath_min, bytes_left);
> +       if (IS_ERR(fspath))
> +               return PTR_ERR(fspath);
> +
> +       if (fspath > fspath_min) {
> +               ipath->fspath->val[i] = (u64)(unsigned long)fspath;
> +               ++ipath->fspath->elem_cnt;
> +               ipath->fspath->bytes_left = fspath - fspath_min;
> +       } else {
> +               ++ipath->fspath->elem_missed;
> +               ipath->fspath->bytes_missing += fspath_min - fspath;
> +               ipath->fspath->bytes_left = 0;
> +       }
> +
> +       return 0;
> +}
>
>  static int iterate_inode_refs(u64 inum, struct inode_fs_paths *ipath)
>  {
> @@ -2700,41 +2731,6 @@ static int iterate_inode_extrefs(u64 inum, struct inode_fs_paths *ipath)
>         return ret;
>  }
>
> -/*
> - * returns 0 if the path could be dumped (probably truncated)
> - * returns <0 in case of an error
> - */
> -static int inode_to_path(u64 inum, u32 name_len, unsigned long name_off,
> -                        struct extent_buffer *eb, struct inode_fs_paths *ipath)
> -{
> -       char *fspath;
> -       char *fspath_min;
> -       int i = ipath->fspath->elem_cnt;
> -       const int s_ptr = sizeof(char *);
> -       u32 bytes_left;
> -
> -       bytes_left = ipath->fspath->bytes_left > s_ptr ?
> -                                       ipath->fspath->bytes_left - s_ptr : 0;
> -
> -       fspath_min = (char *)ipath->fspath->val + (i + 1) * s_ptr;
> -       fspath = btrfs_ref_to_path(ipath->fs_root, ipath->btrfs_path, name_len,
> -                                  name_off, eb, inum, fspath_min, bytes_left);
> -       if (IS_ERR(fspath))
> -               return PTR_ERR(fspath);
> -
> -       if (fspath > fspath_min) {
> -               ipath->fspath->val[i] = (u64)(unsigned long)fspath;
> -               ++ipath->fspath->elem_cnt;
> -               ipath->fspath->bytes_left = fspath - fspath_min;
> -       } else {
> -               ++ipath->fspath->elem_missed;
> -               ipath->fspath->bytes_missing += fspath_min - fspath;
> -               ipath->fspath->bytes_left = 0;
> -       }
> -
> -       return 0;
> -}
> -
>  /*
>   * this dumps all file system paths to the inode into the ipath struct, provided
>   * is has been created large enough. each path is zero-terminated and accessed
> --
> 2.51.0
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ