linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: enable FITRIM ioctl on bigalloc file system
@ 2012-07-03 19:10 Lukas Czerner
  2012-08-21  9:48 ` Lukáš Czerner
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Lukas Czerner @ 2012-07-03 19:10 UTC (permalink / raw)
  To: linux-ext4; +Cc: tytso, Lukas Czerner

With a minor tweaks regarding minimum extent size to discard and
discarded bytes reporting the FITRIM can be enabled on bigalloc file
system and it works without any problem.

This patch fixes minlen handling and discarded bytes reporting to
take into consideration bigalloc enabled file systems and finally
removes the restriction and allow FITRIM to be used on file system with
bigalloc feature enabled.

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

diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index e34deac..9d6e0bc 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -420,13 +420,6 @@ resizefs_out:
 		if (!blk_queue_discard(q))
 			return -EOPNOTSUPP;
 
-		if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
-			       EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
-			ext4_msg(sb, KERN_ERR,
-				 "FITRIM not supported with bigalloc");
-			return -EOPNOTSUPP;
-		}
-
 		if (copy_from_user(&range, (struct fstrim_range __user *)arg,
 		    sizeof(range)))
 			return -EFAULT;
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 1cd6994..c4bd0a6 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -4984,7 +4984,8 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
 
 	start = range->start >> sb->s_blocksize_bits;
 	end = start + (range->len >> sb->s_blocksize_bits) - 1;
-	minlen = range->minlen >> sb->s_blocksize_bits;
+	minlen = EXT4_NUM_B2C(EXT4_SB(sb),
+			      range->minlen >> sb->s_blocksize_bits);
 
 	if (unlikely(minlen > EXT4_CLUSTERS_PER_GROUP(sb)) ||
 	    unlikely(start >= max_blks))
@@ -5044,6 +5045,6 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
 		atomic_set(&EXT4_SB(sb)->s_last_trim_minblks, minlen);
 
 out:
-	range->len = trimmed * sb->s_blocksize;
+	range->len = EXT4_C2B(EXT4_SB(sb), trimmed) << sb->s_blocksize_bits;
 	return ret;
 }
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] ext4: enable FITRIM ioctl on bigalloc file system
  2012-07-03 19:10 [PATCH] ext4: enable FITRIM ioctl on bigalloc file system Lukas Czerner
@ 2012-08-21  9:48 ` Lukáš Czerner
  2012-09-12 15:31   ` Lukáš Czerner
  2012-09-12 16:59 ` Carlos Maiolino
  2012-09-27  2:28 ` Theodore Ts'o
  2 siblings, 1 reply; 6+ messages in thread
From: Lukáš Czerner @ 2012-08-21  9:48 UTC (permalink / raw)
  To: Lukas Czerner; +Cc: linux-ext4, tytso

On Tue, 3 Jul 2012, Lukas Czerner wrote:

> Date: Tue,  3 Jul 2012 21:10:42 +0200
> From: Lukas Czerner <lczerner@redhat.com>
> To: linux-ext4@vger.kernel.org
> Cc: tytso@mit.edu, Lukas Czerner <lczerner@redhat.com>
> Subject: [PATCH] ext4: enable FITRIM ioctl on bigalloc file system
> 
> With a minor tweaks regarding minimum extent size to discard and
> discarded bytes reporting the FITRIM can be enabled on bigalloc file
> system and it works without any problem.
> 
> This patch fixes minlen handling and discarded bytes reporting to
> take into consideration bigalloc enabled file systems and finally
> removes the restriction and allow FITRIM to be used on file system with
> bigalloc feature enabled.

any comments on this ?

Thanks!
-Lukas
> 
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> ---
>  fs/ext4/ioctl.c   |    7 -------
>  fs/ext4/mballoc.c |    5 +++--
>  2 files changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
> index e34deac..9d6e0bc 100644
> --- a/fs/ext4/ioctl.c
> +++ b/fs/ext4/ioctl.c
> @@ -420,13 +420,6 @@ resizefs_out:
>  		if (!blk_queue_discard(q))
>  			return -EOPNOTSUPP;
>  
> -		if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
> -			       EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
> -			ext4_msg(sb, KERN_ERR,
> -				 "FITRIM not supported with bigalloc");
> -			return -EOPNOTSUPP;
> -		}
> -
>  		if (copy_from_user(&range, (struct fstrim_range __user *)arg,
>  		    sizeof(range)))
>  			return -EFAULT;
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index 1cd6994..c4bd0a6 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -4984,7 +4984,8 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
>  
>  	start = range->start >> sb->s_blocksize_bits;
>  	end = start + (range->len >> sb->s_blocksize_bits) - 1;
> -	minlen = range->minlen >> sb->s_blocksize_bits;
> +	minlen = EXT4_NUM_B2C(EXT4_SB(sb),
> +			      range->minlen >> sb->s_blocksize_bits);
>  
>  	if (unlikely(minlen > EXT4_CLUSTERS_PER_GROUP(sb)) ||
>  	    unlikely(start >= max_blks))
> @@ -5044,6 +5045,6 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
>  		atomic_set(&EXT4_SB(sb)->s_last_trim_minblks, minlen);
>  
>  out:
> -	range->len = trimmed * sb->s_blocksize;
> +	range->len = EXT4_C2B(EXT4_SB(sb), trimmed) << sb->s_blocksize_bits;
>  	return ret;
>  }
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ext4: enable FITRIM ioctl on bigalloc file system
  2012-08-21  9:48 ` Lukáš Czerner
