exfat: move extend valid_size into ->page_mkwrite()
authorYuezhang Mo <Yuezhang.Mo@sony.com>
Mon, 23 Sep 2024 12:37:32 +0000 (21:37 +0900)
committerNamjae Jeon <linkinjeon@kernel.org>
Mon, 23 Sep 2024 12:38:11 +0000 (21:38 +0900)
commit6630ea49103c3d45461e29b0f6eb0ce750aeb8f5
tree585813f8ca54dc7564583171cd66581b98d7d2f2
parentd2b537b3e533f28e0d97293fe9293161fe8cd137
exfat: move extend valid_size into ->page_mkwrite()

It is not a good way to extend valid_size to the end of the
mmap area by writing zeros in mmap. Because after calling mmap,
no data may be written, or only a small amount of data may be
written to the head of the mmap area.

This commit moves extending valid_size to exfat_page_mkwrite().
In exfat_page_mkwrite() only extend valid_size to the starting
position of new data writing, which reduces unnecessary writing
of zeros.

If the block is not mapped and is marked as new after being
mapped for writing, block_write_begin() will zero the page
cache corresponding to the block, so there is no need to call
zero_user_segment() in exfat_file_zeroed_range(). And after moving
extending valid_size to exfat_page_mkwrite(), the data written by
mmap will be copied to the page cache but the page cache may be
not mapped to the disk. Calling zero_user_segment() will cause
the data written by mmap to be cleared. So this commit removes
calling zero_user_segment() from exfat_file_zeroed_range() and
renames exfat_file_zeroed_range() to exfat_extend_valid_size().

Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
fs/exfat/file.c