linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Fan Li <fanofcode.li@samsung.com>
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [PATCH 1/3] f2fs: avoid calling i_size_read when it's unnecessary
Date: Wed, 30 Dec 2015 10:27:39 -0800	[thread overview]
Message-ID: <20151230182739.GC28564@jaegeuk.local> (raw)
In-Reply-To: <000c01d142df$24fdd450$6ef97cf0$@samsung.com>

Hi Fan,

On Wed, Dec 30, 2015 at 04:49:56PM +0800, Fan Li wrote:
> i_size_read does more than reading a value, it's best that we use it
> only when we need it.
> 
> Signed-off-by: Fan li <fanofcode.li@samsung.com>
> ---
>  fs/f2fs/data.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index d67c599..a9a4d89 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -780,7 +780,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
>  {
>  	struct buffer_head map_bh;
>  	sector_t start_blk, last_blk;
> -	loff_t isize = i_size_read(inode);
> +	loff_t isize;
>  	u64 logical = 0, phys = 0, size = 0;
>  	u32 flags = 0;
>  	int ret = 0;
> @@ -795,6 +795,8 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
>  			return ret;
>  	}
>  
> +	isize = i_size_read(inode);

It seems that we need to get isize after grabbing i_mutex below in order to
avoid data race.

Thanks,

> +
>  	mutex_lock(&inode->i_mutex);
>  	if (start >= isize)
>  		goto out;
> -- 
> 1.7.9.5
> 

------------------------------------------------------------------------------

  reply	other threads:[~2015-12-30 18:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-30  8:49 [PATCH 1/3] f2fs: avoid calling i_size_read when it's unnecessary Fan Li
2015-12-30 18:27 ` Jaegeuk Kim [this message]
2015-12-31  2:53   ` Fan Li
2016-01-01  3:07     ` Jaegeuk Kim
2016-01-04  6:13       ` Fan Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151230182739.GC28564@jaegeuk.local \
    --to=jaegeuk@kernel.org \
    --cc=fanofcode.li@samsung.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).