Skip to content

Commit 5c2ed62

Browse files
Lukas Czernertytso
authored andcommitted
ext4: Adjust minlen with discard_granularity in the FITRIM ioctl
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 <[email protected]> Signed-off-by: "Theodore Ts'o" <[email protected]>
1 parent 4143179 commit 5c2ed62

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/ext4/ioctl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,8 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
348348
sizeof(range)))
349349
return -EFAULT;
350350

351+
range.minlen = max((unsigned int)range.minlen,
352+
q->limits.discard_granularity);
351353
ret = ext4_trim_fs(sb, &range);
352354
if (ret < 0)
353355
return ret;

0 commit comments

Comments
 (0)