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

From: Ernest Borowski

Date: Tue Dec 01 2026 - 12:42:47 EST


On Tue, Dec 01, 2026 at 10:26:49AM +0800, Baolin Liu wrote:
> Could we also call mapping_set_error(inode->i_mapping, err) here?
> The write can still return a positive short count when the tail
> zeroing fails, and ntfs_file_fsync() doesn't check NVolErrors, so a
> subsequent fsync() could succeed without reporting this error.

Yes, thank you. ntfs_file_fsync() ignores NVolErrors() and sees only
the errors that file_write_and_wait_range() returns, so fsync() returned
0 after a failed zeroing. v4 records the error in the mapping:

if (err) {
ntfs_error(vol->sb,
"Failed to zero [%lld, %lld) of inode 0x%llx after a short write: %d",
start, end, NTFS_I(inode)->mft_no, err);
NVolSetErrors(vol);
/* the write returns the bytes copied; let fsync() see it */
mapping_set_error(inode->i_mapping, err);
}

fsync() then returns that error instead of 0.

A new test checks this [1]. It does a short buffered write into a
hole, uses fail-nth to inject a failure at each fault site of that
write, and checks fsync() whenever the zeroing fails. The zeroing
failed 33 times, with 16 KiB and 64 KiB clusters on Ubuntu and Arch.
After each of them fsync() returned 0 on v3, and it fails with ENOMEM
on v4.

v4 also drops this patch's own copy of ntfs_zero_range_unkillable().
Now that Zhan's short write fix is in ntfs-next, the patch uses the
copy in file.c instead. It also adds the lockdep check of the
invalidate lock that its own copy had, as both callers hold the lock.

[1] https://github.com/xerrni/linux-ntfs/blob/master/tests/delalloc_tail_zero_failure.sh