Re: [f2fs-dev] [PATCH 2/3] f2fs: use i_size_read to get i_size

2015-12-29 Thread Jaegeuk Kim
Hi Chao,

On Tue, Dec 29, 2015 at 05:18:19PM +0800, Chao Yu wrote:
> Hi Jaegeuk,
> 
> > -Original Message-
> > From: Jaegeuk Kim [mailto:jaeg...@kernel.org]
> > Sent: Tuesday, December 29, 2015 7:32 AM
> > To: linux-kernel@vger.kernel.org; linux-fsde...@vger.kernel.org;
> > linux-f2fs-de...@lists.sourceforge.net
> > Cc: Jaegeuk Kim
> > Subject: [f2fs-dev] [PATCH 2/3] f2fs: use i_size_read to get i_size
> > 
> > We need to use i_size_read() to get inode->i_size.
> 
> All callers of f2fs_write_failed should be protected by i_mutex, so no
> one can change i_size, do we really need to use i_size_read here?

Just to follow convention and avoid any confusion later.
We also use i_size_read/write consistently across whole areas.

Thanks,

> 
> Thanks,
> 
> > 
> > Signed-off-by: Jaegeuk Kim 
> > ---
> >  fs/f2fs/data.c | 7 ---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> > 
> > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> > index f34f42a..8a89810 100644
> > --- a/fs/f2fs/data.c
> > +++ b/fs/f2fs/data.c
> > @@ -1386,10 +1386,11 @@ skip_write:
> >  static void f2fs_write_failed(struct address_space *mapping, loff_t to)
> >  {
> > struct inode *inode = mapping->host;
> > +   loff_t i_size = i_size_read(inode);
> > 
> > -   if (to > inode->i_size) {
> > -   truncate_pagecache(inode, inode->i_size);
> > -   truncate_blocks(inode, inode->i_size, true);
> > +   if (to > i_size) {
> > +   truncate_pagecache(inode, i_size);
> > +   truncate_blocks(inode, i_size, true);
> > }
> >  }
> > 
> > --
> > 2.5.4 (Apple Git-61)
> > 
> > 
> > --
> > ___
> > Linux-f2fs-devel mailing list
> > linux-f2fs-de...@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [f2fs-dev] [PATCH 2/3] f2fs: use i_size_read to get i_size

2015-12-29 Thread Chao Yu
Hi Jaegeuk,

> -Original Message-
> From: Jaegeuk Kim [mailto:jaeg...@kernel.org]
> Sent: Tuesday, December 29, 2015 7:32 AM
> To: linux-kernel@vger.kernel.org; linux-fsde...@vger.kernel.org;
> linux-f2fs-de...@lists.sourceforge.net
> Cc: Jaegeuk Kim
> Subject: [f2fs-dev] [PATCH 2/3] f2fs: use i_size_read to get i_size
> 
> We need to use i_size_read() to get inode->i_size.

All callers of f2fs_write_failed should be protected by i_mutex, so no
one can change i_size, do we really need to use i_size_read here?

Thanks,

> 
> Signed-off-by: Jaegeuk Kim 
> ---
>  fs/f2fs/data.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index f34f42a..8a89810 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -1386,10 +1386,11 @@ skip_write:
>  static void f2fs_write_failed(struct address_space *mapping, loff_t to)
>  {
>   struct inode *inode = mapping->host;
> + loff_t i_size = i_size_read(inode);
> 
> - if (to > inode->i_size) {
> - truncate_pagecache(inode, inode->i_size);
> - truncate_blocks(inode, inode->i_size, true);
> + if (to > i_size) {
> + truncate_pagecache(inode, i_size);
> + truncate_blocks(inode, i_size, true);
>   }
>  }
> 
> --
> 2.5.4 (Apple Git-61)
> 
> 
> --
> ___
> Linux-f2fs-devel mailing list
> linux-f2fs-de...@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/