]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ext4: fix inconsistent between segment fstrim and full fstrim
authorYe Bin <yebin10@huawei.com>
Sat, 16 Dec 2023 01:09:19 +0000 (09:09 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 10 Jan 2024 18:53:36 +0000 (13:53 -0500)
commit68da4c44b994aea797eb9821acb3a4a36015293e
tree5acbb3d7472f31345574cc20c4999b0f87bb6b0c
parent1f6bc02f18489b9c9ea39b068d0695fb0e4567e9
ext4: fix inconsistent between segment fstrim and full fstrim

Suppose we issue two FITRIM ioctls for ranges [0,15] and [16,31] with
mininum length of trimmed range set to 8 blocks. If we have say a range of
blocks 10-22 free, this range will not be trimmed because it straddles the
boundary of the two FITRIM ranges and neither part is big enough. This is a
bit surprising to some users that call FITRIM on smaller ranges of blocks
to limit impact on the system. Also XFS trims all free space extents that
overlap with the specified range so we are inconsistent among filesystems.
Let's change ext4_try_to_trim_range() to consider for trimming the whole
free space extent that straddles the end of specified range, not just the
part of it within the range.

Signed-off-by: Ye Bin <yebin10@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20231216010919.1995851-1-yebin10@huawei.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/mballoc.c