Message ID | 20180906211816.12121-3-jeffm@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: trim latency improvements | expand |
On Thu, Sep 06, 2018 at 05:18:15PM -0400, jeffm@suse.com wrote: > From: Jeff Mahoney <jeffm@suse.com> > > 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) > Signed-off-by: Jeff Mahoney <jeffm@suse.com> Reviewed-by: David Sterba <dsterba@suse.com>
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index a0e82589c3e8..92e5e9fd9bdd 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -10887,6 +10887,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;