]> www.infradead.org Git - users/hch/misc.git/commit
ext4: don't write back data before punch hole in nojournal mode
authorZhang Yi <yi.zhang@huawei.com>
Fri, 20 Dec 2024 01:16:30 +0000 (09:16 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 10 Feb 2025 12:48:24 +0000 (07:48 -0500)
commit43d0105e2c7523cc6b14cad65e2044e829c0a07a
tree0cfe1b72fef00b421d48f177b2fd42679b09a605
parent73ae756ecdfa9684446134590eef32b0f067249c
ext4: don't write back data before punch hole in nojournal mode

There is no need to write back all data before punching a hole in
non-journaled mode since it will be dropped soon after removing space.
Therefore, the call to filemap_write_and_wait_range() can be eliminated.
Besides, similar to ext4_zero_range(), we must address the case of
partially punched folios when block size < page size. It is essential to
remove writable userspace mappings to ensure that the folio can be
faulted again during subsequent mmap write access.

In journaled mode, we need to write dirty pages out before discarding
page cache in case of crash before committing the freeing data
transaction, which could expose old, stale data, even if synchronization
has been performed.

Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Link: https://patch.msgid.link/20241220011637.1157197-4-yi.zhang@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/inode.c