From: Daeho Jeong <daeho43@gmail.com>
To: linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com
Cc: Daeho Jeong <daehojeong@google.com>
Subject: [PATCH v2 00/20] f2fs: support block size smaller than PAGE_SIZE
Date: Sun, 15 Nov 2026 20:08:31 -0800 [thread overview]
Message-ID: <20261116040851.2849696-1-daeho43@gmail.com> (raw)
From: Daeho Jeong <daehojeong@google.com>
F2FS has required the filesystem block size to equal PAGE_SIZE. On a
kernel with 16KB pages, this means an existing F2FS image with 4KB
blocks cannot be mounted, e.g. the userdata partition of an Android
device that moves from a 4KB page kernel to a 16KB page kernel.
This series lets F2FS mount and use a filesystem whose block size is
smaller than PAGE_SIZE, such as 4KB blocks on a 16KB page kernel. The
on-disk format does not change.
With subpage blocks, even an order-0 folio holds several blocks, so
the series builds on the large folio support from Nanzhe Zhao [1] and
tracks uptodate and dirty state per block in f2fs_folio_state for any
folio that holds more than one block. Most paths then work in blocks
instead of pages:
- Patches 1-2 convert more page based index and size calculations to
block based ones, and add the superblock and mount infrastructure.
Subpage block sizes are still rejected at this point.
- Patch 3 extends f2fs_folio_state with per-block state, identified by
a magic number, and allocates it on demand with __GFP_NOFAIL.
- Patches 4-7 handle directories, the per-inode dirty counters, the
read path and GC, and the write path and writeback per block.
- Patches 8-19 adapt the remaining features: range operations and
mmap, pinned files, collapse/insert range, move range,
defragmentation, swapfile, fs-verity, atomic writes, inline data,
online resize and compression, and remove the -EOPNOTSUPP checks
that patch 2 added for the features that need them.
- Patch 20 stops rejecting subpage block sizes.
When the block size equals PAGE_SIZE, the behavior does not change,
except for the fixes noted in the individual patches. The following
are not limited to subpage blocks or large folios:
- Patch 1: __complete_revoke_list() and __clone_blkaddrs() compute
offsets in 64 bits on 32-bit architectures.
- Patch 8: an extending direct write updates i_size in ->end_io(),
before iomap invalidates the page cache of the written range.
- Patch 10: collapse and insert range hold i_gc_rwsem[WRITE] and
invalidate_lock until the moved blocks are written back and the page
cache is dropped.
- Patch 11: move range zeroes the cached data past the old EOF of the
destination before extending it, and drops the source blocks from
the page cache also after an exchange that failed part way.
- Patch 12: defragmentation reads compressed files through
->read_folio(). A block of a compressed cluster that was not in the
page cache was read without decompression and written back as file
data.
- Patch 15: aborting atomic writes holds i_gc_rwsem[WRITE] and
invalidate_lock.
A few of the patches adjust code from the large folio series [1]:
- f2fs_folio_has_ffs() checks the folio state magic instead of
requiring a large folio, since order-0 multi-block folios also carry
a folio state, and the page private flags can legitimately be set
before a state is attached.
- f2fs_ffs_find_or_alloc() cannot fail with __GFP_NOFAIL, so the
allocation failure handling of its callers is removed.
- The inode dirty blocks are counted from the dirty bits of the folio
state, and ->dirty_folio() marks the uptodate blocks of a folio
dirty, since mm does not tell which blocks were modified.
- Defragmentation and swapfile activation mark only the target block
dirty instead of the whole page.
Changes in v2:
Addressed the review comments from Chao Yu and Nanzhe Zhao, the
warning reported by the kernel test robot, and the findings of the
Sashiko review. v1 is at [2].
- Patch 1 (block based calculations): rename the subject ("in more
paths"). Use F2FS_BLK_ALIGN() in dir_blocks(). Compute the new
i_size in __clone_blkaddrs() in 64 bits.
- Patch 2 (superblock and mount): probe the 2nd superblock from the
smallest block size and stop at the first one found, so that a stale
superblock of a larger block size is not picked, and return its
error instead of the error of the last probe. Bound log_sectorsize
by log_blocksize and remove F2FS_MAX_LOG_SECTOR_SIZE. Check the
requested inline_xattr_size in f2fs_check_opt_consistency(). Do not
set *recovery when no valid superblock is found. Report a failed
read of a superblock again.
- Patch 3 (folio state): remove the unused variable in
prepare_large_folio_write_begin(). Count the submitted blocks in
nwritten also on error. Do not clear the uptodate flag of the folio
of an inline inode in f2fs_invalidate_folio(). Explain the use of
__GFP_NOFAIL in the commit message.
- Patch 4 (directories): read the name length in f2fs_delete_entry()
under the folio lock. Clear the gcing flag of the folio when its
last dirty block is freed. Simplify f2fs_dentry_to_lblk() and use
f2fs_folio_lblk_address().
- Patch 5 (dirty counters): commit message only.
- Patch 6 (read path and GC): keep the folio state of a folio that is
not fully uptodate in ->release_folio while the folio has other
users. Read the block again in f2fs_get_read_data_folio() and
f2fs_find_data_folio() when the folio state was released while the
folio was unlocked, instead of failing. Do not map the blocks past
EOF in f2fs_read_data_large_folio(). Read under memalloc_nofs in
ra_data_block(), where GC locks are held. Rename
f2fs_submit_page_read_sync() to f2fs_submit_block_read_sync().
- Patch 7 (write path and writeback): count the inode dirty blocks
from the dirty bits of the folio state instead of per folio. Make
->dirty_folio() mark the uptodate blocks within EOF dirty, and add
f2fs_folio_mark_dirty() for the updates made by f2fs, which mark
only the blocks they modify. Keep f2fs_balance_fs_folio_locked() in
write_begin instead of balancing after the folio is unlocked. Drop
the pending write that a failed submission leaves behind in
f2fs_convert_inline_folio(). Keep the folio dirty and accounted when
flush_inline_data() fails.
- Patch 8 (range operations and mmap): update i_size of an extending
direct write in ->end_io(). In page_mkwrite, reserve blocks only
where it may allocate, i.e. not for a pinned file or a compressed
cluster, do not balance with the folio locked, and read the blocks
that are not uptodate after a partial invalidation. Check the dirty
state of a reserved block only for SEEK_DATA.
- Patch 9 (pinned files): keep failing page_mkwrite on a device
aliasing file with -EIO.
- Patch 10 (collapse and insert range): hold i_gc_rwsem[WRITE] and
invalidate_lock from before the first writeback until the moved
blocks are written back and the page cache is dropped.
- Patch 11 (move range): zero the cached data past the old EOF of the
destination with f2fs_zero_post_eof_page() before the move. Drop the
source blocks from the page cache also after an exchange that failed
part way. Call pagecache_isize_extended() for the gap between the
old EOF and the moved data.
- Patch 12 (defragmentation): read compressed files through
->read_folio() as well, and lock and redirty the folio that was read
instead of looking it up again (f2fs_get_defrag_folio()).
- Patch 13 (swapfile): use f2fs_folio_mark_dirty().
- Patch 14 (fs-verity): stop the data reads of a verity file at i_size
in f2fs_read_data_large_folio(). Do not zero the blocks past i_size
on read while verity is being enabled.
- Patch 15 (atomic writes): hold i_gc_rwsem[WRITE] and invalidate_lock
while aborting atomic writes, except at eviction.
- Patch 16 (inline data): redirty the folio and stop on any error of
the inline writeback in f2fs_write_cache_folios(). Note the effect
on inline inodes with large folios in the commit message.
- Patch 18 (compression): raise the minimum cluster size only when a
page has more than four blocks, reject a smaller compress_log_size
in the mount option and in F2FS_IOC_SET_COMPRESS_OPTION, fail the
open of a file that already has a smaller cluster with -EOPNOTSUPP
instead of failing its inode sanity check, and document it. Dirty
every block of a partially dirty compressed cluster before it is
rewritten. Attach a folio state to the multi-block folios of a
rewritten cluster before they are dirtied. Count a read folio of a
compressed file once in the iostat. Do not cut the range that
redirty_blocks() dirties at EOF. Remove inode_inc_dirty_block() and
inode_dec_dirty_block().
- Patches 17, 19 and 20: no change.
- The patches also use the F2FS_BLK_* helpers in more places, as
suggested in the review.
Testing:
Built every patch for x86_64, arm64 (16KB pages), arm and i386.
Ran the xfstests auto group (excluding the clone, dedupe and thin
groups) on arm64 QEMU with mount options "discard,fsync_mode=strict"
in these combinations of page size / block size:
- 16KB/4KB: default, compression (lz4, zstd, lz4hc, lzo-rle with
64KB clusters and checksum), compression+encryption,
encryption+verity, mode=lfs, atgc
- 4KB/4KB: default, compression, encryption+verity,
compression+encryption, mode=lfs
- 16KB/16KB: default, compression, encryption+verity,
compression+encryption, mode=lfs
plus generic/019, 521, 522 and 780 for each combination, and a 24 hour
power-off recovery test with fsstress for each of the three
combinations.
There were no crashes or hangs, and the power-off recovery tests found
no corruption. Two failures are worth a note, and neither depends on
this series:
- generic/455 failed once on 16KB/4KB with encryption+verity, because
fsync() returned before its node block was written. [3] fixes it.
- generic/551 was killed by the OOM killer in three of the compression
runs. It is killed the same way without this series.
Also ran:
- The xfstests quick group with lockdep (PROVE_LOCKING and
DEBUG_ATOMIC_SLEEP) on 16KB/4KB, default and compression. The only
reports were in generic/574 with compression, where
f2fs_decompress_cluster() may sleep in the read completion. This
happens without this series as well, and [4] fixes it.
- 16 processes writing through mmap at the same time until the
filesystem is full, on a 1GB image with 16KB pages and 4KB blocks,
with and without large folios and with and without mode=lfs, as
asked in the review of v1. They got SIGBUS only after the free
space ran out, the data read back was correct, and fsck found no
error.
- A 32-bit ARM kernel (4KB pages) with files beyond 4GB.
[1] https://lore.kernel.org/linux-f2fs-devel/20261028154407.1601430-1-nzzhao.sigma@gmail.com/
[2] https://lore.kernel.org/linux-f2fs-devel/20261102193952.3002018-1-daeho43@gmail.com/
[3] https://lore.kernel.org/linux-f2fs-devel/20261103101208.4550-1-seungbum.ju@gmail.com/
[4] https://lore.kernel.org/linux-f2fs-devel/20261112143355.2923939-2-jprusakowski@google.com/
Daeho Jeong (20):
f2fs: use block-based index and size calculations in more paths
f2fs: support subpage block size superblock and mount
f2fs: extend f2fs_folio_state for subpage blocks
f2fs: support subpage blocks in directory operations
f2fs: convert inode dirty page counters to dirty block counters
f2fs: support subpage blocks in data read path and GC
f2fs: support subpage blocks in data write path and writeback
f2fs: adapt range operations and mmap for subpage blocks
f2fs: support subpage blocks in pinned files
f2fs: support subpage blocks in collapse and insert range
f2fs: support subpage blocks in move range
f2fs: support subpage blocks in defragmentation
f2fs: support subpage blocks in swapfile activation
f2fs: support subpage blocks in fs-verity enablement
f2fs: support subpage blocks in atomic writes
f2fs: preserve inline data in subpage block mode
f2fs: support subpage blocks in online resize
f2fs: support subpage blocks in compression
f2fs: count compress cache entries in pages for its memory limit
f2fs: enable subpage block size support
Documentation/filesystems/f2fs.rst | 7 +-
fs/f2fs/checkpoint.c | 67 +-
fs/f2fs/compress.c | 569 ++++++---
fs/f2fs/data.c | 1725 ++++++++++++++++++----------
fs/f2fs/dir.c | 126 +-
fs/f2fs/f2fs.h | 237 ++--
fs/f2fs/file.c | 716 ++++++++----
fs/f2fs/gc.c | 103 +-
fs/f2fs/inline.c | 23 +-
fs/f2fs/inode.c | 3 +-
fs/f2fs/node.c | 26 +-
fs/f2fs/segment.c | 14 +-
fs/f2fs/super.c | 180 ++-
fs/f2fs/verity.c | 5 -
include/linux/f2fs_fs.h | 2 +-
15 files changed, 2494 insertions(+), 1309 deletions(-)
base-commit: b9d7379d10d43386b59082da8c9a0b111e054781
--
2.56.0.611.g1030f0b940-goog
next reply other threads:[~2026-11-16 4:08 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 4:08 Daeho Jeong [this message]
2026-11-16 4:08 ` [PATCH v2 01/20] f2fs: use block-based index and size calculations in more paths Daeho Jeong
2026-11-16 4:08 ` [PATCH v2 02/20] f2fs: support subpage block size superblock and mount Daeho Jeong
2026-11-16 4:08 ` [PATCH v2 03/20] f2fs: extend f2fs_folio_state for subpage blocks Daeho Jeong
2026-11-16 4:08 ` [PATCH v2 04/20] f2fs: support subpage blocks in directory operations Daeho Jeong
2026-11-16 4:08 ` [PATCH v2 05/20] f2fs: convert inode dirty page counters to dirty block counters Daeho Jeong
2026-11-16 4:08 ` [PATCH v2 06/20] f2fs: support subpage blocks in data read path and GC Daeho Jeong
2026-11-16 4:08 ` [PATCH v2 07/20] f2fs: support subpage blocks in data write path and writeback Daeho Jeong
2026-11-16 4:08 ` [PATCH v2 08/20] f2fs: adapt range operations and mmap for subpage blocks Daeho Jeong
2026-11-16 4:08 ` [PATCH v2 09/20] f2fs: support subpage blocks in pinned files Daeho Jeong
2026-11-16 4:08 ` [PATCH v2 10/20] f2fs: support subpage blocks in collapse and insert range Daeho Jeong
2026-11-16 4:08 ` [PATCH v2 11/20] f2fs: support subpage blocks in move range Daeho Jeong
2026-11-16 4:08 ` [PATCH v2 12/20] f2fs: support subpage blocks in defragmentation Daeho Jeong
2026-11-16 4:08 ` [PATCH v2 13/20] f2fs: support subpage blocks in swapfile activation Daeho Jeong
2026-11-16 4:08 ` [PATCH v2 14/20] f2fs: support subpage blocks in fs-verity enablement Daeho Jeong
2026-11-16 4:08 ` [PATCH v2 15/20] f2fs: support subpage blocks in atomic writes Daeho Jeong
2026-11-16 4:08 ` [PATCH v2 16/20] f2fs: preserve inline data in subpage block mode Daeho Jeong
2026-11-16 4:08 ` [PATCH v2 17/20] f2fs: support subpage blocks in online resize Daeho Jeong
2026-11-16 4:08 ` [PATCH v2 18/20] f2fs: support subpage blocks in compression Daeho Jeong
2026-11-16 4:08 ` [PATCH v2 19/20] f2fs: count compress cache entries in pages for its memory limit Daeho Jeong
2026-11-16 4:08 ` [PATCH v2 20/20] f2fs: enable subpage block size support Daeho Jeong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261116040851.2849696-1-daeho43@gmail.com \
--to=daeho43@gmail.com \
--cc=daehojeong@google.com \
--cc=kernel-team@android.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®