From patchwork Thu Dec 9 09:10:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zefan X-Patchwork-Id: 393462 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 oB99934o030753 for ; Thu, 9 Dec 2010 09:09:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755444Ab0LIJIz (ORCPT ); Thu, 9 Dec 2010 04:08:55 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:51314 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1755369Ab0LIJIy (ORCPT ); Thu, 9 Dec 2010 04:08:54 -0500 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id A48B2170DAC for ; Thu, 9 Dec 2010 17:08:52 +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 oB9949pt015359 for ; Thu, 9 Dec 2010 17:04:09 +0800 Received: from lizf.localdomain ([10.167.225.51]) by mailserver.fnst.cn.fujitus.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2010120917085698-196902 ; Thu, 9 Dec 2010 17:08:56 +0800 Message-ID: <4D009D08.3090904@cn.fujitsu.com> Date: Thu, 09 Dec 2010 17:10:32 +0800 From: Li Zefan User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1b3pre) Gecko/20090513 Fedora/3.0-2.3.beta2.fc11 Thunderbird/3.0b2 MIME-Version: 1.0 To: "linux-btrfs@vger.kernel.org" Subject: [PATCH v2 3/5] Btrfs: Add helper __setup_root_post() References: <4D009CD2.3060805@cn.fujitsu.com> In-Reply-To: <4D009CD2.3060805@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2010-12-09 17:08:57, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2010-12-09 17:08:57, Serialize complete at 2010-12-09 17:08:57 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]); Thu, 09 Dec 2010 09:09:04 +0000 (UTC) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 33b6d45..ca20c6d 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -987,14 +987,25 @@ static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize, return 0; } +static void __setup_root_post(struct btrfs_root *root) +{ + u32 blocksize; + u64 generation; + + generation = btrfs_root_generation(&root->root_item); + blocksize = btrfs_level_size(root, btrfs_root_level(&root->root_item)); + root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item), + blocksize, generation); + BUG_ON(!root->node); + root->commit_root = btrfs_root_node(root); +} + static int find_and_setup_root(struct btrfs_root *tree_root, struct btrfs_fs_info *fs_info, u64 objectid, struct btrfs_root *root) { int ret; - u32 blocksize; - u64 generation; __setup_root(tree_root->nodesize, tree_root->leafsize, tree_root->sectorsize, tree_root->stripesize, @@ -1005,12 +1016,7 @@ static int find_and_setup_root(struct btrfs_root *tree_root, return -ENOENT; BUG_ON(ret); - generation = btrfs_root_generation(&root->root_item); - blocksize = btrfs_level_size(root, btrfs_root_level(&root->root_item)); - root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item), - blocksize, generation); - BUG_ON(!root->node); - root->commit_root = btrfs_root_node(root); + __setup_root_post(root); return 0; } @@ -1111,8 +1117,6 @@ struct btrfs_root *btrfs_read_fs_root_no_radix(struct btrfs_root *tree_root, struct btrfs_fs_info *fs_info = tree_root->fs_info; struct btrfs_path *path; struct extent_buffer *l; - u64 generation; - u32 blocksize; int ret = 0; root = kzalloc(sizeof(*root), GFP_NOFS); @@ -1149,12 +1153,7 @@ struct btrfs_root *btrfs_read_fs_root_no_radix(struct btrfs_root *tree_root, return ERR_PTR(ret); } - generation = btrfs_root_generation(&root->root_item); - blocksize = btrfs_level_size(root, btrfs_root_level(&root->root_item)); - root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item), - blocksize, generation); - root->commit_root = btrfs_root_node(root); - BUG_ON(!root->node); + __setup_root_post(root); out: if (location->objectid != BTRFS_TREE_LOG_OBJECTID) root->ref_cows = 1;