This patchset is going to remove some redunant checking
of inline data flag and also going to avoid some unnecessary
cpu waste when doing inline stuff.
Note:
Sorry for sending previous four patches in separate, let
drop them and make them in this thread for better review.
Shawn Lin (8):
f2fs: check inline flag ahead for f2fs_write_inline_data
f2fs: remove checing inline data flag for f2fs_write_data_page
f2fs: check inline flag ahead for f2fs_read_inline_data
f2fs: remove redundant checking of inline data flag
f2fs: f2fs: check inline flag ahead for f2fs_inline_data_fiemap
f2fs: remove checing inline data flag for f2fs_fiemap
f2fs: remove unnecessary inline checking for f2fs_convert_inline_inode
f2fs: check inline flag ahead for get_dnode_of_data
fs/f2fs/data.c | 17 +++++++----------
fs/f2fs/inline.c | 27 ++++++++++-----------------
fs/f2fs/node.c | 12 +++++-------
3 files changed, 22 insertions(+), 34 deletions(-)
--
2.3.7
No matter inline data flag is set or not, current code is
going to new a dnode. But actually we can avoid it by puting
the check of inline data flag in advance to save this cpu cycle.
Signed-off-by: Shawn Lin <[email protected]>
---
fs/f2fs/inline.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 358214e..0926eab 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -195,16 +195,14 @@ int f2fs_write_inline_data(struct inode *inode, struct page *page)
struct dnode_of_data dn;
int err;
+ if (!f2fs_has_inline_data(inode))
+ return -EAGAIN;
+
set_new_dnode(&dn, inode, NULL, NULL, 0);
err = get_dnode_of_data(&dn, 0, LOOKUP_NODE);
if (err)
return err;
- if (!f2fs_has_inline_data(inode)) {
- f2fs_put_dnode(&dn);
- return -EAGAIN;
- }
-
f2fs_bug_on(F2FS_I_SB(inode), page->index);
f2fs_wait_on_page_writeback(dn.inode_page, NODE, true);
--
2.3.7
Remove the f2fs_has_inline_data for f2fs_write_data_page,
and let f2fs_write_inline_data take over gatekeeper of
checking inline data flag.
Signed-off-by: Shawn Lin <[email protected]>
---
fs/f2fs/data.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index e5c762b..38c834e 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1192,8 +1192,7 @@ write:
err = -EAGAIN;
f2fs_lock_op(sbi);
- if (f2fs_has_inline_data(inode))
- err = f2fs_write_inline_data(inode, page);
+ err = f2fs_write_inline_data(inode, page);
if (err == -EAGAIN)
err = do_write_data_page(&fio);
f2fs_unlock_op(sbi);
--
2.3.7
No matter inline data flag is set or not, get_node_page is
going work now. But actually we can avoid it by puting the
check of inline data flag in advance to save this cpu cycle.
Signed-off-by: Shawn Lin <[email protected]>
---
fs/f2fs/inline.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 0926eab..69a4806 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -81,17 +81,15 @@ int f2fs_read_inline_data(struct inode *inode, struct page *page)
{
struct page *ipage;
+ if (!f2fs_has_inline_data(inode))
+ return -EAGAIN;
+
ipage = get_node_page(F2FS_I_SB(inode), inode->i_ino);
if (IS_ERR(ipage)) {
unlock_page(page);
return PTR_ERR(ipage);
}
- if (!f2fs_has_inline_data(inode)) {
- f2fs_put_page(ipage, 1);
- return -EAGAIN;
- }
-
if (page->index)
zero_user_segment(page, 0, PAGE_CACHE_SIZE);
else
--
2.3.7
Remove the f2fs_has_inline_data for f2fs_read_data_page,
and let f2fs_read_inline_data take over gatekeeper of
checking inline data flag.
Signed-off-by: Shawn Lin <[email protected]>
---
fs/f2fs/data.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 38c834e..d60d5f0 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1047,9 +1047,9 @@ static int f2fs_read_data_page(struct file *file, struct page *page)
trace_f2fs_readpage(page, DATA);
- /* If the file has inline data, try to read it directly */
- if (f2fs_has_inline_data(inode))
- ret = f2fs_read_inline_data(inode, page);
+ /* Firstly, let's try to read inline data directly */
+ ret = f2fs_read_inline_data(inode, page);
+
if (ret == -EAGAIN)
ret = f2fs_mpage_readpages(page->mapping, NULL, page, 1);
return ret;
--
2.3.7
Remove the f2fs_has_inline_data for f2fs_fiemap, and let
f2fs_inline_data_fiemap take over gatekeeper of checking
inline data flag.
Signed-off-by: Shawn Lin <[email protected]>
---
fs/f2fs/data.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index d60d5f0..c88d79c 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -817,11 +817,9 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
if (ret)
return ret;
- if (f2fs_has_inline_data(inode)) {
- ret = f2fs_inline_data_fiemap(inode, fieinfo, start, len);
- if (ret != -EAGAIN)
- return ret;
- }
+ ret = f2fs_inline_data_fiemap(inode, fieinfo, start, len);
+ if (ret != -EAGAIN)
+ return ret;
inode_lock(inode);
--
2.3.7
No matter inline data flag is set or not, get_node_page is
going work now. But actually we can avoid it by puting the
check of inline data flag in advance to save this cpu cycle.
Signed-off-by: Shawn Lin <[email protected]>
---
fs/f2fs/inline.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 69a4806..394feee 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -566,15 +566,13 @@ int f2fs_inline_data_fiemap(struct inode *inode,
struct page *ipage;
int err = 0;
+ if (!f2fs_has_inline_data(inode))
+ return -EAGAIN;
+
ipage = get_node_page(F2FS_I_SB(inode), inode->i_ino);
if (IS_ERR(ipage))
return PTR_ERR(ipage);
- if (!f2fs_has_inline_data(inode)) {
- err = -EAGAIN;
- goto out;
- }
-
ilen = min_t(size_t, MAX_INLINE_DATA, i_size_read(inode));
if (start >= ilen)
goto out;
--
2.3.7
If failing to check inline data flag for f2fs_convert_inline_inode,
it will return 0. So we don't need to check it twice before we are
going to do f2fs_convert_inline_page.
Signed-off-by: Shawn Lin <[email protected]>
---
fs/f2fs/inline.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 394feee..76e096a 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -173,8 +173,7 @@ int f2fs_convert_inline_inode(struct inode *inode)
set_new_dnode(&dn, inode, ipage, ipage, 0);
- if (f2fs_has_inline_data(inode))
- err = f2fs_convert_inline_page(&dn, page);
+ err = f2fs_convert_inline_page(&dn, page);
f2fs_put_dnode(&dn);
out:
--
2.3.7
Check inline data flag ahead, so we can save some
cpu cycle.
Signed-off-by: Shawn Lin <[email protected]>
---
fs/f2fs/node.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 771166d..69467bd 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -534,6 +534,11 @@ int get_dnode_of_data(struct dnode_of_data *dn, pgoff_t index, int mode)
int err = 0;
level = get_node_path(dn->inode, index, offset, noffset);
+ /* if inline_data is set, should not report any block indices */
+ if (f2fs_has_inline_data(dn->inode) && index) {
+ err = -ENOENT;
+ goto release_out;
+ }
nids[0] = dn->inode->i_ino;
npage[0] = dn->inode_page;
@@ -544,13 +549,6 @@ int get_dnode_of_data(struct dnode_of_data *dn, pgoff_t index, int mode)
return PTR_ERR(npage[0]);
}
- /* if inline_data is set, should not report any block indices */
- if (f2fs_has_inline_data(dn->inode) && index) {
- err = -ENOENT;
- f2fs_put_page(npage[0], 1);
- goto release_out;
- }
-
parent = npage[0];
if (level != 0)
nids[1] = get_nid(parent, offset[0], true);
--
2.3.7
Hi Shawn,
> -----Original Message-----
> From: Shawn Lin [mailto:[email protected]]
> Sent: Friday, March 11, 2016 11:28 AM
> To: Jaegeuk Kim
> Cc: Shawn Lin; [email protected]; [email protected]
> Subject: [f2fs-dev] [PATCH 0/8] some cleanup of inline flag checking
>
>
> This patchset is going to remove some redunant checking
> of inline data flag and also going to avoid some unnecessary
> cpu waste when doing inline stuff.
When we are accessing inline inode, inline inode conversion can happen
concurrently, we should check inline flag again under inode page's lock
to avoid accessing the wrong inline data which may have been converted.
Thanks,
>
> Note:
> Sorry for sending previous four patches in separate, let
> drop them and make them in this thread for better review.
>
>
>
> Shawn Lin (8):
> f2fs: check inline flag ahead for f2fs_write_inline_data
> f2fs: remove checing inline data flag for f2fs_write_data_page
> f2fs: check inline flag ahead for f2fs_read_inline_data
> f2fs: remove redundant checking of inline data flag
> f2fs: f2fs: check inline flag ahead for f2fs_inline_data_fiemap
> f2fs: remove checing inline data flag for f2fs_fiemap
> f2fs: remove unnecessary inline checking for f2fs_convert_inline_inode
> f2fs: check inline flag ahead for get_dnode_of_data
>
> fs/f2fs/data.c | 17 +++++++----------
> fs/f2fs/inline.c | 27 ++++++++++-----------------
> fs/f2fs/node.c | 12 +++++-------
> 3 files changed, 22 insertions(+), 34 deletions(-)
>
> --
> 2.3.7
>
>
>
> ------------------------------------------------------------------------------
> Transform Data into Opportunity.
> Accelerate data analysis in your applications with
> Intel Data Analytics Acceleration Library.
> Click to learn more.
> http://pubads.g.doubleclick.net/gampad/clk?id=278785111&iu=/4140
> _______________________________________________
> Linux-f2fs-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Hi Chao Yu,
On 2016/3/11 13:29, Chao Yu wrote:
> Hi Shawn,
>
>> -----Original Message-----
>> From: Shawn Lin [mailto:[email protected]]
>> Sent: Friday, March 11, 2016 11:28 AM
>> To: Jaegeuk Kim
>> Cc: Shawn Lin; [email protected]; [email protected]
>> Subject: [f2fs-dev] [PATCH 0/8] some cleanup of inline flag checking
>>
>>
>> This patchset is going to remove some redunant checking
>> of inline data flag and also going to avoid some unnecessary
>> cpu waste when doing inline stuff.
>
> When we are accessing inline inode, inline inode conversion can happen
> concurrently, we should check inline flag again under inode page's lock
> to avoid accessing the wrong inline data which may have been converted.
>
that sounds reasonable at first glance, and it more seems like that
mopst part of this patchset is just puting the checking in the right way.
If we need to check the inline inode under the protection of inode
page's lock, it means any callers who calling inline API stuff is
wasting time on checing the flag outside the API, right?
So we can just remove the redundant checking of the caller, but not
change the behaviour of checing inline flag under page's lock?
Thanks for catching it.
> Thanks,
>
>>
>> Note:
>> Sorry for sending previous four patches in separate, let
>> drop them and make them in this thread for better review.
>>
>>
>>
>> Shawn Lin (8):
>> f2fs: check inline flag ahead for f2fs_write_inline_data
>> f2fs: remove checing inline data flag for f2fs_write_data_page
>> f2fs: check inline flag ahead for f2fs_read_inline_data
>> f2fs: remove redundant checking of inline data flag
>> f2fs: f2fs: check inline flag ahead for f2fs_inline_data_fiemap
>> f2fs: remove checing inline data flag for f2fs_fiemap
>> f2fs: remove unnecessary inline checking for f2fs_convert_inline_inode
>> f2fs: check inline flag ahead for get_dnode_of_data
>>
>> fs/f2fs/data.c | 17 +++++++----------
>> fs/f2fs/inline.c | 27 ++++++++++-----------------
>> fs/f2fs/node.c | 12 +++++-------
>> 3 files changed, 22 insertions(+), 34 deletions(-)
>>
>> --
>> 2.3.7
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Transform Data into Opportunity.
>> Accelerate data analysis in your applications with
>> Intel Data Analytics Acceleration Library.
>> Click to learn more.
>> http://pubads.g.doubleclick.net/gampad/clk?id=278785111&iu=/4140
>> _______________________________________________
>> Linux-f2fs-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>
>
> ------------------------------------------------------------------------------
> Transform Data into Opportunity.
> Accelerate data analysis in your applications with
> Intel Data Analytics Acceleration Library.
> Click to learn more.
> http://pubads.g.doubleclick.net/gampad/clk?id=278785111&iu=/4140
> _______________________________________________
> Linux-f2fs-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>
Hi Shawn,
> -----Original Message-----
> From: Shawn Lin [mailto:[email protected]]
> Sent: Friday, March 11, 2016 2:34 PM
> To: Chao Yu; 'Shawn Lin'; 'Jaegeuk Kim'
> Cc: [email protected]; [email protected];
> [email protected]
> Subject: Re: [f2fs-dev] [PATCH 0/8] some cleanup of inline flag checking
>
> Hi Chao Yu,
>
> On 2016/3/11 13:29, Chao Yu wrote:
> > Hi Shawn,
> >
> >> -----Original Message-----
> >> From: Shawn Lin [mailto:[email protected]]
> >> Sent: Friday, March 11, 2016 11:28 AM
> >> To: Jaegeuk Kim
> >> Cc: Shawn Lin; [email protected]; [email protected]
> >> Subject: [f2fs-dev] [PATCH 0/8] some cleanup of inline flag checking
> >>
> >>
> >> This patchset is going to remove some redunant checking
> >> of inline data flag and also going to avoid some unnecessary
> >> cpu waste when doing inline stuff.
> >
> > When we are accessing inline inode, inline inode conversion can happen
> > concurrently, we should check inline flag again under inode page's lock
> > to avoid accessing the wrong inline data which may have been converted.
> >
>
> that sounds reasonable at first glance, and it more seems like that
> mopst part of this patchset is just puting the checking in the right way.
>
> If we need to check the inline inode under the protection of inode
> page's lock, it means any callers who calling inline API stuff is
> wasting time on checing the flag outside the API, right?
As you know, inline conversion was designed as one-way operation, which means
inline inode can only be converted to normal inode, but can not be converted
in the opposite way. So here, with original design, it is OK to handle inode
as regular one if we detect that it is a non-inline inode, since it won't be
converted to inline one, otherwise, we should take inode page's lock and check
the flag again.
Thanks,
>
> So we can just remove the redundant checking of the caller, but not
> change the behaviour of checing inline flag under page's lock?
>
> Thanks for catching it.
>
> > Thanks,
> >
> >>
> >> Note:
> >> Sorry for sending previous four patches in separate, let
> >> drop them and make them in this thread for better review.
> >>
> >>
> >>
> >> Shawn Lin (8):
> >> f2fs: check inline flag ahead for f2fs_write_inline_data
> >> f2fs: remove checing inline data flag for f2fs_write_data_page
> >> f2fs: check inline flag ahead for f2fs_read_inline_data
> >> f2fs: remove redundant checking of inline data flag
> >> f2fs: f2fs: check inline flag ahead for f2fs_inline_data_fiemap
> >> f2fs: remove checing inline data flag for f2fs_fiemap
> >> f2fs: remove unnecessary inline checking for f2fs_convert_inline_inode
> >> f2fs: check inline flag ahead for get_dnode_of_data
> >>
> >> fs/f2fs/data.c | 17 +++++++----------
> >> fs/f2fs/inline.c | 27 ++++++++++-----------------
> >> fs/f2fs/node.c | 12 +++++-------
> >> 3 files changed, 22 insertions(+), 34 deletions(-)
> >>
> >> --
> >> 2.3.7
> >>
> >>
> >>
> >> ------------------------------------------------------------------------------
> >> Transform Data into Opportunity.
> >> Accelerate data analysis in your applications with
> >> Intel Data Analytics Acceleration Library.
> >> Click to learn more.
> >> http://pubads.g.doubleclick.net/gampad/clk?id=278785111&iu=/4140
> >> _______________________________________________
> >> Linux-f2fs-devel mailing list
> >> [email protected]
> >> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
> >
> >
> > ------------------------------------------------------------------------------
> > Transform Data into Opportunity.
> > Accelerate data analysis in your applications with
> > Intel Data Analytics Acceleration Library.
> > Click to learn more.
> > http://pubads.g.doubleclick.net/gampad/clk?id=278785111&iu=/4140
> > _______________________________________________
> > Linux-f2fs-devel mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
> >