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: Thu, 31 Dec 2015 19:07:45 -0800 [thread overview]
Message-ID: <20160101030745.GA6673@jaegeuk.local> (raw)
In-Reply-To: <001801d14376$8592b000$90b81000$@samsung.com>
Hi Fan,
On Thu, Dec 31, 2015 at 10:53:32AM +0800, Fan Li wrote:
>
>
> > -----Original Message-----
> > From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> > Sent: Thursday, December 31, 2015 2:28 AM
> > To: Fan Li
> > Cc: linux-f2fs-devel@lists.sourceforge.net
> > Subject: Re: [f2fs-dev] [PATCH 1/3] f2fs: avoid calling i_size_read when it's unnecessary
> >
> > 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.
>
> See if I got this right, isize should remain unchanged during the entire procedure, so we need
> to add i_mutex upon it, and since there is already a i_mutex, we can get inode->i_size
> directly instead of calling i_read_size.
> Is that right?
Right, but I prefer to use i_size_read consistently.
TOH, I'm not convincing why you're treating this as a so costly operation.
Thanks,
>
> >
> > Thanks,
> >
> > > +
> > > mutex_lock(&inode->i_mutex);
> > > if (start >= isize)
> > > goto out;
> > > --
> > > 1.7.9.5
> > >
------------------------------------------------------------------------------
next prev parent reply other threads:[~2016-01-01 3:07 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
2015-12-31 2:53 ` Fan Li
2016-01-01 3:07 ` Jaegeuk Kim [this message]
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=20160101030745.GA6673@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).