diff mbox

[03/12,v2] shmem: pass LLONG_MAX to shmem_truncate_range

Message ID 1342185555-21146-3-git-send-email-lczerner@redhat.com
State Superseded, archived
Headers show

Commit Message

Lukas Czerner July 13, 2012, 1:19 p.m. UTC
Currently we're passing -1 to shmem_truncate_range which can then call
truncate_inode_pages_range() which is actually really confusing since the
argument is signed so we do not get "huge" number as one would expect,
but rather just -1. To make things clearer and easier for
truncate_inode_pages_range() just pass LLONG_MAX since it is actually what
was intended anyway.

It also makes thing easier for allowing truncate_inode_pages_range() to
handle non page aligned regions. Moreover letting the lend argument to
be negative might actually hide some bugs.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
---
 mm/shmem.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Comments

Eric Sandeen July 18, 2012, 7:54 p.m. UTC | #1
On 7/13/12 8:19 AM, Lukas Czerner wrote:
> Currently we're passing -1 to shmem_truncate_range which can then call
> truncate_inode_pages_range() which is actually really confusing since the
> argument is signed so we do not get "huge" number as one would expect,
> but rather just -1. To make things clearer and easier for
> truncate_inode_pages_range() just pass LLONG_MAX since it is actually what
> was intended anyway.
> 
> It also makes thing easier for allowing truncate_inode_pages_range() to
> handle non page aligned regions. Moreover letting the lend argument to
> be negative might actually hide some bugs.
> 
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> Cc: Hugh Dickins <hughd@google.com>
> ---
>  mm/shmem.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 4ce02e0..3199733 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -2961,7 +2961,8 @@ void shmem_unlock_mapping(struct address_space *mapping)
>  
>  void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend)
>  {
> -	truncate_inode_pages_range(inode->i_mapping, lstart, lend);
> +	truncate_inode_pages_range(inode->i_mapping, lstart,
> +				   lend == -1 ? LLONG_MAX : last);

Where'd "last" come from?  That won't build; should be "lend" right?

(code only goes this way if !CONFIG_SHMEM so you might have missed it)

-Eric

>  }
>  EXPORT_SYMBOL_GPL(shmem_truncate_range);
>  
> 


--
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 July 19, 2012, 6:40 a.m. UTC | #2
On Wed, 18 Jul 2012, Eric Sandeen wrote:

> Date: Wed, 18 Jul 2012 14:54:04 -0500
> From: Eric Sandeen <sandeen@redhat.com>
> To: Lukas Czerner <lczerner@redhat.com>
> Cc: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu,
>     achender@linux.vnet.ibm.com, Hugh Dickins <hughd@google.com>
> Subject: Re: [PATCH 03/12 v2] shmem: pass LLONG_MAX to shmem_truncate_range
> 
> On 7/13/12 8:19 AM, Lukas Czerner wrote:
> > Currently we're passing -1 to shmem_truncate_range which can then call
> > truncate_inode_pages_range() which is actually really confusing since the
> > argument is signed so we do not get "huge" number as one would expect,
> > but rather just -1. To make things clearer and easier for
> > truncate_inode_pages_range() just pass LLONG_MAX since it is actually what
> > was intended anyway.
> > 
> > It also makes thing easier for allowing truncate_inode_pages_range() to
> > handle non page aligned regions. Moreover letting the lend argument to
> > be negative might actually hide some bugs.
> > 
> > Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> > Cc: Hugh Dickins <hughd@google.com>
> > ---
> >  mm/shmem.c |    3 ++-
> >  1 files changed, 2 insertions(+), 1 deletions(-)
> > 
> > diff --git a/mm/shmem.c b/mm/shmem.c
> > index 4ce02e0..3199733 100644
> > --- a/mm/shmem.c
> > +++ b/mm/shmem.c
> > @@ -2961,7 +2961,8 @@ void shmem_unlock_mapping(struct address_space *mapping)
> >  
> >  void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend)
> >  {
> > -	truncate_inode_pages_range(inode->i_mapping, lstart, lend);
> > +	truncate_inode_pages_range(inode->i_mapping, lstart,
> > +				   lend == -1 ? LLONG_MAX : last);
> 
> Where'd "last" come from?  That won't build; should be "lend" right?
> 
> (code only goes this way if !CONFIG_SHMEM so you might have missed it)

Ah, I definitely missed it. Thanks Eric. But from the discussion
with the Hugh, we're going to do this a bit differently anyway.

-Lukas

> 
> -Eric
> 
> >  }
> >  EXPORT_SYMBOL_GPL(shmem_truncate_range);
> >  
> > 
> 
> 
> 
--
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/mm/shmem.c b/mm/shmem.c
index 4ce02e0..3199733 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2961,7 +2961,8 @@  void shmem_unlock_mapping(struct address_space *mapping)
 
 void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend)
 {
-	truncate_inode_pages_range(inode->i_mapping, lstart, lend);
+	truncate_inode_pages_range(inode->i_mapping, lstart,
+				   lend == -1 ? LLONG_MAX : last);
 }
 EXPORT_SYMBOL_GPL(shmem_truncate_range);