]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
gfs2: Make sure FITRIM minlen is rounded up to fs block size
authorAndrew Price <anprice@redhat.com>
Tue, 22 Mar 2022 19:05:51 +0000 (19:05 +0000)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 27 Apr 2022 09:58:47 +0000 (11:58 +0200)
commit9ce39d160c3848745ee1b2e7a875ffe73e1bbac1
tree827ac1b25ce4a3573c6cd7e019822eea39f58eef
parenta732c7c8c616f4b057d97bea3606b1699bbc87fd
gfs2: Make sure FITRIM minlen is rounded up to fs block size

BugLink: https://bugs.launchpad.net/bugs/1969110
commit 27ca8273fda398638ca994a207323a85b6d81190 upstream.

Per fstrim(8) we must round up the minlen argument to the fs block size.
The current calculation doesn't take into account devices that have a
discard granularity and requested minlen less than 1 fs block, so the
value can get shifted away to zero in the translation to fs blocks.

The zero minlen passed to gfs2_rgrp_send_discards() then allows
sb_issue_discard() to be called with nr_sects == 0 which returns -EINVAL
and results in gfs2_rgrp_send_discards() returning -EIO.

Make sure minlen is never < 1 fs block by taking the max of the
requested minlen and the fs block size before comparing to the device's
discard granularity and shifting to fs blocks.

Fixes: 076f0faa764ab ("GFS2: Fix FITRIM argument handling")
Signed-off-by: Andrew Price <anprice@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 5c3c9bce1c99bf58efdf1c7af870240777ca64b5)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
fs/gfs2/rgrp.c