Re: [RFC PATCH v2 06/22] nilfs2: Test PAGE_SIZE at run time in the rec_len conversions

From: Ryusuke Konishi

Date: Wed Dec 02 2026 - 13:02:34 EST


On Wed, Dec 2, 2026 at 12:15 PM Eric Curtin wrote:
>
> From: Eric Curtin <eric.curtin@xxxxxxxxxx>
>
> With arm64 boot-time page size selection PAGE_SIZE is not a compile-time
> constant, so it cannot be used in #if.
>
> Replace the #if (PAGE_SIZE >= 65536) blocks in nilfs_rec_len_from_disk()
> and nilfs_rec_len_to_disk() with ordinary C conditions. The compiler
> still removes the dead code when PAGE_SIZE is constant.
>
> No functional change for compile-time page sizes.
>
> Signed-off-by: Eric Curtin <eric.curtin@xxxxxxxxxx>
> ---
> fs/nilfs2/dir.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/fs/nilfs2/dir.c b/fs/nilfs2/dir.c
> index 7686ca9228fc..afc05387f946 100644
> --- a/fs/nilfs2/dir.c
> +++ b/fs/nilfs2/dir.c
> @@ -38,21 +38,19 @@ static inline unsigned int nilfs_rec_len_from_disk(__le16 dlen)
> {
> unsigned int len = le16_to_cpu(dlen);
>
> -#if (PAGE_SIZE >= 65536)
> - if (len == NILFS_MAX_REC_LEN)
> + if (PAGE_SIZE >= 65536 && len == NILFS_MAX_REC_LEN)
> return 1 << 16;
> -#endif
> return len;
> }
>
> static inline __le16 nilfs_rec_len_to_disk(unsigned int len)
> {
> -#if (PAGE_SIZE >= 65536)
> - if (len == (1 << 16))
> - return cpu_to_le16(NILFS_MAX_REC_LEN);
> + if (PAGE_SIZE >= 65536) {
> + if (len == (1 << 16))
> + return cpu_to_le16(NILFS_MAX_REC_LEN);
>
> - BUG_ON(len > (1 << 16));
> -#endif
> + BUG_ON(len > (1 << 16));
> + }
> return cpu_to_le16(len);
> }
>

Looks good to me.

Since linux-fsdevel is not copied on this individual patch, do you
expect us to pick it up through the nilfs2 tree rather than merging it
together with the rest of the series?
Either way, feel free to add:

Acked-by: Ryusuke Konishi <konishi.ryusuke@xxxxxxxxx>

Thanks,
Ryusuke Konishi