linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/3] f2fs: introduce f2fs_cache_node_page() to add page into node_inode cache
@ 2013-12-05  1:54 Chao Yu
  2013-12-05  2:10 ` Chao Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Chao Yu @ 2013-12-05  1:54 UTC (permalink / raw)
  To: ???; +Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel

This patch introduces f2fs_cache_node_page(), in this function, page which is
readed ahead will be copy to node_inode's mapping cache.
It will avoid rereading these node pages.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
---
 fs/f2fs/node.c |   30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 099f06f..5e2588f 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1600,6 +1600,34 @@ static int ra_sum_pages(struct f2fs_sb_info *sbi, struct list_head *pages,
 	return 0;
 }
 
+/*
+ * f2fs_cache_node_page() copy updated page data to node_inode cache page.
+ */
+void f2fs_cache_node_page(struct f2fs_sb_info *sbi, struct page *page,
+						nid_t nid)
+{
+	struct address_space *mapping = sbi->node_inode->i_mapping;
+	struct page *npage;
+
+	npage = find_get_page(mapping, nid);
+	if (npage && PageUptodate(npage)) {
+		f2fs_put_page(npage, 0);
+		return;
+	}
+	f2fs_put_page(npage, 0);
+
+	npage = grab_cache_page(mapping, nid);
+	if (!npage)
+		return;
+
+	memcpy(page_address(npage), page_address(page), PAGE_CACHE_SIZE);
+
+	SetPageUptodate(npage);
+	f2fs_put_page(npage, 1);
+
+	return;
+}
+
 int restore_node_summary(struct f2fs_sb_info *sbi,
 			unsigned int segno, struct f2fs_summary_block *sum)
 {
@@ -1633,6 +1661,8 @@ int restore_node_summary(struct f2fs_sb_info *sbi,
 				sum_entry->version = 0;
 				sum_entry->ofs_in_node = 0;
 				sum_entry++;
+				f2fs_cache_node_page(sbi, page,
+					le32_to_cpu(rn->footer.nid));
 			} else {
 				err = -EIO;
 			}
-- 
1.7.9.5


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 3/3] f2fs: introduce f2fs_cache_node_page() to add page into node_inode cache
  2013-12-05  1:54 [PATCH 3/3] f2fs: introduce f2fs_cache_node_page() to add page into node_inode cache Chao Yu
@ 2013-12-05  2:10 ` Chao Yu
  2013-12-06  1:42   ` Jaegeuk Kim
  0 siblings, 1 reply; 4+ messages in thread
From: Chao Yu @ 2013-12-05  2:10 UTC (permalink / raw)
  To: '???'; +Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel

> -----Original Message-----
> From: Chao Yu [mailto:chao2.yu@samsung.com]
> Sent: Thursday, December 05, 2013 9:55 AM
> To: ???
> Cc: linux-fsdevel@vger.kernel.org; linux-kernel@vger.kernel.org; linux-f2fs-devel@lists.sourceforge.net
> Subject: [f2fs-dev] [PATCH 3/3] f2fs: introduce f2fs_cache_node_page() to add page into node_inode cache
> 
> This patch introduces f2fs_cache_node_page(), in this function, page which is
> readed ahead will be copy to node_inode's mapping cache.
> It will avoid rereading these node pages.
> 
> Signed-off-by: Chao Yu <chao2.yu@samsung.com>

Suggested-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>

I miss that, my mistake.

> ---
>  fs/f2fs/node.c |   30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> index 099f06f..5e2588f 100644
> --- a/fs/f2fs/node.c
> +++ b/fs/f2fs/node.c
> @@ -1600,6 +1600,34 @@ static int ra_sum_pages(struct f2fs_sb_info *sbi, struct list_head *pages,
>  	return 0;
>  }
> 
> +/*
> + * f2fs_cache_node_page() copy updated page data to node_inode cache page.
> + */
> +void f2fs_cache_node_page(struct f2fs_sb_info *sbi, struct page *page,
> +						nid_t nid)
> +{
> +	struct address_space *mapping = sbi->node_inode->i_mapping;
> +	struct page *npage;
> +
> +	npage = find_get_page(mapping, nid);
> +	if (npage && PageUptodate(npage)) {
> +		f2fs_put_page(npage, 0);
> +		return;
> +	}
> +	f2fs_put_page(npage, 0);
> +
> +	npage = grab_cache_page(mapping, nid);
> +	if (!npage)
> +		return;
> +
> +	memcpy(page_address(npage), page_address(page), PAGE_CACHE_SIZE);
> +
> +	SetPageUptodate(npage);
> +	f2fs_put_page(npage, 1);
> +
> +	return;
> +}
> +
>  int restore_node_summary(struct f2fs_sb_info *sbi,
>  			unsigned int segno, struct f2fs_summary_block *sum)
>  {
> @@ -1633,6 +1661,8 @@ int restore_node_summary(struct f2fs_sb_info *sbi,
>  				sum_entry->version = 0;
>  				sum_entry->ofs_in_node = 0;
>  				sum_entry++;
> +				f2fs_cache_node_page(sbi, page,
> +					le32_to_cpu(rn->footer.nid));
>  			} else {
>  				err = -EIO;
>  			}
> --
> 1.7.9.5
> 
> 
> ------------------------------------------------------------------------------
> Sponsored by Intel(R) XDK
> Develop, test and display web and hybrid apps with a single code base.
> Download it for free now!
> http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 3/3] f2fs: introduce f2fs_cache_node_page() to add page into node_inode cache
  2013-12-05  2:10 ` Chao Yu
