ext4: add a hole extent entry in cache after punch

In order to cache hole extents in the extent status tree and keep the
hole length as long as possible, re-add a hole entry to the cache just
after punching a hole.

Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20240127015825.1608160-5-yi.zhang@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

authored by Zhang Yi and committed by Theodore Ts'o 9f111822 6430dea0

Changed files
+4 -2
fs
ext4
+4 -2
fs/ext4/inode.c
··· 4007 4007 4008 4008 /* If there are blocks to remove, do it */ 4009 4009 if (stop_block > first_block) { 4010 + ext4_lblk_t hole_len = stop_block - first_block; 4010 4011 4011 4012 down_write(&EXT4_I(inode)->i_data_sem); 4012 4013 ext4_discard_preallocations(inode); 4013 4014 4014 - ext4_es_remove_extent(inode, first_block, 4015 - stop_block - first_block); 4015 + ext4_es_remove_extent(inode, first_block, hole_len); 4016 4016 4017 4017 if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) 4018 4018 ret = ext4_ext_remove_space(inode, first_block, ··· 4021 4021 ret = ext4_ind_remove_space(handle, inode, first_block, 4022 4022 stop_block); 4023 4023 4024 + ext4_es_insert_extent(inode, first_block, hole_len, ~0, 4025 + EXTENT_STATUS_HOLE); 4024 4026 up_write(&EXT4_I(inode)->i_data_sem); 4025 4027 } 4026 4028 ext4_fc_track_range(handle, inode, first_block, stop_block);