Re: [PATCH 0/2] hfs: fall back to buffered I/O for direct writes past phys_size

From: Viacheslav Dubeyko

Date: Mon Nov 02 2026 - 17:24:52 EST


On Fri, 2026-10-30 at 00:29 -0400, Hengyu Liang wrote:
> Hi Slava,
>
> As discussed in the setattr thread [1], a direct write that ends past
> phys_size loses data at the last close, because hfs_file_truncate()
> zeroes the file from phys_size up to i_size. Patch 1 makes such
> writes
> fall back to buffered I/O, as FAT does. Patch 2 is the
> hfs_file_truncate() cleanup you suggested.
>
> The series applies on top of "hfs: report errors when extending files
> with setattr" v2 [2], which patch 2 needs. The HFS+ fix is sent
> separately.
>
> Tested in KVM with KASAN, all 805 fstests on HFS with that v2
> applied:
> 26 failures without the series, 14 with patch 1 and 15 with both, no
> new failures. The extra one, generic/589, fails on and off on all
> three
> kernels with "invalid MDB drNxtCNID", the next CNID issue from the
> CNID
> thread.
>
> [1]
> https://lore.kernel.org/linux-fsdevel/161fab786f919adb384fbf22dc19f3289bf5f24d.camel@xxxxxxxxxxx/
> [2]
> https://lore.kernel.org/linux-fsdevel/20261021145627.288953-1-hengyul@xxxxxxxxxx/
>
> Hengyu Liang (2):
>   hfs: fall back to buffered I/O for direct writes past phys_size
>   hfs: remove the dead grow path from hfs_file_truncate()
>
>  fs/hfs/extent.c | 18 ++----------------
>  fs/hfs/inode.c  | 10 ++++++++++
>  2 files changed, 12 insertions(+), 16 deletions(-)
>
>
> base-commit: a804c5742bff224d4cb4d25dd383554d598be32b
> prerequisite-patch-id: 737ea6125c4a7fa08a4deb38cf33d27fb791a812

The main plan is to rework as HFS+ as HFS code to remove the
hfsplus_direct_IO(), hfs_direct_IO(). I am already working in HFS+ code
[1]. If you like I can suggest to you to do the same on HFS side. But,
unfortunately, this modification will be completely wiped out in the
future. Would you like to take the task of reworking HFS code by
removing hfs_direct_IO()? You can follow by HFS+ pattern (if it works).

Thanks,
Slava.

[1]
https://lore.kernel.org/linux-fsdevel/20260914233941.2966421-1-slava@xxxxxxxxxxx/