diff mbox

[2/2] ext4: Adjust mineln with discard_granularity in FITRIM code

Message ID 1297789585-5986-2-git-send-email-lczerner@redhat.com
State Accepted, archived
Headers show

Commit Message

Lukas Czerner Feb. 15, 2011, 5:06 p.m. UTC
Discard granularity tells us the minimum size of extent to be discarded.
Use that information to adjust minlen properly in FITRIM code. Smaller
extents will be ignored anyway, so we can optimize by not even trying to
discard them.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
 fs/ext4/ioctl.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Comments

Theodore Ts'o Feb. 23, 2011, 5:58 p.m. UTC | #1
On Tue, Feb 15, 2011 at 06:06:25PM +0100, Lukas Czerner wrote:
> Discard granularity tells us the minimum size of extent to be discarded.
> Use that information to adjust minlen properly in FITRIM code. Smaller
> extents will be ignored anyway, so we can optimize by not even trying to
> discard them.
> 
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>

Applied to the ext4 patch queue, with a rewritten commit description.

"Always write with a deep sympathy for the reader"

	      	     	  	       - Ted

ext4: Adjust minlen with discard_granularity in the FITRIM ioctl

From: Lukas Czerner <lczerner@redhat.com>

Discard granularity tells us the minimum size of extent that can be
discard 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>
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Lukas Czerner Feb. 23, 2011, 6:19 p.m. UTC | #2
On Wed, 23 Feb 2011, Ted Ts'o wrote:

> On Tue, Feb 15, 2011 at 06:06:25PM +0100, Lukas Czerner wrote:
> > Discard granularity tells us the minimum size of extent to be discarded.
> > Use that information to adjust minlen properly in FITRIM code. Smaller
> > extents will be ignored anyway, so we can optimize by not even trying to
> > discard them.
> > 
> > Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> 
> Applied to the ext4 patch queue, with a rewritten commit description.
> 
> "Always write with a deep sympathy for the reader"
> 
> 	      	     	  	       - Ted
> 
> ext4: Adjust minlen with discard_granularity in the FITRIM ioctl
> 
> From: Lukas Czerner <lczerner@redhat.com>
> 
> Discard granularity tells us the minimum size of extent that can be
> discard 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>
> 

Hi Ted,

thanks for merging and for the description. My English still needs a lot
of practice :)

Thanks!
-Lukas
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 25ba7c7..c052c9f 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -348,6 +348,8 @@  mext_out:
 		    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;