From patchwork Mon Nov 29 08:03:22 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zefan X-Patchwork-Id: 363192 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 oAT81q4Y011356 for ; Mon, 29 Nov 2010 08:01:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752623Ab0K2IBt (ORCPT ); Mon, 29 Nov 2010 03:01:49 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:52786 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752108Ab0K2IBt (ORCPT ); Mon, 29 Nov 2010 03:01:49 -0500 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id B8D92170A6D; Mon, 29 Nov 2010 16:01:42 +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 oAT7v7rm005242; Mon, 29 Nov 2010 15:57:07 +0800 Received: from lizf.localdomain ([10.167.225.51]) by mailserver.fnst.cn.fujitus.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2010112916015582-118018 ; Mon, 29 Nov 2010 16:01:55 +0800 Message-ID: <4CF35E4A.1060206@cn.fujitsu.com> Date: Mon, 29 Nov 2010 16:03:22 +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 CC: Sage Weil Subject: [PATCH 3/5] btrfs: Add helper __setup_root_post() References: <4CF35E17.6050705@cn.fujitsu.com> In-Reply-To: <4CF35E17.6050705@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2010-11-29 16:01:55, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2010-11-29 16:01:56, Serialize complete at 2010-11-29 16:01:56 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]); Mon, 29 Nov 2010 08:01:52 +0000 (UTC) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index b40dfe4..fb650e0 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -959,14 +959,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, @@ -977,12 +988,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; } @@ -1083,8 +1089,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); @@ -1121,12 +1125,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;