From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754361AbbCSL0t (ORCPT ); Thu, 19 Mar 2015 07:26:49 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:63312 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751157AbbCSL0r (ORCPT ); Thu, 19 Mar 2015 07:26:47 -0400 X-AuditID: cbfee61b-f79d76d0000024d6-c1-550ab275c14c From: Chao Yu To: Jaegeuk Kim , Changman Lee Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] f2fs: initialize extent tree with on-disk extent info of inode Date: Thu, 19 Mar 2015 19:26:02 +0800 Message-id: <000201d06237$95bd9f60$c138de20$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: AdBh9Bmvu/KfEt69TQqni79SfV8jKA== Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrMLMWRmVeSWpSXmKPExsVy+t9jQd3STVyhBvM/GFlc29fIZPFk/Sxm i0uL3C0u75rD5sDisWlVJ5vH7gWfmTz6tqxi9Pi8SS6AJYrLJiU1J7MstUjfLoEro+H0P7aC b1IVm55cZWpgPCDWxcjJISFgInFx6ht2CFtM4sK99WxdjFwcQgLTGSUWXDsL5fxglNg2fQMT SBWbgIrE8o7/YLaIgJfEpP0nWEBsZgEPicaO76wgtrBAqMT8y4fAprIIqEpMujuFGcTmFbCU ODDrNyOELSjxY/I9qF4tifU7jzNB2PISm9e8ZYa4SEFix9nXjBC79CR+/3jBDlEjLrHxyC2W CYwCs5CMmoVk1Cwko2YhaVnAyLKKUTS1ILmgOCk910ivODG3uDQvXS85P3cTIzion0nvYFzV YHGIUYCDUYmHN8OdK1SINbGsuDL3EKMEB7OSCO/pMqAQb0piZVVqUX58UWlOavEhRmkOFiVx XiX7thAhgfTEktTs1NSC1CKYLBMHp1QD41xXXtkfAuw7dt+yOPyuYmuGzVnru1a8J5pUbvOW nDri779abVaeJLfC4i2rOvtsw1YdeKtT4LA+vfmETQlPreOr4yWKa2/mJVyfwMjzbaLCARnh MK8FCx7OfLb7091vVbzvRBcxfXI+F/HcW0/plm167Qv9Lz8yFi+bsi1iGc85k+qua5NalJRY ijMSDbWYi4oTAZEOt41mAgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With normal extent info cache, we records largest extent mapping between logical block and physical block into extent info, and we persist extent info in on-disk inode. When we enable extent tree cache, if extent info of on-disk inode is exist, and the extent is not a small fragmented mapping extent. We'd better to load the extent info into extent tree cache when inode is loaded. By this way we can have more chance to hit extent tree cache rather than taking more time to read dnode page for block address. Signed-off-by: Chao Yu --- fs/f2fs/data.c | 43 +++++++++++++++++++++++++++++++++++++++++++ fs/f2fs/f2fs.h | 1 + fs/f2fs/inode.c | 4 +--- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index a73df90..0c48af91 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -571,6 +571,39 @@ static unsigned int __free_extent_tree(struct f2fs_sb_info *sbi, return count - et->count; } +static void f2fs_init_extent_tree(struct inode *inode, + struct f2fs_extent *i_ext) +{ + struct f2fs_sb_info *sbi = F2FS_I_SB(inode); + struct extent_tree *et; + struct extent_node *en; + struct extent_info ei; + + if (le32_to_cpu(i_ext->len) < F2FS_MIN_EXTENT_LEN) + return; + + et = __grab_extent_tree(inode); + + write_lock(&et->lock); + if (et->count) + goto out; + + set_extent_info(&ei, le32_to_cpu(i_ext->fofs), + le32_to_cpu(i_ext->blk), le32_to_cpu(i_ext->len)); + + en = __insert_extent_tree(sbi, et, &ei, NULL); + if (en) { + et->cached_en = en; + + spin_lock(&sbi->extent_lock); + list_add_tail(&en->list, &sbi->extent_list); + spin_unlock(&sbi->extent_lock); + } +out: + write_unlock(&et->lock); + atomic_dec(&et->refcount); +} + static bool f2fs_lookup_extent_tree(struct inode *inode, pgoff_t pgofs, struct extent_info *ei) { @@ -781,6 +814,16 @@ out: return; } +void f2fs_init_extent_cache(struct inode *inode, struct f2fs_extent *i_ext) +{ + if (test_opt(F2FS_I_SB(inode), EXTENT_CACHE)) + f2fs_init_extent_tree(inode, i_ext); + + write_lock(&F2FS_I(inode)->ext_lock); + get_extent_info(&F2FS_I(inode)->ext, *i_ext); + write_unlock(&F2FS_I(inode)->ext_lock); +} + static bool f2fs_lookup_extent_cache(struct inode *inode, pgoff_t pgofs, struct extent_info *ei) { diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index c5c3ae9..836e5a9 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1577,6 +1577,7 @@ int reserve_new_block(struct dnode_of_data *); int f2fs_reserve_block(struct dnode_of_data *, pgoff_t); void f2fs_shrink_extent_tree(struct f2fs_sb_info *, int); void f2fs_destroy_extent_tree(struct inode *); +void f2fs_init_extent_cache(struct inode *, struct f2fs_extent *); void f2fs_update_extent_cache(struct dnode_of_data *); struct page *find_data_page(struct inode *, pgoff_t, bool); struct page *get_lock_data_page(struct inode *, pgoff_t); diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index b508744..fcd1e7b 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -130,9 +130,7 @@ static int do_read_inode(struct inode *inode) fi->i_pino = le32_to_cpu(ri->i_pino); fi->i_dir_level = ri->i_dir_level; - write_lock(&fi->ext_lock); - get_extent_info(&fi->ext, ri->i_ext); - write_unlock(&fi->ext_lock); + f2fs_init_extent_cache(inode, &ri->i_ext); get_inline_info(fi, ri); -- 2.3.1