Commit be715140 authored by Lukas Czerner's avatar Lukas Czerner Committed by Alex Elder

xfs: check if device support discard in xfs_ioc_trim()

Right now we, are relying on the fact that when we attempt to
actually do the discard, blkdev_issue_discar() returns -EOPNOTSUPP
and the user is informed that the device does not support discard.

However, in the case where the we do not hit any suitable free
extent to trim in FITRIM code, it will finish without any error.
This is very confusing, because it seems that FITRIM was successful
even though the device does not actually supports discard.

Solution: Check for the discard support before attempt to search for
free extents.
Signed-off-by: default avatarLukas Czerner <lczerner@redhat.com>
Signed-off-by: default avatarAlex Elder <aelder@sgi.com>
parent 3a3675b7
...@@ -152,6 +152,8 @@ xfs_ioc_trim( ...@@ -152,6 +152,8 @@ xfs_ioc_trim(
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -XFS_ERROR(EPERM); return -XFS_ERROR(EPERM);
if (!blk_queue_discard(q))
return -XFS_ERROR(EOPNOTSUPP);
if (copy_from_user(&range, urange, sizeof(range))) if (copy_from_user(&range, urange, sizeof(range)))
return -XFS_ERROR(EFAULT); return -XFS_ERROR(EFAULT);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment