Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Hyunchul Lee and committed by
Namjae Jeon
ca513e49 8b4064e6

+20 -11
+20 -11
fs/ntfs/file.c
··· 876 876 end_vcn = ntfs_bytes_to_cluster(vol, end_offset - 1) + 1; 877 877 878 878 if (offset & vol->cluster_size_mask) { 879 - loff_t to; 879 + if (offset < ni->initialized_size) { 880 + loff_t to; 880 881 881 - to = min_t(loff_t, ntfs_cluster_to_bytes(vol, start_vcn + 1), 882 - end_offset); 883 - err = iomap_zero_range(vi, offset, to - offset, NULL, 884 - &ntfs_seek_iomap_ops, 885 - &ntfs_iomap_folio_ops, NULL); 886 - if (err < 0 || (end_vcn - start_vcn) == 1) 882 + to = min_t(loff_t, 883 + ntfs_cluster_to_bytes(vol, start_vcn + 1), 884 + end_offset); 885 + err = iomap_zero_range(vi, offset, to - offset, 886 + NULL, &ntfs_seek_iomap_ops, 887 + &ntfs_iomap_folio_ops, NULL); 888 + if (err < 0) 889 + goto out; 890 + } 891 + if (end_vcn - start_vcn == 1) 887 892 goto out; 888 893 start_vcn++; 889 894 } ··· 897 892 loff_t from; 898 893 899 894 from = ntfs_cluster_to_bytes(vol, end_vcn - 1); 900 - err = iomap_zero_range(vi, from, end_offset - from, NULL, 901 - &ntfs_seek_iomap_ops, 902 - &ntfs_iomap_folio_ops, NULL); 903 - if (err < 0 || (end_vcn - start_vcn) == 1) 895 + if (from < ni->initialized_size) { 896 + err = iomap_zero_range(vi, from, end_offset - from, 897 + NULL, &ntfs_seek_iomap_ops, 898 + &ntfs_iomap_folio_ops, NULL); 899 + if (err < 0) 900 + goto out; 901 + } 902 + if (end_vcn - start_vcn == 1) 904 903 goto out; 905 904 end_vcn--; 906 905 }