[PATCH 00/10] ext4: refactor partial block zero-out for iomap conversion

From: Zhang Yi

Date: Mon Mar 09 2026 - 21:50:03 EST


From: Zhang Yi <yi.zhang@xxxxxxxxxx>

Hello!

This patch series extracted from my iomap conversion v2 series[1]. It
refactors the ext4 zero partial block code path in preparation for
converting buffered I/O to the iomap infrastructure. The main changes
are:

[1] https://lore.kernel.org/linux-ext4/20260203062523.3869120-1-yi.zhang@xxxxxxxxxx/

1. Introduce ext4_block_zero_eof(): Extend and rename
ext4_block_truncate_page() to handle post-EOF partial block zeroing
for both append writes and truncate operations.
2. Separate ordered data handling: Move data=ordered mode handling from
__ext4_block_zero_page_range to ext4_block_zero_eof(). Only truncate
and post-EOF append write/fallocate paths need ordered data mode,
hole punching and zero range paths don't need ordered data handling.
3. Split journal mode handling: Extract
ext4_block_journalled_zero_range() from
__ext4_block_zero_page_range() for data=journal mode, leaving
ext4_block_do_zero_range() for data=ordered/writeback modes.
4. Refactor ext4_alloc_file_blocks(): Change parameters to loff_t byte
granularity to simplify callers and prepares removing the zero call
from the allocation loop for unaligned append writes.
5. Remove handle parameters: Stop passing handle_t * to zero functions.
Make ext4_block_journalled_zero_range() start its own handle, and
move zero operations outside active handles. This is required because
iomap uses "folio lock -> transaction start" lock ordering, opposite
to the current lock ordering.
6. Centralize zeroing in ext4_write_checks(): Move all post-EOF partial
block zeroing to ext4_write_checks() so it applies to both regular
buffered writes and the upcoming iomap path.

Thanks
Yi.

Zhang Yi (10):
ext4: add did_zero output parameter to ext4_block_zero_page_range()
ext4: ext4_block_truncate_page() returns zeroed length on success
ext4: rename and extend ext4_block_truncate_page()
ext4: factor out journalled block zeroing range
ext4: rename ext4_block_zero_page_range() to ext4_block_zero_range()
ext4: move ordered data handling out of ext4_block_do_zero_range()
ext4: remove handle parameters from zero partial block functions
ext4: pass allocate range as loff_t to ext4_alloc_file_blocks()
ext4: move zero partial block range functions out of active handle
ext4: zero post-EOF partial block before appending write

fs/ext4/ext4.h | 5 +-
fs/ext4/extents.c | 83 ++++++---------
fs/ext4/file.c | 14 +++
fs/ext4/inode.c | 256 ++++++++++++++++++++++++++++------------------
4 files changed, 208 insertions(+), 150 deletions(-)

--
2.52.0