Skip to content

Commit

Permalink
btrfs: don't attempt to trim devices that don't support it
Browse files Browse the repository at this point in the history
commit 0be88e3 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: 499f377 ("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>
  • Loading branch information
Jeff Mahoney authored and Greg Kroah-Hartman committed Nov 13, 2018
1 parent d87af98 commit 391235f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -11071,6 +11071,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;
Expand Down

0 comments on commit 391235f

Please sign in to comment.