@ 2012-09-12 15:31   ` Lukáš Czerner
  2012-09-26 19:46     ` Lukáš Czerner
  0 siblings, 1 reply; 6+ messages in thread
From: Lukáš Czerner @ 2012-09-12 15:31 UTC (permalink / raw)
  To: Lukáš Czerner; +Cc: linux-ext4, tytso

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2822 bytes --]

On Tue, 21 Aug 2012, Lukáš Czerner wrote:

> Date: Tue, 21 Aug 2012 11:48:27 +0200 (CEST)
> From: Lukáš Czerner <lczerner@redhat.com>
> To: Lukas Czerner <lczerner@redhat.com>
> Cc: linux-ext4@vger.kernel.org, tytso@mit.edu
> Subject: Re: [PATCH] ext4: enable FITRIM ioctl on bigalloc file system
> 
> On Tue, 3 Jul 2012, Lukas Czerner wrote:
> 
> > Date: Tue,  3 Jul 2012 21:10:42 +0200
> > From: Lukas Czerner <lczerner@redhat.com>
> > To: linux-ext4@vger.kernel.org
> > Cc: tytso@mit.edu, Lukas Czerner <lczerner@redhat.com>
> > Subject: [PATCH] ext4: enable FITRIM ioctl on bigalloc file system
> > 
> > With a minor tweaks regarding minimum extent size to discard and
> > discarded bytes reporting the FITRIM can be enabled on bigalloc file
> > system and it works without any problem.
> > 
> > This patch fixes minlen handling and discarded bytes reporting to
> > take into consideration bigalloc enabled file systems and finally
> > removes the restriction and allow FITRIM to be used on file system with
> > bigalloc feature enabled.
> 
> any comments on this ?
> 
> Thanks!
> -Lukas

ping^2

