Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757046AbbBEJvW (ORCPT ); Thu, 5 Feb 2015 04:51:22 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:19791 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753258AbbBEJvS (ORCPT ); Thu, 5 Feb 2015 04:51:18 -0500 X-AuditID: cbfee61a-f79c06d000004e71-3f-54d33d14b5b2 From: Chao Yu To: Jaegeuk Kim , Changman Lee Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH v3 03/10] f2fs: introduce f2fs_map_bh to clean codes of check_extent_cache Date: Thu, 05 Feb 2015 17:50:30 +0800 Message-id: <000001d04129$48365810$d8a30830$@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: AdA/j2B3GJSQ/tM8TqWalF18jf9wqw== Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrMLMWRmVeSWpSXmKPExsVy+t9jQV0R28shBs+32lhc29fIZPFk/Sxm i0uL3C0u75rD5sDisWlVJ5vH7gWfmTz6tqxi9Pi8SS6AJYrLJiU1J7MstUjfLoErY+HLBvaC acIVXx7MZWlg3MXfxcjJISFgItG+7hwThC0mceHeerYuRi4OIYHpjBK3Ji5khnB+MEp82XMI rIpNQEViecd/MFtEwEti0v4TLCA2s4CHRGPHd1YQW1ggRuLeynnsIDaLgKrEnAsz2UBsXgFL if9nl7NA2IISPybfg+rVkli/8zgThC0vsXnNW2aIixQkdpx9zQixS09i7dRprBA14hIbj9xi mcAoMAvJqFlIRs1CMmoWkpYFjCyrGEVTC5ILipPScw31ihNzi0vz0vWS83M3MYKD+pnUDsaV DRaHGAU4GJV4eC33XQoRYk0sK67MPcQowcGsJMKryXE5RIg3JbGyKrUoP76oNCe1+BCjNAeL kjivkn1biJBAemJJanZqakFqEUyWiYNTqoExyiH5yI1J9zRiOKQs5VrEdEIjqwrWZp6PiGTm nXCxsNPENT7wBfMVuYeX5055/GVdxo9NlqqXHggrJVyTn7oxaOK247pXOOzPf0742LImxOdb wlfhSRzn/k1aW2yzLz/4jXfl0R/P/3ddOGy0f86yhG5t/pz+baWLXj9bt6WpkSfJ4sQaqysN SizFGYmGWsxFxYkAIYrMq2YCAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2618 Lines: 86 This patch introduces f2fs_map_bh to clean codes of check_extent_cache. v2: o cleanup f2fs_map_bh pointed out by Jaegeuk Kim. Signed-off-by: Chao Yu --- fs/f2fs/data.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 335df0d..f2d8deb 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -248,8 +248,23 @@ int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index) return err; } +static void f2fs_map_bh(struct super_block *sb, pgoff_t pgofs, + struct extent_info *ei, struct buffer_head *bh_result) +{ + unsigned int blkbits = sb->s_blocksize_bits; + size_t count; + + clear_buffer_new(bh_result); + map_bh(bh_result, sb, ei->blk + pgofs - ei->fofs); + count = ei->fofs + ei->len - pgofs; + if (count < (UINT_MAX >> blkbits)) + bh_result->b_size = (count << blkbits); + else + bh_result->b_size = UINT_MAX; +} + static int check_extent_cache(struct inode *inode, pgoff_t pgofs, - struct buffer_head *bh_result) + struct extent_info *ei) { struct f2fs_inode_info *fi = F2FS_I(inode); pgoff_t start_fofs, end_fofs; @@ -271,18 +286,7 @@ static int check_extent_cache(struct inode *inode, pgoff_t pgofs, start_blkaddr = fi->ext.blk; if (pgofs >= start_fofs && pgofs <= end_fofs) { - unsigned int blkbits = inode->i_sb->s_blocksize_bits; - size_t count; - - clear_buffer_new(bh_result); - map_bh(bh_result, inode->i_sb, - start_blkaddr + pgofs - start_fofs); - count = end_fofs - pgofs + 1; - if (count < (UINT_MAX >> blkbits)) - bh_result->b_size = (count << blkbits); - else - bh_result->b_size = UINT_MAX; - + *ei = fi->ext; stat_inc_read_hit(inode->i_sb); read_unlock(&fi->ext_lock); return 1; @@ -608,13 +612,16 @@ static int __get_data_block(struct inode *inode, sector_t iblock, int mode = create ? ALLOC_NODE : LOOKUP_NODE_RA; pgoff_t pgofs, end_offset; int err = 0, ofs = 1; + struct extent_info ei; bool allocated = false; /* Get the page offset from the block offset(iblock) */ pgofs = (pgoff_t)(iblock >> (PAGE_CACHE_SHIFT - blkbits)); - if (check_extent_cache(inode, pgofs, bh_result)) + if (check_extent_cache(inode, pgofs, &ei)) { + f2fs_map_bh(inode->i_sb, pgofs, &ei, bh_result); goto out; + } if (create) { f2fs_balance_fs(F2FS_I_SB(inode)); -- 2.2.1 -- 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/