]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
btrfs: Honour FITRIM range constraints during free space trim
authorNikolay Borisov <nborisov@suse.com>
Mon, 25 Mar 2019 12:31:21 +0000 (14:31 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 May 2019 05:38:53 +0000 (07:38 +0200)
commitb9ee627187491547791aacf96d4dd8f4d9afbf1c
tree89c6d4f5fffd7231c107bba4250e467a84f0577f
parent4afdd2d2afbbeab511ff68211a80aca24d5be37b
btrfs: Honour FITRIM range constraints during free space trim

commit c2d1b3aae33605a61cbab445d8ae1c708ccd2698 upstream.

Up until now trimming the freespace was done irrespective of what the
arguments of the FITRIM ioctl were. For example fstrim's -o/-l arguments
will be entirely ignored. Fix it by correctly handling those paramter.
This requires breaking if the found freespace extent is after the end of
the passed range as well as completing trim after trimming
fstrim_range::len bytes.

Fixes: 499f377f49f0 ("btrfs: iterate over unused chunk space in FITRIM")
CC: stable@vger.kernel.org # 4.4+
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/extent-tree.c