ext4: remove unnecessary parameter "needed" in ext4_discard_preallocations
authorKemeng Shi <shikemeng@huaweicloud.com>
Fri, 5 Jan 2024 09:21:01 +0000 (17:21 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 18 Jan 2024 15:52:45 +0000 (10:52 -0500)
commit2ffd2a6ad1d3a8213bb5805f45f49098fe615db1
treeab4f3a039b03fb8c3942f9446ea9d4f8877c7068
parent20427949b9b584422c05bb31e48b1b68615dd794
ext4: remove unnecessary parameter "needed" in ext4_discard_preallocations

The "needed" controls the number of ext4_prealloc_space to discard in
ext4_discard_preallocations. Function ext4_discard_preallocations is
supposed to discard all non-used preallocated blocks when "needed"
is 0 and now ext4_discard_preallocations is always called with "needed"
= 0. Remove unnecessary parameter "needed" and remove all non-used
preallocated spaces in ext4_discard_preallocations to simplify the
code.

Note: If count of non-used preallocated spaces could be more than
UINT_MAX, there was a memory leak as some non-used preallocated
spaces are left ununsed and this commit will fix it. Otherwise,
there is no behavior change.

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20240105092102.496631-9-shikemeng@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/ext4.h
fs/ext4/extents.c
fs/ext4/file.c
fs/ext4/indirect.c
fs/ext4/inode.c
fs/ext4/ioctl.c
fs/ext4/mballoc.c
fs/ext4/move_extent.c
fs/ext4/super.c