exfat: reduce unnecessary writes during mmap write
Subsystems (2)
PATCH v2 1/1 exfat: reduce unnecessary writes during mmap write
From: Yuling Dong <[email protected]>
During mmap write, exfat_page_mkwrite() currently extends valid_size to the end of the VMA range. For a large mapping, this can push valid_size far beyond the page that actually triggered the fault, resulting in unnecessary writes.
valid_size only needs to extend to the end of the page being written.
--- fs/exfat/file.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
fs/exfat/file.c +6 -9
@@ -707,21 +707,18 @@ static ssize_t exfat_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)static vm_fault_t exfat_page_mkwrite (struct vm_fault *vmf) {int err; -struct vm_area_struct *vma = vmf->vma; -struct file *file = vma->vm_file; -struct inode *inode =file_inode (file); +struct inode *inode =file_inode (vmf->vma->vm_file);struct exfat_inode_info *ei =EXFAT_I (inode); -loff_t start, end; +loff_t new_valid_size;if (!inode_trylock (inode))return VM_FAULT_RETRY ; - start = ((loff_t )vma->vm_pgoff <<PAGE_SHIFT ); - end =min_t (loff_t,i_size_read (inode), - start + vma->vm_end - vma->vm_start); + new_valid_size = ((loff_t )vmf->pgoff +1 ) <<PAGE_SHIFT ; + new_valid_size =min (new_valid_size,i_size_read (inode)); -if (ei->valid_size < end) { - err =exfat_extend_valid_size (inode, end); +if (ei->valid_size < new_valid_size) { + err =exfat_extend_valid_size (inode, new_valid_size);if (err <0 ) {inode_unlock (inode);return vmf_fs_error (err);
Signature · 1 line
2.43.0
Quoted 8 lines · On Thu, Jan 15, 2026 at 2:07 PM <[email protected]> wrote:
From: Yuling Dong <[email protected]>
During mmap write,
exfat_page_mkwrite()currently extendsvalid_sizeto the end of the VMA range. For a large mapping, this can pushvalid_sizefar beyond the page that actually triggered the fault, resulting in unnecessary writes.
Quoted 4 lines
valid_sizeonly needs to extend to the end of the page being written.Signed-off-by Yuling Dong <[email protected]>
Applied it to #dev.
Thanks!