Re: [PATCH] btrfs: disable bs > ps support if no transparent hugepage support

Filipe Manana <[email protected]> Thu, 30 Jul 2026 16:53:17 +0100
Newsgroups org.kernel.vger.linux-btrfs
Message-ID <CAL3q7H5tyWwfh79Zmk0ZYkrG=EJ=SFAUbw03os1mu+GO9c8Jnw@mail.gmail.com>
On Thu, Jul 30, 2026 at 8:22=E2=80=AFAM Qu Wenruo <[email protected]> wrote:
>
> Btrfs relies one mapping_set_folio_order_range() to set the minimal

one -> on

> folio order for all its data inodes, but that function will be nop if
> transparent hugepage is not enabled.
>
> Guard the bs > ps support behind CONFIG_TRANSPARENT_HUGEPAGE, just like
> all other filesystems.
>
> Fixes: 98077f7f2180 ("btrfs: enable experimental bs > ps support")
> Signed-off-by: Qu Wenruo <[email protected]>
> ---
>  fs/btrfs/Kconfig | 3 ++-
>  fs/btrfs/fs.c    | 6 +++++-
>  2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/Kconfig b/fs/btrfs/Kconfig
> index 9de04c37e11a..4b10d78ed99b 100644
> --- a/fs/btrfs/Kconfig
> +++ b/fs/btrfs/Kconfig
> @@ -106,7 +106,8 @@ config BTRFS_EXPERIMENTAL
>
>           - extent tree v2 - complex rework of extent tracking
>
> -         - block size > page size support
> +         - block size > page size support - needs transparent huge page =
and
> +                                            non-HIGHMEM system
>
>           - huge folios for data - folios can be as large as 2MiB now
>
> diff --git a/fs/btrfs/fs.c b/fs/btrfs/fs.c
> index 5015d0148841..77544ee5e6db 100644
> --- a/fs/btrfs/fs.c
> +++ b/fs/btrfs/fs.c
> @@ -155,8 +155,12 @@ bool __attribute_const__ btrfs_supported_blocksize(u=
32 blocksize)
>          *
>          * Considering HIGHMEM is such a pain to deal with and it's going
>          * to be deprecated eventually, just reject HIGHMEM && bs > ps ca=
ses.
> +        *
> +        * Finally, for bs > ps cases, we need to set the minimal folio o=
rder,
> +        * which requires transparent hugepage.
>          */
> -       if (IS_ENABLED(CONFIG_HIGHMEM) && blocksize > PAGE_SIZE)
> +       if (blocksize > PAGE_SIZE &&
> +           (IS_ENABLED(CONFIG_HIGHMEM) || !IS_ENABLED(CONFIG_TRANSPARENT=
_HUGEPAGE)))

This is quite hard to read now. How about something much easier to read lik=
e:

if (blocksize > PAGE_SIZE) {
    if (IS_ENABLED(CONFIG_HIGHMEM))
          return false;

   if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE))
         return false;
}

Otherwise:

Reviewed-by: Filipe Manana <[email protected]>

Thanks.

>                 return false;
>         return true;
>  #endif
> --
> 2.54.0
>
>