Skip to content

ext4: use iomap for regular file's buffered I/O path

Zhang Yi linux-ext4 linux-fsdevel lkml oe-kbuild-all 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest22 patches 31 repliesIn review

Changes in v2 from the cover letter

- Rebase this series on linux-next 20260122.
- Refactor partial block zero range, stop passing handle to ext4_block_truncate_page() and ext4_zero_partial_blocks(), and move partial block zeroing operation outside an active journal transaction to prevent potential deadlocks because of the lock ordering of folio and transaction start.
- Clarify the lock ordering of folio lock and transaction start, update the comments accordingly.
- Fix some issues related to fast commit, pollute post-EOF folio.
- Some minor code and comments optimizations.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/22ext4: make ext4_block_zero_page_range() pass out did_zerofs/ext4/inode.c+14 -90 replies
2/22ext4: make ext4_block_truncate_page() return zeroed lengthfs/ext4/inode.c+9 -10 replies
3/22ext4: only order data when partially block truncating downfs/ext4/inode.c+19 -1319 replies
4/22ext4: factor out journalled block zeroing rangefs/ext4/inode.c+63 -210 replies
5/22ext4: stop passing handle to ext4_journalled_block_zero_range()fs/ext4/ext4.h fs/ext4/extents.c fs/ext4/inode.c+34 -300 replies
6/22ext4: don't zero partial block under an active handle when truncating downfs/ext4/inode.c+12 -150 replies
7/22ext4: move ext4_block_zero_page_range() out of an active handlefs/ext4/extents.c fs/ext4/inode.c+29 -350 replies
8/22ext4: zero post EOF partial block before appending writefs/ext4/file.c fs/ext4/inode.c+27 -140 replies
9/22ext4: add a new iomap aops for regular file's buffered IO pathfs/ext4/ext4.h fs/ext4/inode.c+39 -00 replies
10/22ext4: implement buffered read iomap pathfs/ext4/inode.c+44 -10 replies
11/22ext4: pass out extent seq counter when mapping da blocksfs/ext4/inode.c+2 -20 replies
12/22ext4: implement buffered write iomap pathfs/ext4/ext4.h fs/ext4/file.c fs/ext4/inode.c +1 more+200 -70 replies
13/22ext4: implement writeback iomap pathfs/ext4/ext4.h fs/ext4/inode.c fs/ext4/page-io.c +1 more+341 -20 replies
14/22ext4: implement mmap iomap pathfs/ext4/inode.c fs/ext4/super.c+37 -30 replies
15/22iomap: correct the range of a partial dirty clearfs/iomap/buffered-io.c+7 -30 replies
16/22iomap: support invalidating partial foliosfs/iomap/buffered-io.c+2 -00 replies
17/22ext4: implement partial block zero range iomap pathfs/ext4/inode.c+85 -00 replies
18/22ext4: do not order data for inodes using buffered iomap pathfs/ext4/ext4_jbd2.h+6 -10 replies
19/22ext4: add block mapping tracepoints for iomap buffered I/O pathfs/ext4/inode.c include/trace/events/ext4.h+51 -00 replies
20/22ext4: disable online defrag when inode using iomap buffered I/O pathfs/ext4/move_extent.c+11 -00 replies
21/22ext4: partially enable iomap for the buffered I/O path of regular filesfs/ext4/ext4.h fs/ext4/ext4_jbd2.c fs/ext4/ialloc.c +1 more+39 -00 replies
22/22ext4: introduce a mount option for iomap buffered I/O pathfs/ext4/ext4.h fs/ext4/inode.c fs/ext4/super.c+10 -00 replies

Reviews trailers per patch

1 of 22 patches has a Reviewed-by or Acked-by.

PatchDarrick J. Wong
1/22
2/22
3/22
4/22
5/22
6/22
7/22
8/22
9/22
10/22
11/22
12/22
13/22
14/22
15/22
16/22R-b
17/22
18/22
19/22
20/22
21/22
22/22

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH -next v2 00/22] ext4: use iomap for regular file's buffered I/O path

From: Zhang Yi <[email protected]>

Changes since V1:
- Rebase this series on linux-next 20260122.
- Refactor partial block zero range, stop passing handle to ext4_block_truncate_page() and ext4_zero_partial_blocks(), and move partial block zeroing operation outside an active journal transaction to prevent potential deadlocks because of the lock ordering of folio and transaction start.
- Clarify the lock ordering of folio lock and transaction start, update the comments accordingly.
- Fix some issues related to fast commit, pollute post-EOF folio.
- Some minor code and comments optimizations.

v1:     https://lore.kernel.org/linux-ext4/[email protected]/
RFC v4: https://lore.kernel.org/linux-ext4/[email protected]/
RFC v3: https://lore.kernel.org/linux-ext4/[email protected]/
RFC v2: https://lore.kernel.org/linux-ext4/[email protected]/
RFC v1: https://lore.kernel.org/linux-ext4/[email protected]/

