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

From: liubaolin

Date: Sat Dec 05 2026 - 05:30:26 EST




在 2026/12/5 02:45, Ernest Borowski 写道:
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

Hi Ernest,
Thanks for checking this and testing my patch.
I ran into these issues while developing and testing the large folio
series against ntfs-next as it stood at the time.
I should have checked for overlap with your delalloc series before
posting. Sorry about that.
After going through both series again, I see that my patches 1 and 5
address the same issues as patches 13 and 4, respectively, of your v5
series.
I'm happy to drop those two patches and build on your fixes.
I'll hold off on posting v2 until your series lands in ntfs-next,
then rebase the remaining patches and rerun the tests before sending it.
Thanks again for your help. You've done a really thorough job with
these fixes, and I appreciate the time you've taken to check my changes too.

Thanks,
Baolin.