ext4: mark group as trimmed only if it was fully scanned
authorDmitry Monakhov <dmtrmonakhov@yandex-team.ru>
Sun, 17 Apr 2022 17:03:15 +0000 (20:03 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jun 2022 08:23:19 +0000 (10:23 +0200)
commit3e4b684f1e32540bec1a77b96779df35c0ff300c
tree94db74a5567788f829e7d707b8b808e4d27a7003
parent6ee0868b0c3ccead5907685fcdcdd0c08dfe4b0b
ext4: mark group as trimmed only if it was fully scanned

commit d63c00ea435a5352f486c259665a4ced60399421 upstream.

Otherwise nonaligned fstrim calls will works inconveniently for iterative
scanners, for example:

// trim [0,16MB] for group-1, but mark full group as trimmed
fstrim  -o $((1024*1024*128)) -l $((1024*1024*16)) ./m
// handle [16MB,16MB] for group-1, do nothing because group already has the flag.
fstrim  -o $((1024*1024*144)) -l $((1024*1024*16)) ./m

[ Update function documentation for ext4_trim_all_free -- TYT ]

Signed-off-by: Dmitry Monakhov <dmtrmonakhov@yandex-team.ru>
Link: https://lore.kernel.org/r/1650214995-860245-1-git-send-email-dmtrmonakhov@yandex-team.ru
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext4/mballoc.c