diff options
author | Jeff Mahoney <jeffm@suse.com> | 2018-09-06 17:18:15 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-10-15 17:23:32 +0200 |
commit | 0be88e367fd8fbdb45257615d691f4675dda062f (patch) | |
tree | d87c1ecf1e3ae1e2dba10c199a42105aadb43838 /fs/btrfs/extent-tree.c | |
parent | d4e329de5e5e21594df2e0dd59da9acee71f133b (diff) | |
download | linux-0be88e367fd8fbdb45257615d691f4675dda062f.tar.bz2 |
btrfs: don't attempt to trim devices that don't support it
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>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 41fb24da7afa..6e1c2a22874f 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -10772,6 +10772,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 (!test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) return 0; |