ext4: avoid trim error on fs with small groups
authorJan Kara <jack@suse.cz>
Fri, 12 Nov 2021 15:22:02 +0000 (16:22 +0100)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 10 Jan 2022 18:25:55 +0000 (13:25 -0500)
commit173b6e383d2a204c9921ffc1eca3b87aa2106c33
treee550a04527303c784286fab4ef8a8734e5767b00
parent5c48a7df91499e371ef725895b2e2d21a126e227
ext4: avoid trim error on fs with small groups

A user reported FITRIM ioctl failing for him on ext4 on some devices
without apparent reason.  After some debugging we've found out that
these devices (being LVM volumes) report rather large discard
granularity of 42MB and the filesystem had 1k blocksize and thus group
size of 8MB. Because ext4 FITRIM implementation puts discard
granularity into minlen, ext4_trim_fs() declared the trim request as
invalid. However just silently doing nothing seems to be a more
appropriate reaction to such combination of parameters since user did
not specify anything wrong.

CC: Lukas Czerner <lczerner@redhat.com>
Fixes: 5c2ed62fd447 ("ext4: Adjust minlen with discard_granularity in the FITRIM ioctl")
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20211112152202.26614-1-jack@suse.cz
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/ioctl.c
fs/ext4/mballoc.c