[RESEND RFC PATCH v7 0/3] migrate ocfs2 DIO from buffer_head to iomap

From: Heming Zhao

Date: Tue Nov 17 2026 - 19:21:04 EST


This patch set migrates ocfs2 Direct I/O (DIO) from buffer_head mode
to iomap mode. And the code base is commit aebb72744764 (v7.4-rc3),
and also merge Joseph's code and ideas from [1]:

V7 changelog:

Address sashiko's review comments. Main changes:

1. Adopt the latest iomap API and remove the iomap_ops structure.
2. Add a retry mechanism in ocfs2_dio_wr_map_blocks() to fix a data loss
bug. Multiple concurrent writes are serialized by i_rwsem at submission
time but completed asynchronously by ocfs2_dio_end_io(). When the
unwritten extent conversion fails and finishes first, other threads'
submissions would lose data but still return success.
3. Fix DIO alignment issues.
4. Fix several edge-case handling problems in the DIO write path.

Resend this patch set based on sashiko latest review comments:
- ref: https://sashiko.dev/#/patchset/20261117150053.18417-1-heming.zhao%40suse.com
- build issues with the latest iomap API
- comments contain some stale symbol names
- patch [2/3]: change the check of "map->pblk < past_eof" to
"map->lblk < past_eof" in ocfs2_map_blocks()
- patch [3/3]: remove the dead w_unwritten_count field in
"struct ocfs2_write_ctxt"
- revise some commit log mistakes and a typo.

[1]:
https://gitee.com/anolis/storage-cloud-kernel/commit/ea3fe75e2060118ba093e90b1cd34fa382914b29

[2]:
https://sashiko.dev/#/patchset/20261103135605.22943-1-heming.zhao%40suse.com

v1 patch set:
https://lore.kernel.org/ocfs2-devel/20260724052559.15409-1-heming.zhao@xxxxxxxx/
v2 patch set:
https://lore.kernel.org/ocfs2-devel/20260727061802.18485-1-heming.zhao@xxxxxxxx/
v3 patch set:
https://lore.kernel.org/ocfs2-devel/20261018143319.22329-1-heming.zhao@xxxxxxxx/
v3 sashiko review:
https://sashiko.dev/#/patchset/20261018143319.22329-1-heming.zhao%40suse.com
v4 patch set:
https://lore.kernel.org/ocfs2-devel/20261103135605.22943-1-heming.zhao@xxxxxxxx/
v4 sashiko review:
https://sashiko.dev/#/patchset/20261103135605.22943-1-heming.zhao%40suse.com
v5 patch set:
https://lore.kernel.org/ocfs2-devel/20261105071930.16399-1-heming.zhao@xxxxxxxx/
v5 sashiko review:
https://sashiko.dev/#/patchset/20261105071930.16399-1-heming.zhao%40suse.com
v6 patch set:
https://lore.kernel.org/ocfs2-devel/20261115154013.9379-1-heming.zhao@xxxxxxxx/
v6 sashiko review:
https://sashiko.dev/#/patchset/20261115154013.9379-1-heming.zhao%40suse.com

--------------
# test report

This patch set has been tested on 7.4-rc3 kernel with the following test cases.

The current code still needs some polishing. I hope sashiko can continue to
find issues in v7, so I've only done a few basic tests so far.


## ltp

runltp -f dio -d /mnt/ocfs2/

results: passed

## xfstests

./check -g quick -T -b -s ocfs2 -e generic/081 \
-e generic/266 -e generic/272 -e generic/281 \
-e generic/338 -e generic/347 -e generic/361 \
-e generic/628 -e generic/629 -e generic/648 -e generic/650

OCFS2_MKFS_LOCAL_OPT="-b 2K -C 8K --fs-features=local --fs-feature-level=max-features"
Failures: generic/003 generic/056 generic/075 generic/091 generic/094 generic/112
generic/177 generic/211 generic/225 generic/263 generic/319 generic/321 generic/322
generic/329 generic/331 generic/370 generic/376 generic/424 generic/448 generic/467
generic/477 generic/481 generic/498 generic/510 generic/512 generic/513 generic/534
generic/537 generic/552 generic/557 generic/563 generic/564 generic/578 generic/588
generic/607 generic/620 generic/630 generic/755 generic/759 generic/760 generic/771
generic/777 generic/779 generic/784 ocfs2/001
Failed 45 of 632 tests


-----------------------
Heming Zhao (3):
ocfs2: Add new ocfs2_map_blocks() to introduce iomap feature
ocfs2: switch DIO read path from buffer_head to iomap
ocfs2: switch dio write path from buffer_head to iomap

fs/ocfs2/Kconfig | 2 +-
fs/ocfs2/aops.c | 1626 ++++++++++++++++++++++++++++++++++++----------
fs/ocfs2/aops.h | 42 +-
fs/ocfs2/file.c | 248 ++++++-
fs/ocfs2/inode.h | 6 +
fs/ocfs2/mmap.c | 2 +-
fs/ocfs2/ocfs2.h | 25 +-
fs/ocfs2/super.c | 1 +
8 files changed, 1533 insertions(+), 419 deletions(-)

--
2.55.0