Re: [PATCH v4 10/11] ntfs: zero the rest of a new cluster after a short buffered write

From: Ernest Borowski

Date: Fri Dec 04 2026 - 13:45:51 EST


Hi Hyunchul,

On Fri, Dec 04, 2026 at 10:05:55AM +0900, Hyunchul Lee wrote:
> Instead of marking this range dirty directly, how about zeroing it with
> iomap_zero_range()? __iomap_write_end() marks exactly the zeroed range
> dirty.
>
> if (ntfs_pos_is_delalloc(inode, start)) {
> ntfs_zero_range_unkillable(...)
> continue;
> }
>
> folio = filemap_lock_folio(...)
> if (IS_ERR(folio))
> continue;
> if (folio_test_uptodate(folio))
> folio_mark_dirty(folio);
> ...

Thanks, the first half is simpler, and patch 10 of v5 [1] now does it.
While the cluster is still delalloc, only this write and its zeroing of
the cluster's edges can have put data there: a write fault allocates
the cluster. So zeroing the whole rest of the cluster loses nothing,
and since [start, end) never leaves one cluster, one check and one
ntfs_zero_range_unkillable() call cover it.

I would keep iomap_dirty_folio_range() for the second half, though.
That branch runs when a write fault or writeback allocated the cluster
during the copy. With 1 KiB or 2 KiB clusters a folio holds several
clusters, and folio_mark_dirty() dirties all of its blocks. The blocks
of the clusters after this one, which the write reserved but did not
reach, then look dirty to iomap_write_delalloc_release(), so they are
not punched out: writeback allocates them for zeroes, or past EOF they
stay reserved. That case is from reading the code. Our reproducers
give the same results with your version as with mine, as none of them
has a write fault allocate the cluster during the copy with clusters
smaller than a page.

With your change to the delalloc case, the reproducers of this series
(short_copy_stale, delalloc_tail_zero_failure, killed_short_write and
the others) still pass on Ubuntu and Arch:

https://github.com/xerrni/linux-ntfs/actions/runs/47382064876

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

Thanks,
Ernest