ext4: using nofail preallocation in ext4_es_remove_extent()
authorBaokun Li <libaokun1@huawei.com>
Mon, 24 Apr 2023 03:38:40 +0000 (11:38 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 26 Jun 2023 23:35:12 +0000 (19:35 -0400)
commite9fe2b882bd5b26b987c9ba110c2222796f72af5
treedf7a8aa8fe8b435d3f80032d1f0bf4d10423ac3d
parentbda3efaf774fb687c2b7a555aaec3006b14a8857
ext4: using nofail preallocation in ext4_es_remove_extent()

If __es_remove_extent() returns an error it means that when splitting
extent, allocating an extent that must be kept failed, where returning
an error directly would cause the extent tree to be inconsistent. So we
use GFP_NOFAIL to pre-allocate an extent_status and pass it to
__es_remove_extent() to avoid this problem.

In addition, since the allocated memory is outside the i_es_lock, the
extent_status tree may change and the pre-allocated extent_status is
no longer needed, so we release the pre-allocated extent_status when
es->es_len is not initialized.

Suggested-by: Jan Kara <jack@suse.cz>
Signed-off-by: Baokun Li <libaokun1@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20230424033846.4732-7-libaokun1@huawei.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/extents_status.c