[PATCH v3 0/7] hfsplus: convert regular file I/O to iomap-based operations

Viacheslav Dubeyko posted 7 patches 2 weeks, 2 days ago
There is a newer version of this series
fs/hfsplus/Kconfig         |   2 +-
fs/hfsplus/Makefile        |   5 +-
fs/hfsplus/bitmap.c        |  18 +++
fs/hfsplus/extents.c       | 164 ++++++++++++++------
fs/hfsplus/file.c          | 304 +++++++++++++++++++++++++++++++++++++
fs/hfsplus/hfsplus_fs.h    |  26 +++-
fs/hfsplus/inode.c         | 281 ++++++++++------------------------
fs/hfsplus/iomap.c         | 192 +++++++++++++++++++++++
fs/hfsplus/iomap.h         |  18 +++
include/linux/hfs_common.h |   8 +-
include/linux/iomap.h      |  20 +++
11 files changed, 787 insertions(+), 251 deletions(-)
create mode 100644 fs/hfsplus/file.c
create mode 100644 fs/hfsplus/iomap.c
create mode 100644 fs/hfsplus/iomap.h
[PATCH v3 0/7] hfsplus: convert regular file I/O to iomap-based operations
Posted by Viacheslav Dubeyko 2 weeks, 2 days ago
This series moves HFS+ regular file data I/O off the legacy
buffer_head/blockdev_direct_IO() path onto iomap-based operations with
the goal to retire the older buffer_head-based direct I/O infrastructure.

v2
Christoph Hellwig has detected that taking the page lock around
the kmap/modify/kunmap section is not enough on its own:
writeback drops the page lock before the write actually completes,
so a mutator that only waits on the lock can still start rewriting
a page whose old contents are still in flight to the device.
Mark the allocation file's mapping with mapping_set_stable_writes()
and call folio_wait_stable() right after taking the page lock in
both functions, so a mutator also waits out any writeback that was
already in progress when it acquired the lock.

Christoph Hellwig suggested to introduce a generalized version
of iomap_dio_end_io() that was placed into include/linux/iomap.h.

The hfsplus_btree_aops uses hfsplus_btree_read_folio() and
hfsplus_btree_writepages() methods. The hfsplus_symlink_aops
uses hfsplus_symlink_read_folio() and hfsplus_symlink_writepages()
methods. Also, hfsplus_setattr() doesn't distinguish the regular
and not regular file cases anymore.

v3
Matthew Wilcox recommended to use folio_wait_writeback()
instead of folio_wait_stable().

Fix failures in generic/091, generic/521, and generic/551.

Viacheslav Dubeyko (7):
  hfs/hfsplus: exchange hardcoded number of extents on named constants
  hfsplus: rework hfsplus_get_block() logic
  hfsplus: take the bitmap page lock for allocate/free
  hfsplus: add iomap operations for regular file data
  hfsplus: move file related operations to file.c
  hfsplus: introduce iomap-based file_operations
  hfsplus: switch address_space_operations on iomap-based support

 fs/hfsplus/Kconfig         |   2 +-
 fs/hfsplus/Makefile        |   5 +-
 fs/hfsplus/bitmap.c        |  18 +++
 fs/hfsplus/extents.c       | 164 ++++++++++++++------
 fs/hfsplus/file.c          | 304 +++++++++++++++++++++++++++++++++++++
 fs/hfsplus/hfsplus_fs.h    |  26 +++-
 fs/hfsplus/inode.c         | 281 ++++++++++------------------------
 fs/hfsplus/iomap.c         | 192 +++++++++++++++++++++++
 fs/hfsplus/iomap.h         |  18 +++
 include/linux/hfs_common.h |   8 +-
 include/linux/iomap.h      |  20 +++
 11 files changed, 787 insertions(+), 251 deletions(-)
 create mode 100644 fs/hfsplus/file.c
 create mode 100644 fs/hfsplus/iomap.c
 create mode 100644 fs/hfsplus/iomap.h

-- 
2.43.0
Re: [PATCH v3 0/7] hfsplus: convert regular file I/O to iomap-based operations
Posted by Darrick J. Wong 2 weeks, 2 days ago
On Tue, Sep 08, 2026 at 02:04:41PM -0700, Viacheslav Dubeyko wrote:
> This series moves HFS+ regular file data I/O off the legacy
> buffer_head/blockdev_direct_IO() path onto iomap-based operations with
> the goal to retire the older buffer_head-based direct I/O infrastructure.
> 
> v2
> Christoph Hellwig has detected that taking the page lock around
> the kmap/modify/kunmap section is not enough on its own:
> writeback drops the page lock before the write actually completes,
> so a mutator that only waits on the lock can still start rewriting
> a page whose old contents are still in flight to the device.
> Mark the allocation file's mapping with mapping_set_stable_writes()
> and call folio_wait_stable() right after taking the page lock in
> both functions, so a mutator also waits out any writeback that was
> already in progress when it acquired the lock.
> 
> Christoph Hellwig suggested to introduce a generalized version
> of iomap_dio_end_io() that was placed into include/linux/iomap.h.
> 
> The hfsplus_btree_aops uses hfsplus_btree_read_folio() and
> hfsplus_btree_writepages() methods. The hfsplus_symlink_aops
> uses hfsplus_symlink_read_folio() and hfsplus_symlink_writepages()
> methods. Also, hfsplus_setattr() doesn't distinguish the regular
> and not regular file cases anymore.
> 
> v3
> Matthew Wilcox recommended to use folio_wait_writeback()
> instead of folio_wait_stable().
> 
> Fix failures in generic/091, generic/521, and generic/551.

FWIW the iomap port itself looks correct to me, so for patches 4, 6,
and 7:

Acked-by: "Darrick J. Wong" <djwong@kernel.org>

but my knowledge of HFS+ is pretty fragmented now, so I couldn't say for
sure about 1-3 or 5.

--D

> Viacheslav Dubeyko (7):
>   hfs/hfsplus: exchange hardcoded number of extents on named constants
>   hfsplus: rework hfsplus_get_block() logic
>   hfsplus: take the bitmap page lock for allocate/free
>   hfsplus: add iomap operations for regular file data
>   hfsplus: move file related operations to file.c
>   hfsplus: introduce iomap-based file_operations
>   hfsplus: switch address_space_operations on iomap-based support
> 
>  fs/hfsplus/Kconfig         |   2 +-
>  fs/hfsplus/Makefile        |   5 +-
>  fs/hfsplus/bitmap.c        |  18 +++
>  fs/hfsplus/extents.c       | 164 ++++++++++++++------
>  fs/hfsplus/file.c          | 304 +++++++++++++++++++++++++++++++++++++
>  fs/hfsplus/hfsplus_fs.h    |  26 +++-
>  fs/hfsplus/inode.c         | 281 ++++++++++------------------------
>  fs/hfsplus/iomap.c         | 192 +++++++++++++++++++++++
>  fs/hfsplus/iomap.h         |  18 +++
>  include/linux/hfs_common.h |   8 +-
>  include/linux/iomap.h      |  20 +++
>  11 files changed, 787 insertions(+), 251 deletions(-)
>  create mode 100644 fs/hfsplus/file.c
>  create mode 100644 fs/hfsplus/iomap.c
>  create mode 100644 fs/hfsplus/iomap.h
> 
> -- 
> 2.43.0
>