[PATCH 2/7] ntfs: do not consume delalloc reservations when filling holes
From: Ernest Borowski via B4 Relay
Date: Sun Nov 22 2026 - 13:19:59 EST
From: Ernest Borowski <ernest.borowski.git@xxxxxxxxx>
ntfs_attr_map_cluster() always calls ntfs_cluster_alloc() with
is_dealloc set, which makes the allocator skip the dirty_clusters check
and subtract the allocated clusters from vol->dirty_clusters. That is
right for writeback converting an LCN_DELALLOC run, whose clusters were
reserved by the buffered write, but ntfs_attr_map_cluster() also fills
plain holes for fallocate(), direct I/O and page_mkwrite(), which never
reserved anything. Those allocations release reservations that belong
to dirty data of other files, and can use clusters that are promised to
that data, so writeback of the delayed data can later run out of space
although every earlier check succeeded.
Reproducer: write 1 MiB to file A without syncing (statfs() free space
drops by 256 clusters), then fallocate() 1 MiB on file B: free space
does not drop at all.
Only treat the allocation as consuming a reservation when the run being
filled is a delalloc run. Filling a hole now fails with ENOSPC when the
remaining free clusters are all reserved for delayed data, so a write
fault into a hole of an mmap()ed file gets SIGBUS in that case, as on
other filesystems with delayed allocation.
Fixes: 495e90fa3348 ("ntfs: update attrib operations")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Ernest Borowski <ernest.borowski.git@xxxxxxxxx>
---
fs/ntfs/attrib.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
index 4028c310fc..cdac846f37 100644
--- a/fs/ntfs/attrib.c
+++ b/fs/ntfs/attrib.c
@@ -5520,8 +5520,14 @@ int ntfs_attr_map_cluster(struct ntfs_inode *ni, s64 vcn_start, s64 *lcn_start,
}
}
+ /*
+ * Only a delayed-allocation run holds a reservation in
+ * vol->dirty_clusters for the allocator to consume. Holes filled by
+ * fallocate(), direct I/O or page_mkwrite() have none and must leave
+ * the reservations of other writers alone.
+ */
rlc = ntfs_cluster_alloc(vol, vcn, clu_count, lcn_seek_from, DATA_ZONE,
- false, true, true);
+ false, true, lcn == LCN_DELALLOC);
if (IS_ERR(rlc)) {
err = PTR_ERR(rlc);
goto out;
--
2.56.1