Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5c2ed62f authored by Lukas Czerner's avatar Lukas Czerner Committed by Theodore Ts'o
Browse files

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: default avatarLukas Czerner <lczerner@redhat.com>
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent 41431792
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -348,6 +348,8 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
		    sizeof(range)))
		    sizeof(range)))
			return -EFAULT;
			return -EFAULT;


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