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

From: Hengyu Liang

Date: Fri Oct 30 2026 - 00:30:59 EST


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
--
2.53.0