]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 May 2025 09:13:34 +0000 (11:13 +0200)
commitef086af377113fd042b313710ed7b4425d0bf0b3
treeac6d32a3753cc60c817457af0d75b337d052c7b4
parenteafaf48809b0db2b21d3be595a0a3603a2a2d057
ext4: don't write back data before punch hole in nojournal mode

[ Upstream commit 43d0105e2c7523cc6b14cad65e2044e829c0a07a ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/ext4/inode.c