@ 2013-12-06  1:42   ` Jaegeuk Kim
  2013-12-06  2:34     ` Chao Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Jaegeuk Kim @ 2013-12-06  1:42 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel

Hi,

2013-12-05 (목), 10:10 +0800, Chao Yu:
> > -----Original Message-----
> > From: Chao Yu [mailto:chao2.yu@samsung.com]
> > Sent: Thursday, December 05, 2013 9:55 AM
> > To: ???
> > Cc: linux-fsdevel@vger.kernel.org; linux-kernel@vger.kernel.org; linux-f2fs-devel@lists.sourceforge.net
> > Subject: [f2fs-dev] [PATCH 3/3] f2fs: introduce f2fs_cache_node_page() to add page into node_inode cache
> > 
> > This patch introduces f2fs_cache_node_page(), in this function, page which is
> > readed ahead will be copy to node_inode's mapping cache.
> > It will avoid rereading these node pages.
> > 
> > Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> 
> Suggested-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
> 
> I miss that, my mistake.
> 
> > ---
> >  fs/f2fs/node.c |   30 ++++++++++++++++++++++++++++++
> >  1 file changed, 30 insertions(+)
> > 
> > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> > index 099f06f..5e2588f 100644
> > --- a/fs/f2fs/node.c
> > +++ b/fs/f2fs/node.c
> > @@ -1600,6 +1600,34 @@ static int ra_sum_pages(struct f2fs_sb_info *sbi, struct list_head *pages,
> >  	return 0;
> >  }
> > 
> > +/*
> > + * f2fs_cache_node_page() copy updated page data to node_inode cache page.
> > + */
> > +void f2fs_cache_node_page(struct f2fs_sb_info *sbi, struct page *page,
> > +						nid_t nid)
> > +{
> > +	struct address_space *mapping = sbi->node_inode->i_mapping;
> > +	struct page *npage;
> > +
> > +	npage = find_get_page(mapping, nid);
> > +	if (npage && PageUptodate(npage)) {
> > +		f2fs_put_page(npage, 0);
> > +		return;
> > +	}
> > +	f2fs_put_page(npage, 0);
> > +
> > +	npage = grab_cache_page(mapping, nid);
> > +	if (!npage)
> > +		return;
> > +

I forgot to tell you that we need to check its validity here.
We should not cache this page all the time.
So, let's consider this approach a little bit more.
Thank you, :)

> > +	memcpy(page_address(npage), page_address(page), PAGE_CACHE_SIZE);
> > +
> > +	SetPageUptodate(npage);
> > +	f2fs_put_page(npage, 1);
> > +
> > +	return;
> > +}
> > +
> >  int restore_node_summary(struct f2fs_sb_info *sbi,
> >  			unsigned int segno, struct f2fs_summary_block *sum)
> >  {
> > @@ -1633,6 +1661,8 @@ int restore_node_summary(struct f2fs_sb_info *sbi,
> >  				sum_entry->version = 0;
> >  				sum_entry->ofs_in_node = 0;
> >  				sum_entry++;
> > +				f2fs_cache_node_page(sbi, page,
> > +					le32_to_cpu(rn->footer.nid));
> >  			} else {
> >  				err = -EIO;
> >  			}
> > --
> > 1.7.9.5
> > 
> > 
> > ------------------------------------------------------------------------------
> > Sponsored by Intel(R) XDK
> > Develop, test and display web and hybrid apps with a single code base.
> > Download it for free now!
> > http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
> > _______________________________________________
> > Linux-f2fs-devel mailing list
> > Linux-f2fs-devel@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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
Jaegeuk Kim
Samsung


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 3/3] f2fs: introduce f2fs_cache_node_page() to add page into node_inode cache
  2013-12-06  1:42   ` Jaegeuk Kim
@ 2013-12-06  2:34     ` Chao Yu
  0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2013-12-06  2:34 UTC (permalink / raw)
  To: ???; +Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel

Hi,

