From patchwork Wed Nov 17 04:23:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miao Xie X-Patchwork-Id: 330731 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAH4OaFf014502 for ; Wed, 17 Nov 2010 04:24:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759098Ab0KQEXg (ORCPT ); Tue, 16 Nov 2010 23:23:36 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:52946 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1757849Ab0KQEXf (ORCPT ); Tue, 16 Nov 2010 23:23:35 -0500 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id E82A41710AB; Wed, 17 Nov 2010 12:23:34 +0800 (CST) Received: from mailserver.fnst.cn.fujitus.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id oAH4J6Hq020643; Wed, 17 Nov 2010 12:19:08 +0800 Received: from [10.167.225.64] ([10.167.225.64]) by mailserver.fnst.cn.fujitus.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2010111712235578-30754 ; Wed, 17 Nov 2010 12:23:55 +0800 Message-ID: <4CE358C3.7070903@cn.fujitsu.com> Date: Wed, 17 Nov 2010 12:23:31 +0800 From: Miao Xie Reply-To: miaox@cn.fujitsu.com User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100413 Fedora/3.0.4-2.fc13 Thunderbird/3.0.4 MIME-Version: 1.0 To: Josef Bacik , Chris Mason CC: Linux Btrfs , Linux Kernel , Linux Fsdevel , Ito , Andrew Morton Subject: [PATCH 2/3] btrfs: restructure btrfs_merge_bio_hook() X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2010-11-17 12:23:55, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2010-11-17 12:23:58, Serialize complete at 2010-11-17 12:23:58 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 17 Nov 2010 04:24:37 +0000 (UTC) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 3906e48..32b68fa 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1353,6 +1353,22 @@ static int btrfs_clear_bit_hook(struct inode *inode, return 0; } +static int __btrfs_can_merge_page_to_bio(struct btrfs_mapping_tree *map_tree, + size_t size, struct bio *bio) +{ + u64 logical = (u64)bio->bi_sector << 9; + u64 map_length; + int ret; + + map_length = bio->bi_size; + ret = btrfs_map_block(map_tree, READ, logical, + &map_length, NULL, 0); + + if (map_length < bio->bi_size + size) + return 1; + return ret; +} + /* * extent_io.c merge_bio_hook, this must check the chunk tree to make sure * we don't create bios that span stripes or chunks @@ -1363,23 +1379,12 @@ int btrfs_merge_bio_hook(struct page *page, unsigned long offset, { struct btrfs_root *root = BTRFS_I(page->mapping->host)->root; struct btrfs_mapping_tree *map_tree; - u64 logical = (u64)bio->bi_sector << 9; - u64 length = 0; - u64 map_length; - int ret; if (bio_flags & EXTENT_BIO_COMPRESSED) return 0; - length = bio->bi_size; map_tree = &root->fs_info->mapping_tree; - map_length = length; - ret = btrfs_map_block(map_tree, READ, logical, - &map_length, NULL, 0); - - if (map_length < length + size) - return 1; - return ret; + return __btrfs_can_merge_page_to_bio(map_tree, size, bio); } /*