Unfortunately, this patch is not correct. The units of struct
fstrim_range's minlen (here, range->minlen) is bytes.
IIUC, if range->minlen is smaller than block size of ext4, above calculation
However the minlen variable in ext4_trim_fs is in units of *clusters*.
And so it gets rounded up two places. The first time is when it is
converted into units of a cluster:
minlen = EXT4_NUM_B2C(EXT4_SB(sb),
range->minlen >> sb->s_blocksize_bits);
And the second time is when it is rounded up to the block device's
discard granularity.
So after that if statement, we need to convert minlen from clusters to
bytes, like so:
range->minlen = EXT4_C2B(EXT4_SB(sb), minlen) << sb->s_blocksize_bits);