freenode
Kernel & Low-Level

ext4 moves buffered I/O onto iomap in 32-patch series

Zhang Yi’s v5 conversion drops buffer_head for regular-file buffered paths and reworks EOF zeroing so size updates cannot expose stale data.

Zhang Yi of Huawei has posted the fifth revision of a large ext4 series that switches regular files’ buffered I/O path from the long-standing buffer_head machinery to the kernel’s shared iomap framework. The change is the kind of core plumbing move that other major filesystems have already made, and it aims to simplify mapping, writeback, and partial-block handling while improving concurrency on modern storage.

The series reworks how ext4 maps blocks for buffered reads and writes, writeback, mmap faults, and partial-block zeroing, so those paths no longer open-code buffer_head operations. Writeback allocates and submits through iomap, converting unwritten extents and updating on-disk size only after I/O completes. Because the iomap path does not rely on data=ordered mode to hide stale blocks on append, new blocks are allocated unwritten and size advancement is carefully deferred until zeroed EOF data is safely on disk.

That ordering is the subtle part of the work. Extending a file at an unaligned EOF can leave a zeroed partial block straddling the old on-disk size. The patches introduce an inode state that tracks when that block is still awaiting writeback, tag the matching I/O, and either wait for it or advance size only after completion, so crash recovery cannot expose old contents. Collapse/insert range and related fallocate paths flush the pending range when they cannot simply defer the size update. Several race fixes cover punch-hole versus writeback, stale delalloc extents, and zeroing that could otherwise skip a block converted underfoot.

xfstests runs under auto, fast_commit, and 64K configurations showed no new failures beyond a known intermittent large-folio split issue elsewhere in the MM layer. FIO on a RAM-backed guest reported solid gains for the iomap path over buffer_head in several write-cache and writeback setups. Online defragmentation remains unsupported for inodes on the new path for now, and the series still needs to land; reviewers so far include Ojaswin Mujoo and Jan Kara.