summaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2018-09-06 17:18:15 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-11-13 11:15:14 -0800
commitda05e93720843101d7b70c84b63805a37d4485d1 (patch)
treebd38240e7eb3d4854cd192fb57d9088d96eb5f6d /fs/btrfs
parenta7d24c89db0b0b664046aebd1e0f9aef7306b944 (diff)
downloadlinux-stable-da05e93720843101d7b70c84b63805a37d4485d1.tar.gz
linux-stable-da05e93720843101d7b70c84b63805a37d4485d1.tar.bz2
linux-stable-da05e93720843101d7b70c84b63805a37d4485d1.zip
btrfs: don't attempt to trim devices that don't support it
commit 0be88e367fd8fbdb45257615d691f4675dda062f upstream. We check whether any device the file system is using supports discard in the ioctl call, but then we attempt to trim free extents on every device regardless of whether discard is supported. Due to the way we mask off EOPNOTSUPP, we can end up issuing the trim operations on each free range on devices that don't support it, just wasting time. Fixes: 499f377f49f08 ("btrfs: iterate over unused chunk space in FITRIM") CC: stable@vger.kernel.org # 4.4+ Signed-off-by: Jeff Mahoney <jeffm@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>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/extent-tree.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 3ebef3ab9dde..43a2d77039df 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -10976,6 +10976,10 @@ static int btrfs_trim_free_extents(struct btrfs_device *device,
*trimmed = 0;
+ /* Discard not supported = nothing to do. */
+ if (!blk_queue_discard(bdev_get_queue(device->bdev)))
+ return 0;
+
/* Not writeable = nothing to do. */
if (!device->writeable)
return 0;