Skip to content

Commit

Permalink
xfs: check if device support discard in xfs_ioc_trim()
Browse files Browse the repository at this point in the history
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: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Alex Elder <aelder@sgi.com>
  • Loading branch information
Lukas Czerner authored and Alex Elder committed Feb 22, 2011
1 parent c4d0c3b commit 5d15765
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fs/xfs/linux-2.6/xfs_discard.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ xfs_ioc_trim(

if (!capable(CAP_SYS_ADMIN))
return -XFS_ERROR(EPERM);
if (!blk_queue_discard(q))
return -XFS_ERROR(EOPNOTSUPP);
if (copy_from_user(&range, urange, sizeof(range)))
return -XFS_ERROR(EFAULT);

Expand Down

0 comments on commit 5d15765

Please sign in to comment.