[PATCH 05/11] fs/ntfs3: do not force allocation for IOMAP_ZERO on a partial cluster
From: Konstantin Komarov
Date: Fri Oct 09 2026 - 13:24:11 EST
ntfs_iomap_begin() set 'rw' for IOMAP_ZERO whenever the end of the
range fell inside a cluster, forcing the sparse path to allocate
clusters in order to zero them.
Drop the IOMAP_ZERO case and only clamp clen_max when 'rw' is already
set.
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@xxxxxxxxxxxxxxxxxxxx>
---
fs/ntfs3/inode.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index 1f1b2e5897e1..a3b2daaecb4d 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -968,9 +968,7 @@ static int ntfs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
}
}
- if (IOMAP_ZERO == flags && (endbyte & sbi->cluster_mask)) {
- rw = true;
- } else if (rw) {
+ if (rw) {
clen_max = bytes_to_cluster(sbi, endbyte) - vcn;
}
@@ -978,7 +976,7 @@ static int ntfs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
* Force to allocate clusters if directIO(write) or writeback_range.
* NOTE: attr_data_get_block allocates clusters only for sparse file.
* Normal file allocates clusters in attr_set_size.
- */
+ */
no_da = flags == (IOMAP_DIRECT | IOMAP_WRITE) || srcmap == WB_NO_DA;
err = attr_data_get_block(ni, vcn, clen_max, &lcn, &clen,
@@ -987,8 +985,12 @@ static int ntfs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
if (err) {
return err;
}
- if (!clen)
+ if (!clen) {
+ /* Looks like file is broken.
+ * It is marked as bad via _ntfs_bad_inode
+ */
return -EINVAL;
+ }
if (lcn == EOF_LCN) {
/* request out of file. */
--
2.43.0