News: 0001579758

  ARM Give a man a fire and he's warm for a day, but set fire to him and he's warm for the rest of his life (Terry Pratchett, Jingo)

New Patches Optimize EXT4 Online Defragmentation For Better Performance

([Linux Storage] 5 Hours Ago EXT4 Online Defragmentation)


A set of 13 patches were posted today to the Linux kernel mailing list for optimizing the online defragmentation handling by the EXT4 kernel driver. The online defragmentation improvements for EXT4 can net a nice performance win with a very significant improvement in a variety of scenarios.

Huawei engineer Zhang Yi posted the patches to the Linux kernel mailing list for improving the EXT4 file-system online defragmentation handling. Plus it's also working toward converting the EXT4 buffered I/O code for regular files over to the IOmap infrastructure. Zhang Yi explained with the LKML patch series:

"Currently, the online defragmentation of the ext4 is primarily implemented through the move extent operation in the kernel. This extent-moving operates at the granularity of PAGE_SIZE, iteratively performing extent swapping and data movement operations, which is quite inefficient. Especially since ext4 now supports large folios, iterations at the PAGE_SIZE granularity are no longer practical and fail to leverage the advantages of large folios. Additionally, the current implementation is tightly coupled with buffer_head, making it unable to support after the conversion of buffered I/O processes to the iomap infrastructure.

This patch set (based on 6.17-rc7) optimizes the extent-moving process, deprecates the old move_extent_per_page() interface, and introduces a new mext_move_extent() interface. The new interface iterates over and copies data based on the extents of the original file instead of the PAGE_SIZE, and supporting large folios. The data processing logic in the iteration remains largely consistent with previous versions, with no additional optimizations or changes made.

Additionally, the primary objective of this set of patches is to prepare for converting the buffered I/O process for regular files to the iomap infrastructure. These patches decouple the buffer_head from the main extent-moving process, restricting its use to only the helpers mext_folio_mkwrite() and mext_folio_mkuptodate(), which handle updating and marking pages in the swapped page cache as dirty. The overall coding style of the extent-moving process aligns with the iomap infrastructure, laying the foundation for supporting online defragmentation once the iomap infrastructure is adopted."

The benchmarks included as part of [1]the patch series are very enticing:

Some really solid wins at the different block sizes and both for written/unwritten extent moving.



[1] https://lore.kernel.org/lkml/20250923012724.2378858-1-yi.zhang@huaweicloud.com/



avis

varikonniemi

ojsl1

varikonniemi

ihatemichael

Volta

Britoid

varikonniemi

jabl

Few things are harder to put up with than the annoyance of a good example.
-- Mark Twain, "Pudd'nhead Wilson's Calendar"