Re: [PATCH v1 01/13] ntfs: limit writeback allocation to the dirty range

From: Ernest Borowski

Date: Fri Dec 04 2026 - 13:46:02 EST


Hi Baolin,

On Thu, Dec 03, 2026 at 12:03:40PM +0800, Baolin Liu wrote:
> A buffered write into a hole reserves space before copying user data.
> If the copy faults partway through, writeback can allocate the clean
> remainder of the reservation because it maps up to allocated_size.
> After fsync and cache eviction, reads can expose old disk contents
> instead of zeros.

Patch 13 of my delalloc series v5 [1] fixes the same bug in a different
way: writeback maps up to the end of the dirty folios that follow the
one being written, and zeroes a cluster larger than a page on the disk
only when some of its folios below initialized_size are not dirty. I
ran your patch, ported onto patches 1-12 of v5, through our reproducers
on the current ntfs-next. It passes the same ones as patch 13
(killed_short_write_wb, hole_fill_stale, stale_wb_race and the others).

Mapping one dirty range at a time costs time with clusters larger than
a page, because every new cluster is zeroed on the disk before its
first folio is written. fsync() of 384 MiB written into new space, 3
runs each, on a kernel without debug options:

cluster size your patch patch 13 ntfs-next
512 B, 4 KiB 98-113 ms 111-140 ms 172-204 ms
64 KiB 242-260 ms 110-120 ms 170-177 ms

Your patch also makes mkwrite_past_init pass, which patch 13 does not.
That test stores through a shared mapping 2 MiB into a file whose
initialized size is 4 KiB, and then reads the tail of the first cluster.
Your patch zeroes the whole first cluster when the first 4 KiB are
written back, so the tail happens to be zero. From reading the code, a
cluster allocated another way, for example by fallocate(), would still
show old data there; I have not tested that. Zhan's "ntfs: zero up to a
page that a shared mapping makes writable" [2] fixes that case where it
starts, when the write fault moves the initialized size.

Would you be fine with dropping 1/13 from the large folio series and
basing it on the delalloc series instead? I have not tested the large
folio patches on top of v5.

[1] https://lore.kernel.org/all/20261204-b4-ntfs-delalloc-fixes-v5-0-1cd0267df2cd@xxxxxxxxx/
[2] https://lore.kernel.org/all/20261201125126.1651071-1-zhanxusheng1024@xxxxxxxxx/

Thanks,
Ernest