From patchwork Sun Mar 27 05:30:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Itaru Kitayama X-Patchwork-Id: 666351 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 p2R5VGfg026673 for ; Sun, 27 Mar 2011 05:31:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751426Ab1C0Fa7 (ORCPT ); Sun, 27 Mar 2011 01:30:59 -0400 Received: from irs1ma.bb4u.ne.jp ([202.229.9.180]:32791 "EHLO irs1ma.bb4u.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751404Ab1C0Fa6 (ORCPT ); Sun, 27 Mar 2011 01:30:58 -0400 Received: from prime (nc2213.bb4u.ne.jp [58.89.221.3]) by irs1ma.bb4u.ne.jp (Postfix) with SMTP id 765CF4E030D; Sun, 27 Mar 2011 14:30:55 +0900 (JST) Date: Sun, 27 Mar 2011 14:30:55 +0900 From: Itaru Kitayama To: miaox@cn.fujitsu.com Cc: Chris Mason , Linux Btrfs , Ito , David Sterba Subject: Re: [PATCH V5 2/2] btrfs: implement delayed inode items operation Message-Id: <20110327143055.ae2d3c68.kitayama@cl.bb4u.ne.jp> In-Reply-To: <4D8B2DEB.1000001@cn.fujitsu.com> References: <4D8B2DEB.1000001@cn.fujitsu.com> X-Mailer: Sylpheed 3.0.2 (GTK+ 2.20.1; x86_64-redhat-linux-gnu) Mime-Version: 1.0 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]); Sun, 27 Mar 2011 05:31:17 +0000 (UTC) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 2164296..f40ff4e 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -740,6 +740,7 @@ struct btrfs_space_info { struct list_head block_groups[BTRFS_NR_RAID_TYPES]; spinlock_t lock; struct rw_semaphore groups_sem; + struct srcu_struct groups_srcu; atomic_t caching_threads; }; diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 9e4c9f4..22d6dbb 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -3003,6 +3003,7 @@ static int update_space_info(struct btrfs_fs_info *info, u64 flags, for (i = 0; i < BTRFS_NR_RAID_TYPES; i++) INIT_LIST_HEAD(&found->block_groups[i]); init_rwsem(&found->groups_sem); + init_srcu_struct(&found->groups_srcu); spin_lock_init(&found->lock); found->flags = flags & (BTRFS_BLOCK_GROUP_DATA | BTRFS_BLOCK_GROUP_SYSTEM | @@ -4853,6 +4854,7 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans, int data) { int ret = 0; + int idx; struct btrfs_root *root = orig_root->fs_info->extent_root; struct btrfs_free_cluster *last_ptr = NULL; struct btrfs_block_group_cache *block_group = NULL; @@ -4929,7 +4931,7 @@ ideal_cache: if (block_group && block_group_bits(block_group, data) && (block_group->cached != BTRFS_CACHE_NO || search_start == ideal_cache_offset)) { - down_read(&space_info->groups_sem); + idx = srcu_read_lock(&space_info->groups_srcu); if (list_empty(&block_group->list) || block_group->ro) { /* @@ -4939,7 +4941,7 @@ ideal_cache: * valid */ btrfs_put_block_group(block_group); - up_read(&space_info->groups_sem); + srcu_read_unlock(&space_info->groups_srcu, idx); } else { index = get_block_group_index(block_group); goto have_block_group; @@ -4949,8 +4951,8 @@ ideal_cache: } } search: - down_read(&space_info->groups_sem); - list_for_each_entry(block_group, &space_info->block_groups[index], + idx = srcu_read_lock(&space_info->groups_srcu); + list_for_each_entry_rcu(block_group, &space_info->block_groups[index], list) { u64 offset; int cached; @@ -5197,8 +5199,8 @@ loop: BUG_ON(index != get_block_group_index(block_group)); btrfs_put_block_group(block_group); } - up_read(&space_info->groups_sem); - + srcu_read_unlock(&space_info->groups_srcu, idx); + if (!ins->objectid && ++index < BTRFS_NR_RAID_TYPES) goto search;