Skip to content

Commit

Permalink
ext4: Adjust minlen with discard_granularity in the FITRIM ioctl
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Lukas Czerner authored and Theodore Ts'o committed Feb 23, 2011
1 parent 4143179 commit 5c2ed62
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fs/ext4/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5c2ed62

Please sign in to comment.