summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyunchul Lee <hyc.lee@gmail.com>2026-04-03 02:54:11 +0300
committerNamjae Jeon <linkinjeon@kernel.org>2026-04-18 05:33:00 +0300
commitca513e492fb8ac59f5e3092a79d836cd2e687a2a (patch)
tree7f562cc93e5fdf6b2abcd5bef418c4b8f63453a8
parent8b4064e6146efc6c0202d671c4e26bcbd26e3555 (diff)
downloadlinux-ca513e492fb8ac59f5e3092a79d836cd2e687a2a.tar.xz
ntfs: not zero out range beyond init in punch_hole
The area beyond initialized_size are read as zero values, there is no need to zero out that region. Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
-rw-r--r--fs/ntfs/file.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index e1a9ba544644..34003fa07dd1 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -876,14 +876,19 @@ static int ntfs_punch_hole(struct ntfs_inode *ni, int mode, loff_t offset,
end_vcn = ntfs_bytes_to_cluster(vol, end_offset - 1) + 1;
if (offset & vol->cluster_size_mask) {
- loff_t to;
-
- to = min_t(loff_t, ntfs_cluster_to_bytes(vol, start_vcn + 1),
- end_offset);
- err = iomap_zero_range(vi, offset, to - offset, NULL,
- &ntfs_seek_iomap_ops,
- &ntfs_iomap_folio_ops, NULL);
- if (err < 0 || (end_vcn - start_vcn) == 1)
+ if (offset < ni->initialized_size) {
+ loff_t to;
+
+ to = min_t(loff_t,
+ ntfs_cluster_to_bytes(vol, start_vcn + 1),
+ end_offset);
+ err = iomap_zero_range(vi, offset, to - offset,
+ NULL, &ntfs_seek_iomap_ops,
+ &ntfs_iomap_folio_ops, NULL);
+ if (err < 0)
+ goto out;
+ }
+ if (end_vcn - start_vcn == 1)
goto out;
start_vcn++;
}
@@ -892,10 +897,14 @@ static int ntfs_punch_hole(struct ntfs_inode *ni, int mode, loff_t offset,
loff_t from;
from = ntfs_cluster_to_bytes(vol, end_vcn - 1);
- err = iomap_zero_range(vi, from, end_offset - from, NULL,
- &ntfs_seek_iomap_ops,
- &ntfs_iomap_folio_ops, NULL);
- if (err < 0 || (end_vcn - start_vcn) == 1)
+ if (from < ni->initialized_size) {
+ err = iomap_zero_range(vi, from, end_offset - from,
+ NULL, &ntfs_seek_iomap_ops,
+ &ntfs_iomap_folio_ops, NULL);
+ if (err < 0)
+ goto out;
+ }
+ if (end_vcn - start_vcn == 1)
goto out;
end_vcn--;
}