public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: check if device support discard in xfs_ioc_trim()
@ 2011-02-15 17:07 Lukas Czerner
  2011-02-15 18:54 ` Alex Elder
  0 siblings, 1 reply; 2+ messages in thread
From: Lukas Czerner @ 2011-02-15 17:07 UTC (permalink / raw)
  To: xfs; +Cc: hch, lczerner

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>
---
 fs/xfs/linux-2.6/xfs_discard.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/fs/xfs/linux-2.6/xfs_discard.c b/fs/xfs/linux-2.6/xfs_discard.c
index 05201ae..d61611c 100644
--- a/fs/xfs/linux-2.6/xfs_discard.c
+++ b/fs/xfs/linux-2.6/xfs_discard.c
@@ -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);
 
-- 
1.7.4

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-02-15 18:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-15 17:07 [PATCH] xfs: check if device support discard in xfs_ioc_trim() Lukas Czerner
2011-02-15 18:54 ` Alex Elder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox