[PATCH v8 00/11] f2fs: prepare metadata layouts for runtime block sizes

From: Kelvin Zhang

Date: Thu Sep 03 2026 - 19:06:17 EST


F2FS currently describes several on-disk metadata layouts and filesystem
geometry values with constants derived from PAGE_SIZE or a fixed 4KB block
size. This series derives those values from the mounted filesystem's block
size instead, as preparation for supporting filesystem blocks smaller than
PAGE_SIZE.

The patches initialize sb_info early, describe the SIT, NAT, orphan, dentry,
node, and xattr layouts dynamically, parameterize sector/byte/block
conversion helpers, and derive node-tree geometry at runtime.

This series does not relax the block-size mount check or enable subpage I/O.
It is intended to be a behavior-preserving refactoring for currently
supported 4KB-block filesystems.

Changes since v7:
- address all review comments from Chao Yu and Daeho Jeong
- mark the sb_set_blocksize() failure as unlikely and remove unused helpers
- retain struct f2fs_orphan_block as a flexible-array wrapper
- separate the shared-header block-size geometry helper from the cached
kernel-side inode geometry helper
- consolidate the inline-xattr size helpers and move F2FS_MAX_BLKSIZE to its
first use
- retain the node-ID layout description without nesting comments
- restore shift-based block alignment instead of using 64-bit division
- move node-tree geometry before block-size macro parameterization so each
intermediate patch builds without temporary PAGE_SIZE churn
- use a size_t format for the maximum inline-xattr size on 32-bit builds
- remove unrelated whitespace and other incidental changes

v7:
https://lore.kernel.org/linux-f2fs-devel/cover.1788213716.git.zhangxp1998@xxxxxxxxx/

Changes since v3:
- no code changes in v4 through v7; those versions addressed mail transport
corruption before v7 was delivered intact through direct SMTP

v3:
https://lore.kernel.org/linux-f2fs-devel/CAH=xXfEFL7w7nsU3xjNubKJ1soYMqT-DbJBuyzfEX4Rv3rdFEA@xxxxxxxxxxxxxx/

Changes since v2:
- use DECLARE_FLEX_ARRAY() for flexible arrays that are alone in a struct or
used in a union, fixing the reported m68k GCC build failures
- use F2FS_BLK_ALIGN() in f2fs_sec_trim_file() to avoid a runtime 64-bit
division and an unresolved __divdi3 reference on 32-bit SH
- no other code changes

Changes since v1:
- rebase onto f2fs/dev at c966d29e01bb
- drop the unrelated free-NID underflow fix from this series
- split the preparatory changes into 11 focused patches
- initialize sb_info earlier and describe the xattr layout explicitly
- separate sector, byte/block, and block-size macro parameterization
- update commit messages and address checkpatch warnings

v2:
https://lore.kernel.org/linux-f2fs-devel/CAH=xXfHWW_J92z3YgvoLSx8+z6rekq=p2kiP15KE9=2+Ju2RjQ@xxxxxxxxxxxxxx/
v1:
https://lore.kernel.org/linux-f2fs-devel/CAH=xXfFVAwQ3r_NdUDtmXhtg6Lw8kDWoNTzGL5oy4mwHMsJLJw@xxxxxxxxxxxxxx/

Tested with:
- x86_64 W=1 F2FS build at every patch
- i386 allmodconfig W=1 F2FS builds at patch 07/11 and the series tip
(no new warnings)
- arm64 16KB-page W=1 F2FS build at the series tip
- builds of all five F2FS subpage selftest binaries on the complete branch
- scripts/checkpatch.pl --strict (no errors or warnings)

Kelvin Zhang (11):
f2fs: initialize sb_info early in f2fs_fill_super
f2fs: describe SIT block layout dynamically
f2fs: describe NAT block layout dynamically
f2fs: describe orphan block layout dynamically
f2fs: describe dentry block layout dynamically
f2fs: describe {i,d,id}node block layout dynamically
f2fs: describe xattr block layout dynamically
f2fs: parameterize sector conversion macros
f2fs: parameterize byte and block conversion macros
f2fs: describe node tree geometry dynamically
f2fs: parameterize block size and mask macros

fs/f2fs/checkpoint.c | 63 ++++++++-------
fs/f2fs/data.c | 85 +++++++++++---------
fs/f2fs/debug.c | 4 +-
fs/f2fs/dir.c | 51 ++++++------
fs/f2fs/extent_cache.c | 9 ++-
fs/f2fs/f2fs.h | 117 ++++++++++++++++++++-------
fs/f2fs/file.c | 84 +++++++++++---------
fs/f2fs/gc.c | 27 ++++---
fs/f2fs/inline.c | 11 ++-
fs/f2fs/inode.c | 25 +++---
fs/f2fs/node.c | 171 +++++++++++++++++++++-------------------
fs/f2fs/node.h | 87 ++++++++++----------
fs/f2fs/recovery.c | 4 +-
fs/f2fs/segment.c | 60 +++++++-------
fs/f2fs/segment.h | 32 ++++----
fs/f2fs/shrinker.c | 2 +-
fs/f2fs/super.c | 84 +++++++++++++-------
fs/f2fs/sysfs.c | 10 +--
fs/f2fs/verity.c | 6 +-
fs/f2fs/xattr.c | 10 ++-
fs/f2fs/xattr.h | 11 +--
include/linux/f2fs_fs.h | 135 +++++++++++++++++--------------
22 files changed, 628 insertions(+), 460 deletions(-)

base-commit: c966d29e01bbf829f8bb4a39a49811c56cdb49c3
--
2.53.0