]> git.ipfire.org Git - thirdparty/linux.git/commit
ext4: refactor zeroout path and handle all cases
authorOjaswin Mujoo <ojaswin@linux.ibm.com>
Fri, 23 Jan 2026 06:25:37 +0000 (11:55 +0530)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 23 Jan 2026 21:49:53 +0000 (16:49 -0500)
commita985e07c264552d0aa7c019ca54d075414c56620
treeeb0a855f45f5b3b98f42e29b7b636926ebb96875
parent6066990c99c48d8955eb4b467c11e14daa8d5ec4
ext4: refactor zeroout path and handle all cases

Currently, zeroout is used as a fallback in case we fail to
split/convert extents in the "traditional" modify-the-extent-tree way.
This is essential to mitigate failures in critical paths like extent
splitting during endio. However, the logic is very messy and not easy to
follow. Further, the fragile use of various flags has made it prone to
errors.

Refactor zeroout out logic by moving it up to ext4_split_extents().
Further, zeroout correctly based on the type of conversion we want, ie:
- unwritten to written: Zeroout everything around the mapped range.
- written to unwritten: Zeroout only the mapped range.

Also, ext4_ext_convert_to_initialized() now passes
EXT4_GET_BLOCKS_CONVERT to make the intention clear.

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