From patchwork Thu Feb 24 12:48:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liubo X-Patchwork-Id: 587341 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 p1OCmFf0005850 for ; Thu, 24 Feb 2011 12:48:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753330Ab1BXMsA (ORCPT ); Thu, 24 Feb 2011 07:48:00 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:52758 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752164Ab1BXMr7 (ORCPT ); Thu, 24 Feb 2011 07:47:59 -0500 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id EAF37170080; Thu, 24 Feb 2011 20:47:54 +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 p1OCg9GQ031674; Thu, 24 Feb 2011 20:42:09 +0800 Received: from localhost.localdomain ([10.167.225.27]) by mailserver.fnst.cn.fujitus.com (Lotus Domino Release 8.5.1FP4) with ESMTP id 2011022420465183-216251 ; Thu, 24 Feb 2011 20:46:51 +0800 Message-ID: <4D665396.2040105@cn.fujitsu.com> Date: Thu, 24 Feb 2011 20:48:22 +0800 From: liubo User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1b3pre) Gecko/20090513 Fedora/3.0-2.3.beta2.fc11 Thunderbird/3.0b2 MIME-Version: 1.0 To: Daniel J Blueman CC: Chris Mason , Josef Bacik , Linux BTRFS , Miao Xie Subject: Re: [2.6.38-rc6] create->rebalance->mount crash... References: In-Reply-To: X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-02-24 20:46:51, Serialize by Router on mailserver/fnst(Release 8.5.1FP4|July 25, 2010) at 2011-02-24 20:46:52, Serialize complete at 2011-02-24 20:46:52 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.6 (demeter1.kernel.org [140.211.167.41]); Thu, 24 Feb 2011 12:48:16 +0000 (UTC) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 100e409..4749ab0 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -3856,10 +3856,14 @@ static void update_global_block_rsv(struct btrfs_fs_info *fs_info) spin_unlock(&block_rsv->lock); } -static void init_global_block_rsv(struct btrfs_fs_info *fs_info) +static int init_global_block_rsv(struct btrfs_fs_info *fs_info) { struct btrfs_space_info *space_info; + space_info = __find_space_info(fs_info, BTRFS_BLOCK_GROUP_DATA); + if (!space_info) + return -EAGAIN; + space_info = __find_space_info(fs_info, BTRFS_BLOCK_GROUP_SYSTEM); fs_info->chunk_block_rsv.space_info = space_info; fs_info->chunk_block_rsv.priority = 10; @@ -3884,6 +3888,8 @@ static void init_global_block_rsv(struct btrfs_fs_info *fs_info) btrfs_add_durable_block_rsv(fs_info, &fs_info->delalloc_block_rsv); update_global_block_rsv(fs_info); + + return 0; } static void release_global_block_rsv(struct btrfs_fs_info *fs_info) @@ -8514,7 +8520,13 @@ int btrfs_read_block_groups(struct btrfs_root *root) set_block_group_ro(cache); } - init_global_block_rsv(info); +again: + ret = init_global_block_rsv(info); + if (ret == -EAGAIN) { + update_space_info(info, BTRFS_BLOCK_GROUP_DATA, 0, 0, + &space_info); + goto again; + } ret = 0; error: btrfs_free_path(path);