]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ext4: Adjust minlen with discard_granularity in the FITRIM ioctl
authorLukas Czerner <lczerner@redhat.com>
Wed, 23 Feb 2011 22:49:51 +0000 (17:49 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 23 Feb 2011 22:49:51 +0000 (17:49 -0500)
Discard granularity tells us the minimum size of extent that can be
discarded by the device.  If the user supplies a minimum extent that
should be discarded (range.minlen) which is smaller than the discard
granularity, increase minlen to the discard granularity, since there's
no point submitting trim requests that the device will reject anyway.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
fs/ext4/ioctl.c

index 25ba7c79d2893eadde4105b20116a2a5d0acb5b4..c052c9f0f3a160de1607125d9ecc1ea0e1964602 100644 (file)
@@ -348,6 +348,8 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
                    sizeof(range)))
                        return -EFAULT;
 
+               range.minlen = max((unsigned int)range.minlen,
+                                  q->limits.discard_granularity);
                ret = ext4_trim_fs(sb, &range);
                if (ret < 0)
                        return ret;