Skip to contentSkip to conversation

f2fs: introduce f2fs_cache_node_page() to add page into node_inode cache

PATCH In review Chao Yu 2 participants 4 messages Dec 5, 2013 – Dec 6, 2013

Subsystems (2)
lore
Share & tools
lore

Chao Yu

author
#0 lore raw

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.

---
 fs/f2fs/node.c |   30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
fs/f2fs/node.c +30 -0
index 099f06f..5e2588f 100644
@@ -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;
 			}
Signature · 8 lines
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
author
#1 lore raw
Quoted 7 lines

-----Original Message-----
From: Chao Yu [mailto:[email protected]]
Sent: Thursday, December 05, 2013 9:55 AM
To: ???
Cc: [email protected]; [email protected]; [email protected]
Subject: [f2fs-dev] [PATCH 3/3] f2fs: introduce f2fs_cache_node_page() to add page into node_inode cache

Quoted 5 lines

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.

I miss that, my mistake.

Quoted 56 lines
---
 fs/f2fs/node.c |   30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
fs/f2fs/node.c +30 -1
index 099f06f..5e2588f 100644
@@ -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

Quoted 9 lines

------------------------------------------------------------------------------
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 [email protected]
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

#2 lore raw

Hi,

2013-12-05 (목), 10:10 +0800, Chao Yu:

Quoted 41 lines
Quoted 7 lines

-----Original Message-----
From: Chao Yu [mailto:[email protected]]
Sent: Thursday, December 05, 2013 9:55 AM
To: ???
Cc: [email protected]; [email protected]; [email protected]
Subject: [f2fs-dev] [PATCH 3/3] f2fs: introduce f2fs_cache_node_page() to add page into node_inode cache

Quoted 5 lines

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.

I miss that, my mistake.

Quoted 24 lines
---
 fs/f2fs/node.c |   30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
fs/f2fs/node.c +12 -0
index 099f06f..5e2588f 100644
@@ -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);
Quoted 8 lines

fs/f2fs/node.c static int ra_sum_pages(struct f2fs_sb_info *sbi, struct list_head *pages, · line 1622

Quoted 8 lines
fs/f2fs/node.c +8 -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, :)

Quoted 39 lines
Quoted 24 lines
fs/f2fs/node.c +10 -1
+	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

Quoted 9 lines

------------------------------------------------------------------------------
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 [email protected]
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 13 lines
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
author
#3 lore raw

Hi,

Quoted 56 lines

-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Friday, December 06, 2013 9:43 AM
To: Chao Yu
Cc: [email protected]; [email protected]; [email protected]; 谭姝
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:

Quoted 46 lines
Quoted 7 lines

-----Original Message-----
From: Chao Yu [mailto:[email protected]]
Sent: Thursday, December 05, 2013 9:55 AM
To: ???
Cc: [email protected]; [email protected]; [email protected]
Subject: [f2fs-dev] [PATCH 3/3] f2fs: introduce f2fs_cache_node_page() to add page into node_inode cache

Quoted 5 lines

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.

I miss that, my mistake.

Quoted 29 lines
---
 fs/f2fs/node.c |   30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
fs/f2fs/node.c +17 -0
index 099f06f..5e2588f 100644
@@ -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);
Quoted 8 lines
Quoted 3 lines

fs/f2fs/node.c static int ra_sum_pages(struct f2fs_sb_info *sbi, struct list_head *pages, · line 1622

Quoted 3 lines
fs/f2fs/node.c +3 -0
+	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. :)

Quoted 41 lines
Quoted 25 lines
Quoted 25 lines
fs/f2fs/node.c +10 -1
+	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

Quoted 15 lines
Quoted 9 lines

------------------------------------------------------------------------------
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 [email protected]
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Quoted 3 lines

--
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 [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel