[PATCH v5 0/5] hfsplus: convert regular file I/O to iomap

From: Viacheslav Dubeyko

Date: Tue Nov 17 2026 - 19:49:05 EST


Switch the HFS+ regular file data path from buffer heads and
blockdev_direct_IO() to iomap.

(1) adds a generic iomap_dio_end_io() helper to
include/linux/iomap.h: a direct write ->end_io callback that updates
i_size when the write goes beyond the end-of-file. It can be used by
file systems that issue all extending direct writes synchronously
under inode_lock.

(2) moves the file related operations (open, release, fsync and
file_operations) from inode.c into the new file.c, without functional
changes, to prepare the place for the iomap-based file operations.

(3) splits the extent lookup/allocation logic out of
hfsplus_get_block() into hfsplus_map_extent(), which reports the
mapping without a buffer_head, so that the iomap path can use it
directly. No functional change for the buffer_head path.

(4) makes hfsplus_map_extent() return -EIO when no extent covers
the requested block. On a corrupted volume, hfsplus_get_block() mapped
such a block to allocation block 0, i.e. the boot blocks and the volume
header. The iomap path relies on this check, since a zero-length extent
would otherwise produce a zero-length mapping.

(5) adds the HFS+ iomap operations, implements iomap-based
llseek/read_iter/write_iter, switches hfsplus_aops to iomap (removing
hfsplus_direct_IO() and the LEGACY_DIRECT_IO dependency), and rolls
back i_size and the allocated blocks when the zero-filling extension
or the data write fails. HFS+ doesn't support holes, so extending
writes and truncates zero-fill the gap up to the new end-of-file.

Changes since v4:
- iomap_dio_end_io() is extracted into a dedicated patch 1.
- Rebased on top of "hfsplus: don't take inode_lock in
hfsplus_file_fsync()", "hfsplus: set s_maxbytes from the volume
capacity" and "hfsplus: release preallocated blocks in
hfsplus_file_truncate()", which are already applied.
- v5 patches 04, 06, 07 and 10 are squashed into patch 5.
- The -EIO check in hfsplus_map_extent() is moved out of the iomap
conversion into the separate, documented patch 4.
- The phys_size change in hfsplus_get_block() is dropped: it is not
related to iomap, since after the conversion hfsplus_get_block() only
allocates blocks when phys_size is block-aligned.
- hfsplus_write_iomap_end() keeps fs_blocks and the inode byte count in
whole blocks, as hfsplus_inode_read_fork() and hfsplus_file_truncate()
do, while phys_size stays byte-granular for a partially written block.
- __hfsplus_iomap_begin() ends a mapping of initialized blocks at the
block boundary above phys_size instead of at phys_size itself. With
an unaligned on-disk size this used to produce a mapping length that
is not a multiple of the logical block size, and an aligned O_DIRECT
overwrite failed with -EINVAL.
- The fsync locking change is dropped from this series, since it is
handled by the separate prep patch.
- The volume capacity check in hfsplus_file_write_iter() is dropped,
since generic_write_checks() enforces s_maxbytes, which is set from
the volume capacity.

Viacheslav Dubeyko (5):
iomap: add iomap_dio_end_io() helper
hfsplus: move file related operations to file.c
hfsplus: rework hfsplus_get_block() logic
hfsplus: return -EIO from hfsplus_map_extent() if no extent covers the
block
hfsplus: convert regular file I/O to iomap

fs/hfsplus/Kconfig | 2 +-
fs/hfsplus/Makefile | 5 +-
fs/hfsplus/extents.c | 163 +++++++++++++++------
fs/hfsplus/file.c | 308 ++++++++++++++++++++++++++++++++++++++++
fs/hfsplus/hfsplus_fs.h | 26 +++-
fs/hfsplus/inode.c | 274 +++++++++++------------------------
fs/hfsplus/iomap.c | 254 +++++++++++++++++++++++++++++++++
fs/hfsplus/iomap.h | 17 +++
include/linux/iomap.h | 20 +++
9 files changed, 823 insertions(+), 246 deletions(-)
create mode 100644 fs/hfsplus/file.c
create mode 100644 fs/hfsplus/iomap.c
create mode 100644 fs/hfsplus/iomap.h

--
2.53.0