> -----Original Message-----
> From: Jaegeuk Kim [mailto:jaegeuk.kim@samsung.com]
> Sent: Friday, December 06, 2013 9:43 AM
> To: Chao Yu
> Cc: linux-fsdevel@vger.kernel.org; linux-kernel@vger.kernel.org; linux-f2fs-devel@lists.sourceforge.net; 谭姝
> Subject: RE: [f2fs-dev] [PATCH 3/3] f2fs: introduce f2fs_cache_node_page() to add page into node_inode cache
> 
> Hi,
> 
> 2013-12-05 (목), 10:10 +0800, Chao Yu:
> > > -----Original Message-----
> > > From: Chao Yu [mailto:chao2.yu@samsung.com]
> > > Sent: Thursday, December 05, 2013 9:55 AM
> > > To: ???
> > > Cc: linux-fsdevel@vger.kernel.org; linux-kernel@vger.kernel.org; linux-f2fs-devel@lists.sourceforge.net
> > > Subject: [f2fs-dev] [PATCH 3/3] f2fs: introduce f2fs_cache_node_page() to add page into node_inode cache
> > >
> > > This patch introduces f2fs_cache_node_page(), in this function, page which is
> > > readed ahead will be copy to node_inode's mapping cache.
> > > It will avoid rereading these node pages.
> > >
> > > Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> >
> > Suggested-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
> >
> > I miss that, my mistake.
> >
> > > ---
> > >  fs/f2fs/node.c |   30 ++++++++++++++++++++++++++++++
> > >  1 file changed, 30 insertions(+)
> > >
> > > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> > > index 099f06f..5e2588f 100644
> > > --- a/fs/f2fs/node.c
> > > +++ b/fs/f2fs/node.c
> > > @@ -1600,6 +1600,34 @@ static int ra_sum_pages(struct f2fs_sb_info *sbi, struct list_head *pages,
> > >  	return 0;
> > >  }
> > >
> > > +/*
> > > + * f2fs_cache_node_page() copy updated page data to node_inode cache page.
> > > + */
> > > +void f2fs_cache_node_page(struct f2fs_sb_info *sbi, struct page *page,
> > > +						nid_t nid)
> > > +{
> > > +	struct address_space *mapping = sbi->node_inode->i_mapping;
> > > +	struct page *npage;
> > > +
> > > +	npage = find_get_page(mapping, nid);
> > > +	if (npage && PageUptodate(npage)) {
> > > +		f2fs_put_page(npage, 0);
> > > +		return;
> > > +	}
> > > +	f2fs_put_page(npage, 0);
> > > +
> > > +	npage = grab_cache_page(mapping, nid);
> > > +	if (!npage)
> > > +		return;
> > > +
> 
> I forgot to tell you that we need to check its validity here.
> We should not cache this page all the time.
> So, let's consider this approach a little bit more.
> Thank you, :)

Ah, agreed.

I think we should check whether this page is uptodate or not.
And find_lock_page() will check value of 'mapping',
so we do not check here.

Anyway, I will send patch V2.
Thanks for your review. :)

> 
> > > +	memcpy(page_address(npage), page_address(page), PAGE_CACHE_SIZE);
> > > +
> > > +	SetPageUptodate(npage);
> > > +	f2fs_put_page(npage, 1);
> > > +
> > > +	return;
> > > +}
> > > +
> > >  int restore_node_summary(struct f2fs_sb_info *sbi,
> > >  			unsigned int segno, struct f2fs_summary_block *sum)
> > >  {
> > > @@ -1633,6 +1661,8 @@ int restore_node_summary(struct f2fs_sb_info *sbi,
> > >  				sum_entry->version = 0;
> > >  				sum_entry->ofs_in_node = 0;
> > >  				sum_entry++;
> > > +				f2fs_cache_node_page(sbi, page,
> > > +					le32_to_cpu(rn->footer.nid));
> > >  			} else {
> > >  				err = -EIO;
> > >  			}
> > > --
> > > 1.7.9.5
> > >
> > >
> > > ------------------------------------------------------------------------------
> > > Sponsored by Intel(R) XDK
> > > Develop, test and display web and hybrid apps with a single code base.
> > > Download it for free now!
> > > http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
> > > _______________________________________________
> > > Linux-f2fs-devel mailing list
> > > Linux-f2fs-devel@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 majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at  http://www.tux.org/lkml/
> 
> --
> Jaegeuk Kim
> Samsung


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-12-06  2:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-05  1:54 [PATCH 3/3] f2fs: introduce f2fs_cache_node_page() to add page into node_inode cache Chao Yu
2013-12-05  2:10 ` Chao Yu
2013-12-06  1:42   ` Jaegeuk Kim
2013-12-06  2:34     ` Chao Yu

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).