> > 
> > Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> > ---
> >  fs/ext4/ioctl.c   |    7 -------
> >  fs/ext4/mballoc.c |    5 +++--
> >  2 files changed, 3 insertions(+), 9 deletions(-)
> > 
> > diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
> > index e34deac..9d6e0bc 100644
> > --- a/fs/ext4/ioctl.c
> > +++ b/fs/ext4/ioctl.c
> > @@ -420,13 +420,6 @@ resizefs_out:
> >  		if (!blk_queue_discard(q))
> >  			return -EOPNOTSUPP;
> >  
> > -		if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
> > -			       EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
> > -			ext4_msg(sb, KERN_ERR,
> > -				 "FITRIM not supported with bigalloc");
> > -			return -EOPNOTSUPP;
> > -		}
> > -
> >  		if (copy_from_user(&range, (struct fstrim_range __user *)arg,
> >  		    sizeof(range)))
> >  			return -EFAULT;
> > diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> > index 1cd6994..c4bd0a6 100644
> > --- a/fs/ext4/mballoc.c
> > +++ b/fs/ext4/mballoc.c
> > @@ -4984,7 +4984,8 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
> >  
> >  	start = range->start >> sb->s_blocksize_bits;
> >  	end = start + (range->len >> sb->s_blocksize_bits) - 1;
> > -	minlen = range->minlen >> sb->s_blocksize_bits;
> > +	minlen = EXT4_NUM_B2C(EXT4_SB(sb),
> > +			      range->minlen >> sb->s_blocksize_bits);
> >  
> >  	if (unlikely(minlen > EXT4_CLUSTERS_PER_GROUP(sb)) ||
> >  	    unlikely(start >= max_blks))
> > @@ -5044,6 +5045,6 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
> >  		atomic_set(&EXT4_SB(sb)->s_last_trim_minblks, minlen);
> >  
> >  out:
> > -	range->len = trimmed * sb->s_blocksize;
> > +	range->len = EXT4_C2B(EXT4_SB(sb), trimmed) << sb->s_blocksize_bits;
> >  	return ret;
> >  }
> > 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ext4: enable FITRIM ioctl on bigalloc file system
  2012-07-03 19:10 [PATCH] ext4: enable FITRIM ioctl on bigalloc file system Lukas Czerner
  2012-08-21  9:48 ` Lukáš Czerner
@ 2012-09-12 16:59 ` Carlos Maiolino
  2012-09-27  2:28 ` Theodore Ts'o
  2 siblings, 0 replies; 6+ messages in thread
From: Carlos Maiolino @ 2012-09-12 16:59 UTC (permalink / raw)
  To: linux-ext4

On Tue, Jul 03, 2012 at 09:10:42PM +0200, Lukas Czerner wrote:
> With a minor tweaks regarding minimum extent size to discard and
> discarded bytes reporting the FITRIM can be enabled on bigalloc file
> system and it works without any problem.
> 
> This patch fixes minlen handling and discarded bytes reporting to
> take into consideration bigalloc enabled file systems and finally
> removes the restriction and allow FITRIM to be used on file system with
> bigalloc feature enabled.
> 
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> ---
>  fs/ext4/ioctl.c   |    7 -------
>  fs/ext4/mballoc.c |    5 +++--
>  2 files changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
> index e34deac..9d6e0bc 100644
> --- a/fs/ext4/ioctl.c
> +++ b/fs/ext4/ioctl.c
> @@ -420,13 +420,6 @@ resizefs_out:
>  		if (!blk_queue_discard(q))
>  			return -EOPNOTSUPP;
>  
> -		if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
> -			       EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
> -			ext4_msg(sb, KERN_ERR,
> -				 "FITRIM not supported with bigalloc");
> -			return -EOPNOTSUPP;
> -		}
> -
>  		if (copy_from_user(&range, (struct fstrim_range __user *)arg,
>  		    sizeof(range)))
>  			return -EFAULT;
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index 1cd6994..c4bd0a6 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -4984,7 +4984,8 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
>  
>  	start = range->start >> sb->s_blocksize_bits;
>  	end = start + (range->len >> sb->s_blocksize_bits) - 1;
> -	minlen = range->minlen >> sb->s_blocksize_bits;
> +	minlen = EXT4_NUM_B2C(EXT4_SB(sb),
> +			      range->minlen >> sb->s_blocksize_bits);
>  
>  	if (unlikely(minlen > EXT4_CLUSTERS_PER_GROUP(sb)) ||
>  	    unlikely(start >= max_blks))
> @@ -5044,6 +5045,6 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
>  		atomic_set(&EXT4_SB(sb)->s_last_trim_minblks, minlen);
>  
>  out:
> -	range->len = trimmed * sb->s_blocksize;
> +	range->len = EXT4_C2B(EXT4_SB(sb), trimmed) << sb->s_blocksize_bits;
>  	return ret;
>  }

Looks good to me,

Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
-- 
--Carlos

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ext4: enable FITRIM ioctl on bigalloc file system
  2012-09-12 15:31   ` Lukáš Czerner
