]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ext4: fix stale data if it bail out of the extents mapping loop
authorZhang Yi <yi.zhang@huawei.com>
Mon, 7 Jul 2025 14:08:06 +0000 (22:08 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Aug 2025 14:49:41 +0000 (16:49 +0200)
commit98571b628c61e8129dfc24d60544385833fbcd12
tree90c43d43f53370d3100f1bc7a40d76effc1eb9b7
parentde83915e8f2a5d03dec8ccbc05a6bd711f409e76
ext4: fix stale data if it bail out of the extents mapping loop

commit ded2d726a3041fce8afd88005cbfe15cd4737702 upstream.

During the process of writing back folios, if
mpage_map_and_submit_extent() exits the extent mapping loop due to an
ENOSPC or ENOMEM error, it may result in stale data or filesystem
inconsistency in environments where the block size is smaller than the
folio size.

When mapping a discontinuous folio in mpage_map_and_submit_extent(),
some buffers may have already be mapped. If we exit the mapping loop
prematurely, the folio data within the mapped range will not be written
back, and the file's disk size will not be updated. Once the transaction
that includes this range of extents is committed, this can lead to stale
data or filesystem inconsistency.

Fix this by submitting the current processing partially mapped folio.

Suggested-by: Jan Kara <jack@suse.cz>
Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20250707140814.542883-4-yi.zhang@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext4/inode.c