f2fs: introduce f2fs_cache_node_page() to add page into node_inode cache
Subsystems (2)
PATCH v2 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.
change log:
o check validity of grabbed page suggested by Jaegeuk Kim.
--- fs/f2fs/node.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
fs/f2fs/node.c +35 -0
@@ -1600,6 +1600,39 @@ 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 (unlikely (npage &&PageUptodate (npage))) { +f2fs_put_page (npage,0 ); +return ; + } +f2fs_put_page (npage,0 ); + + npage =grab_cache_page (mapping, nid); +if (unlikely (!npage)) +return ; + +if (unlikely (PageUptodate (npage))) { +f2fs_put_page (npage,1 ); +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 +1666,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
2013-12-06 (금), 17:10 +0800, Chao Yu:
Quoted 19 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.change log:
o check validity of grabbed page suggested by Jaegeuk Kim.Suggested-by Jaegeuk Kim <[email protected]>Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/node.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)fs/f2fs/node.c +0
-0@@ -1600,6 +1600,39 @@ static int ra_sum_pages(struct f2fs_sb_info *sbi, struct list_head *pages,return 0 ;
fs/f2fs/node.c static int ra_sum_pages(struct f2fs_sb_info *sbi, struct list_head *pages, · line 1610
Quoted 10 lines
fs/f2fs/node.c +8
-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;
What I meant for the validity was to check the block address to figure out this node page is up-to-date or not.
IOW, something like this.
get_node_info(sbi, nid, &ni);
if (ni.blk_addr != current block address))
goto out;
npage = grab_cache_page(mapping, nid);
if (unlikely(!npage))
return;
if (unlikely(PageUptodate(npage))) {
f2fs_put_page(npage, 1);
return;
}
memcpy(page_address(npage), page_address(page), PAGE_CACHE_SIZE); SetPageUptodate(npage);
f2fs_put_page(npage, 1);
out:
return;
Quoted 37 lines
fs/f2fs/node.c +27
-0+ + npage =find_get_page (mapping, nid); +if (unlikely (npage &&PageUptodate (npage))) { +f2fs_put_page (npage,0 ); +return ; + } +f2fs_put_page (npage,0 ); + + npage =grab_cache_page (mapping, nid); +if (unlikely (!npage)) +return ; + +if (unlikely (PageUptodate (npage))) { +f2fs_put_page (npage,1 ); +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 +1666,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 · 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
Hi,
Quoted 29 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Monday, December 09, 2013 7:37 AM
To: Chao Yu
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [f2fs-dev] [PATCH 3/3 V2] f2fs: introducef2fs_cache_node_page()to add page intonode_inodecache2013-12-06 (금), 17:10 +0800, Chao Yu:
Quoted 21 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.change log:
o check validity of grabbed page suggested by Jaegeuk Kim.Suggested-by Jaegeuk Kim <[email protected]>Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/node.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)fs/f2fs/node.c +0
-0@@ -1600,6 +1600,39 @@ static int ra_sum_pages(struct f2fs_sb_info *sbi, struct list_head *pages,return 0 ; }
Quoted 13 lines
fs/f2fs/node.c static int ra_sum_pages(struct f2fs_sb_info *sbi, struct list_head *pages, · line 1610
Quoted 8 lines
fs/f2fs/node.c +8
-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;What I meant for the validity was to check the block address to figure out this node page is up-to-date or not.
IOW, something like this.
Yes, you're right.
So, how about the this one?
--- fs/f2fs/node.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-)
fs/f2fs/node.c +38 -1
@@ -1600,13 +1600,46 @@ static int ra_sum_pages(struct f2fs_sb_info *sbi, struct list_head *pages,return 0 ; } +/* +* f2fs_cache_node_page() check validaty of input page by searching NAT. +* Then, it will copy updated data of vaild page to node_inode cache. +*/ +void f2fs_cache_node_page (struct f2fs_sb_info *sbi,struct page *page, +nid_t nid,block_t blkaddr) +{ +struct address_space *mapping = sbi->node_inode->i_mapping; +struct page *npage; +struct node_info ni; + +get_node_info (sbi, nid, &ni); + +if (ni.blk_addr != blkaddr) +return ; + + npage =grab_cache_page (mapping, nid); +if (!npage) +return ; + +if (PageUptodate (npage)) { +f2fs_put_page (npage,1 ); +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) {struct f2fs_node *rn;struct f2fs_summary *sum_entry;struct page *page, *tmp; -block_t addr; +block_t addr, blkaddr;int bio_blocks =MAX_BIO_BLOCKS (max_hw_blocks (sbi));int i, last_offset, nrpages, err =0 ;LIST_HEAD (page_list);
@@ -1624,6 +1657,7 @@ int restore_node_summary(struct f2fs_sb_info *sbi,if (err)return err; + blkaddr = addr;list_for_each_entry_safe (page, tmp, &page_list, lru) {lock_page (page);
@@ -1633,6 +1667,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), blkaddr); }else { err = -EIO ; }
@@ -1640,6 +1676,7 @@ int restore_node_summary(struct f2fs_sb_info *sbi,list_del (&page->lru);unlock_page (page);__free_pages (page,0 ); + blkaddr++; } }return err;
Signature · 1 line
1.7.9.5
2013-12-09 (월), 10:14 +0800, Chao Yu:
Quoted 68 lines
Hi,
Quoted 29 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Monday, December 09, 2013 7:37 AM
To: Chao Yu
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [f2fs-dev] [PATCH 3/3 V2] f2fs: introducef2fs_cache_node_page()to add page intonode_inodecache2013-12-06 (금), 17:10 +0800, Chao Yu:
Quoted 21 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.change log:
o check validity of grabbed page suggested by Jaegeuk Kim.Suggested-by Jaegeuk Kim <[email protected]>Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/node.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)fs/f2fs/node.c +0
-0@@ -1600,6 +1600,39 @@ static int ra_sum_pages(struct f2fs_sb_info *sbi, struct list_head *pages,return 0 ; }Quoted 13 lines
fs/f2fs/node.c static int ra_sum_pages(struct f2fs_sb_info *sbi, struct list_head *pages, · line 1611
Quoted 8 lines
fs/f2fs/node.c +8
-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;What I meant for the validity was to check the block address to figure out this node page is up-to-date or not.
IOW, something like this.Yes, you're right.
So, how about the this one?
--- fs/f2fs/node.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-)fs/f2fs/node.c +8
-0@@ -1600,13 +1600,46 @@ static int ra_sum_pages(struct f2fs_sb_info *sbi, struct list_head *pages,return 0 ; } +/* +* f2fs_cache_node_page() check validaty of input page by searching NAT. +* Then, it will copy updated data of vaild page to node_inode cache. +*/ +void f2fs_cache_node_page (struct f2fs_sb_info *sbi,struct page *page, +nid_t nid,block_t blkaddr) +{ +struct address_space *mapping = sbi->node_inode->i_mapping;
fs/f2fs/node.c static int ra_sum_pages(struct f2fs_sb_info *sbi, struct list_head *pages, · line 1620
Quoted 10 lines
fs/f2fs/node.c +10
-0+struct page *npage; +struct node_info ni; + +get_node_info (sbi, nid, &ni); + +if (ni.blk_addr != blkaddr) +return ; + + npage =grab_cache_page (mapping, nid); +if (!npage)
if (unlikely(!npage))
Could you submit a v3?
Thanks,
Quoted 51 lines
fs/f2fs/node.c +20
-1+return ; + +if (PageUptodate (npage)) { +f2fs_put_page (npage,1 ); +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) {struct f2fs_node *rn;struct f2fs_summary *sum_entry;struct page *page, *tmp; -block_t addr; +block_t addr, blkaddr;int bio_blocks =MAX_BIO_BLOCKS (max_hw_blocks (sbi));int i, last_offset, nrpages, err =0 ;LIST_HEAD (page_list);@@ -1624,6 +1657,7 @@ int restore_node_summary(struct f2fs_sb_info *sbi,if (err)return err; + blkaddr = addr;list_for_each_entry_safe (page, tmp, &page_list, lru) {lock_page (page);@@ -1633,6 +1667,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), blkaddr); }else { err = -EIO ; }@@ -1640,6 +1676,7 @@ int restore_node_summary(struct f2fs_sb_info *sbi,list_del (&page->lru);unlock_page (page);__free_pages (page,0 ); + blkaddr++; } }return err;
Signature · 2 lines
Jaegeuk Kim Samsung