All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] ext4: check if device support discard in FITRIM ioctl
@ 2011-02-15 17:06 Lukas Czerner
  2011-02-15 17:06 ` [PATCH 2/2] ext4: Adjust mineln with discard_granularity in FITRIM code Lukas Czerner
  2011-02-23 17:50 ` [PATCH 1/2] ext4: check if device support discard in FITRIM ioctl Ted Ts'o
  0 siblings, 2 replies; 5+ messages in thread
From: Lukas Czerner @ 2011-02-15 17:06 UTC (permalink / raw)
  To: linux-ext4; +Cc: tytso, 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/ext4/ioctl.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index eb3bc2f..25ba7c7 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -334,12 +334,16 @@ mext_out:
 	case FITRIM:
 	{
 		struct super_block *sb = inode->i_sb;
+		struct request_queue *q = bdev_get_queue(sb->s_bdev);
 		struct fstrim_range range;
 		int ret = 0;
 
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
 
+		if (!blk_queue_discard(q))
+			return -EOPNOTSUPP;
+
 		if (copy_from_user(&range, (struct fstrim_range *)arg,
 		    sizeof(range)))
 			return -EFAULT;
-- 
1.7.4


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

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-15 17:06 [PATCH 1/2] ext4: check if device support discard in FITRIM ioctl Lukas Czerner
2011-02-15 17:06 ` [PATCH 2/2] ext4: Adjust mineln with discard_granularity in FITRIM code Lukas Czerner
2011-02-23 17:58   ` Ted Ts'o
2011-02-23 18:19     ` Lukas Czerner
2011-02-23 17:50 ` [PATCH 1/2] ext4: check if device support discard in FITRIM ioctl Ted Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.