@ 2012-09-26 19:46     ` Lukáš Czerner
  0 siblings, 0 replies; 6+ messages in thread
From: Lukáš Czerner @ 2012-09-26 19:46 UTC (permalink / raw)
  To: Lukáš Czerner; +Cc: linux-ext4, tytso

[-- Attachment #1: Type: TEXT/PLAIN, Size: 3292 bytes --]

On Wed, 12 Sep 2012, Lukáš Czerner wrote:

> Date: Wed, 12 Sep 2012 11:31:46 -0400 (EDT)
> From: Lukáš Czerner <lczerner@redhat.com>
> To: Lukáš Czerner <lczerner@redhat.com>
> Cc: linux-ext4@vger.kernel.org, tytso@mit.edu
> Subject: Re: [PATCH] ext4: enable FITRIM ioctl on bigalloc file system
> 
> On Tue, 21 Aug 2012, Lukáš Czerner wrote:
> 
> > Date: Tue, 21 Aug 2012 11:48:27 +0200 (CEST)
> > From: Lukáš Czerner <lczerner@redhat.com>
> > To: Lukas Czerner <lczerner@redhat.com>
> > Cc: linux-ext4@vger.kernel.org, tytso@mit.edu
> > Subject: Re: [PATCH] ext4: enable FITRIM ioctl on bigalloc file system
> > 
> > On Tue, 3 Jul 2012, Lukas Czerner wrote:
> > 
> > > Date: Tue,  3 Jul 2012 21:10:42 +0200
> > > From: Lukas Czerner <lczerner@redhat.com>
> > > To: linux-ext4@vger.kernel.org
> > > Cc: tytso@mit.edu, Lukas Czerner <lczerner@redhat.com>
> > > Subject: [PATCH] ext4: enable FITRIM ioctl on bigalloc file system
> > > 
> > > With a minor tweaks regarding minimum extent size to discard and
> > > discarded bytes reporting the FITRIM can be enabled on bigalloc file
> > > system and it works without any problem.
> > > 
> > > This patch fixes minlen handling and discarded bytes reporting to
> > > take into consideration bigalloc enabled file systems and finally
> > > removes the restriction and allow FITRIM to be used on file system with
> > > bigalloc feature enabled.
> > 
> > any comments on this ?
> > 
> > Thanks!
> > -Lukas
> 
> ping^2

ping^3

> 
> > > 
> > > Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> > > ---
> > >  fs/ext4/ioctl.c   |    7 -------
> > >  fs/ext4/mballoc.c |    5 +++--
> > >  2 files changed, 3 insertions(+), 9 deletions(-)
> > > 
> > > diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
> > > index e34deac..9d6e0bc 100644
> > > --- a/fs/ext4/ioctl.c
> > > +++ b/fs/ext4/ioctl.c
> > > @@ -420,13 +420,6 @@ resizefs_out:
> > >  		if (!blk_queue_discard(q))
> > >  			return -EOPNOTSUPP;
> > >  
> > > -		if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
> > > -			       EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
> > > -			ext4_msg(sb, KERN_ERR,
> > > -				 "FITRIM not supported with bigalloc");
> > > -			return -EOPNOTSUPP;
> > > -		}
> > > -
> > >  		if (copy_from_user(&range, (struct fstrim_range __user *)arg,
> > >  		    sizeof(range)))
> > >  			return -EFAULT;
> > > diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> > > index 1cd6994..c4bd0a6 100644
> > > --- a/fs/ext4/mballoc.c
> > > +++ b/fs/ext4/mballoc.c
> > > @@ -4984,7 +4984,8 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
> > >  
> > >  	start = range->start >> sb->s_blocksize_bits;
> > >  	end = start + (range->len >> sb->s_blocksize_bits) - 1;
> > > -	minlen = range->minlen >> sb->s_blocksize_bits;
> > > +	minlen = EXT4_NUM_B2C(EXT4_SB(sb),
> > > +			      range->minlen >> sb->s_blocksize_bits);
> > >  
> > >  	if (unlikely(minlen > EXT4_CLUSTERS_PER_GROUP(sb)) ||
> > >  	    unlikely(start >= max_blks))
> > > @@ -5044,6 +5045,6 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
> > >  		atomic_set(&EXT4_SB(sb)->s_last_trim_minblks, minlen);
> > >  
> > >  out:
> > > -	range->len = trimmed * sb->s_blocksize;
> > > +	range->len = EXT4_C2B(EXT4_SB(sb), trimmed) << sb->s_blocksize_bits;
> > >  	return ret;
> > >  }
> > > 
> > 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ext4: enable FITRIM ioctl on bigalloc file system
  2012-07-03 19:10 [PATCH] ext4: enable FITRIM ioctl on bigalloc file system Lukas Czerner
  2012-08-21  9:48 ` Lukáš Czerner
  2012-09-12 16:59 ` Carlos Maiolino
@ 2012-09-27  2:28 ` Theodore Ts'o
  2 siblings, 0 replies; 6+ messages in thread
From: Theodore Ts'o @ 2012-09-27  2:28 UTC (permalink / raw)
  To: Lukas Czerner; +Cc: linux-ext4

On Tue, Jul 03, 2012 at 09:10:42PM +0200, Lukas Czerner wrote:
> With a minor tweaks regarding minimum extent size to discard and
> discarded bytes reporting the FITRIM can be enabled on bigalloc file
> system and it works without any problem.
> 
> This patch fixes minlen handling and discarded bytes reporting to
> take into consideration bigalloc enabled file systems and finally
> removes the restriction and allow FITRIM to be used on file system with
> bigalloc feature enabled.
> 
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>

Applied, thanks!

						- Ted

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-09-27  2:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-03 19:10 [PATCH] ext4: enable FITRIM ioctl on bigalloc file system Lukas Czerner
2012-08-21  9:48 ` Lukáš Czerner
2012-09-12 15:31   ` Lukáš Czerner
2012-09-26 19:46     ` Lukáš Czerner
2012-09-12 16:59 ` Carlos Maiolino
2012-09-27  2:28 ` Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).