From patchwork Tue May 11 08:25:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zheng" X-Patchwork-Id: 98637 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4B8QQuu022266 for ; Tue, 11 May 2010 08:26:26 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757175Ab0EKI0Y (ORCPT ); Tue, 11 May 2010 04:26:24 -0400 Received: from rcsinet10.oracle.com ([148.87.113.121]:29466 "EHLO rcsinet10.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755918Ab0EKI0W (ORCPT ); Tue, 11 May 2010 04:26:22 -0400 Received: from rcsinet15.oracle.com (rcsinet15.oracle.com [148.87.113.117]) by rcsinet10.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id o4B8QKCa012849 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 11 May 2010 08:26:21 GMT Received: from acsmt353.oracle.com (acsmt353.oracle.com [141.146.40.153]) by rcsinet15.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id o4AIkFCL006449 for ; Tue, 11 May 2010 08:26:19 GMT Received: from abhmt014.oracle.com by acsmt355.oracle.com with ESMTP id 230482311273566352; Tue, 11 May 2010 01:25:52 -0700 Received: from [192.168.0.100] (/118.112.27.58) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 11 May 2010 01:25:52 -0700 Message-ID: <4BE9148A.9090709@oracle.com> Date: Tue, 11 May 2010 16:25:46 +0800 From: "Yan, Zheng" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100330 Fedora/3.0.4-1.fc12 Thunderbird/3.0.4 MIME-Version: 1.0 To: linux-btrfs@vger.kernel.org CC: Chris Mason Subject: [PATCH 4/5] btrfs: don't cache empty block groups during mount X-Auth-Type: Internal IP X-Source-IP: rcsinet15.oracle.com [148.87.113.117] X-CT-RefId: str=0001.0A090201.4BE914AD.0228:SCFMA4539811,ss=1,fgs=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.3 (demeter.kernel.org [140.211.167.41]); Tue, 11 May 2010 08:26:26 +0000 (UTC) diff -urp 4/fs/btrfs/extent-tree.c 8/fs/btrfs/extent-tree.c --- 4/fs/btrfs/extent-tree.c 2010-05-11 14:15:29.174108554 +0800 +++ 8/fs/btrfs/extent-tree.c 2010-05-11 13:26:38.036107000 +0800 @@ -316,11 +329,6 @@ static int caching_kthread(void *data) if (!path) return -ENOMEM; - exclude_super_stripes(extent_root, block_group); - spin_lock(&block_group->space_info->lock); - block_group->space_info->bytes_super += block_group->bytes_super; - spin_unlock(&block_group->space_info->lock); - last = max_t(u64, block_group->key.objectid, BTRFS_SUPER_INFO_OFFSET); /* @@ -7499,6 +7541,7 @@ int btrfs_free_block_groups(struct btrfs if (block_group->cached == BTRFS_CACHE_STARTED) wait_block_group_cache_done(block_group); + free_excluded_extents(info->extent_root, block_group); btrfs_remove_free_space_cache(block_group); btrfs_put_block_group(block_group); @@ -7586,26 +7629,12 @@ int btrfs_read_block_groups(struct btrfs cache->flags = btrfs_block_group_flags(&cache->item); cache->sectorsize = root->sectorsize; - /* - * check for two cases, either we are full, and therefore - * don't need to bother with the caching work since we won't - * find any space, or we are empty, and we can just add all - * the space in and be done with it. This saves us _alot_ of - * time, particularly in the full case. - */ - if (found_key.offset == btrfs_block_group_used(&cache->item)) { - exclude_super_stripes(root, cache); - cache->last_byte_to_unpin = (u64)-1; - cache->cached = BTRFS_CACHE_FINISHED; - free_excluded_extents(root, cache); - } else if (btrfs_block_group_used(&cache->item) == 0) { - exclude_super_stripes(root, cache); + exclude_super_stripes(root, cache); + /* check for the case that block group is full */ + if (found_key.offset == cache->bytes_super + + btrfs_block_group_used(&cache->item)) { cache->last_byte_to_unpin = (u64)-1; cache->cached = BTRFS_CACHE_FINISHED; - add_new_free_space(cache, root->fs_info, - found_key.objectid, - found_key.objectid + - found_key.offset); free_excluded_extents(root, cache); }