Original Cover (Updated):

This series adds the iomap buffered I/O path supports for regular files. It implements the core iomap APIs on ext4 and introduces two mount options called 'buffered_iomap' and "nobuffered_iomap" to enable and disable the iomap buffered I/O path. This series supports the default features, default mount options and bigalloc feature for ext4. We do not yet support online defragmentation, inline data, fs_verify, fs_crypt, non-extent, and data=journal mode, it will fall to buffered_head I/O path automatically if these features and options are used.

Key notes on the iomap implementations in this series.
- Don't use ordered data mode to prevent exposing stale data when performing append write and truncating down.
- Override dioread_nolock mount option, always allocate unwritten extents for new blocks.
- When performing write back, don't use reserved journal handle and postponing updating i_disksize until I/O is done.
- The lock ordering of the folio lock and start transaction is the opposite of that in the buffer_head buffered write path.

Series details:

Patch 01-08: Refactor partial block zeroing operation, move it out of an
active running journal transaction, and handle post EOF partial block zeroing properly.
Patch 09-21: Implement the core iomap buffered read, write path, dirty
folio write back path, mmap path and partial block zeroing path for ext4 regular file.
Patch 22: Introduce 'buffered_iomap' and 'nobuffer_iomap' mount option
to enable and disable the iomap buffered I/O path.

Tests and Performance:

I tested this series using xfstests-bld with auto configurations, as well as fast_commit and 64k configurations. No new regressions were observed.

I used fio to test my virtual machine with a 150 GB memory disk and found an improvement of approximately 30% to 50% in large I/O write performance, while read performance showed no significant difference.

buffered write
==============

buffer_head:
bs write cache uncached write

  1k       423  MiB/s      36.3 MiB/s
  4k       1067 MiB/s      58.4 MiB/s
  64k      4321 MiB/s      869  MiB/s
  1M       4640 MiB/s      3158 MiB/s

iomap:
bs write cache uncached write

  1k       403  MiB/s      57   MiB/s
  4k       1093 MiB/s      61   MiB/s
  64k      6488 MiB/s      1206 MiB/s
  1M       7378 MiB/s      4818 MiB/s

buffered read
=============

buffer_head:
bs read hole read cache read data

  1k       635  MiB/s    661  MiB/s    605  MiB/s
  4k       1987 MiB/s    2128 MiB/s    1761 MiB/s
  64k      6068 MiB/s    9472 MiB/s    4475 MiB/s
  1M       5471 MiB/s    8657 MiB/s    4405 MiB/s

iomap:

  bs      read hole   read cache       read data
  1k       643  MiB/s    653  MiB/s    602  MiB/s
  4k       2075 MiB/s    2159 MiB/s    1716 MiB/s
  64k      6267 MiB/s    9545MiB/s     4451 MiB/s
  1M       6072 MiB/s    9191MiB/s     4467 MiB/s

Comments and suggestions are welcome!

Thanks,
Yi.

Zhang Yi (22):
ext4: make ext4_block_zero_page_range() pass out did_zero
ext4: make ext4_block_truncate_page() return zeroed length
ext4: only order data when partially block truncating down
ext4: factor out journalled block zeroing range
ext4: stop passing handle to ext4_journalled_block_zero_range()
ext4: don't zero partial block under an active handle when truncating
down
ext4: move ext4_block_zero_page_range() out of an active handle
ext4: zero post EOF partial block before appending write
ext4: add a new iomap aops for regular file's buffered IO path
ext4: implement buffered read iomap path
ext4: pass out extent seq counter when mapping da blocks
ext4: implement buffered write iomap path
ext4: implement writeback iomap path
ext4: implement mmap iomap path
iomap: correct the range of a partial dirty clear
iomap: support invalidating partial folios
ext4: implement partial block zero range iomap path
ext4: do not order data for inodes using buffered iomap path
ext4: add block mapping tracepoints for iomap buffered I/O path
ext4: disable online defrag when inode using iomap buffered I/O path
ext4: partially enable iomap for the buffered I/O path of regular
files
ext4: introduce a mount option for iomap buffered I/O path

 fs/ext4/ext4.h              |  21 +-
 fs/ext4/ext4_jbd2.c         |   1 +
 fs/ext4/ext4_jbd2.h         |   7 +-
 fs/ext4/extents.c           |  31 +-
 fs/ext4/file.c              |  40 +-
 fs/ext4/ialloc.c            |   1 +
 fs/ext4/inode.c             | 822 ++++++++++++++++++++++++++++++++----
 fs/ext4/move_extent.c       |  11 +
 fs/ext4/page-io.c           | 119 ++++++
 fs/ext4/super.c             |  32 +-
 fs/iomap/buffered-io.c      |  12 +-
 include/trace/events/ext4.h |  45 ++
 12 files changed, 1033 insertions(+), 109 deletions(-)
Signature · 1 line
2.52.0