From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chao Yu Subject: [PATCH 3/3] f2fs: introduce f2fs_cache_node_page() to add page into node_inode cache Date: Thu, 05 Dec 2013 09:54:56 +0800 Message-ID: <001701cef15d$169a5a30$43cf0e90$@samsung.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1VoOAM-0004D6-Hk for linux-f2fs-devel@lists.sourceforge.net; Thu, 05 Dec 2013 01:55:46 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-MD5:128) (Exim 4.76) id 1VoOAL-0006PE-Lr for linux-f2fs-devel@lists.sourceforge.net; Thu, 05 Dec 2013 01:55:46 +0000 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MXB00E7Y9CQC840@mailout3.samsung.com> for linux-f2fs-devel@lists.sourceforge.net; Thu, 05 Dec 2013 10:55:38 +0900 (KST) Content-language: zh-cn List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net To: ??? Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net 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 --- 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