From patchwork Fri Nov 19 14:33:37 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 339381 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 oAJEhcIt016450 for ; Fri, 19 Nov 2010 14:43:40 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754523Ab0KSOnT (ORCPT ); Fri, 19 Nov 2010 09:43:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:29139 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753548Ab0KSOnS (ORCPT ); Fri, 19 Nov 2010 09:43:18 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oAJEhHwC006763 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 19 Nov 2010 09:43:17 -0500 Received: from localhost.localdomain (test1244.test.redhat.com [10.10.10.244]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oAJEhHui016206 for ; Fri, 19 Nov 2010 09:43:17 -0500 From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH] Btrfs: do not loop through raid types when looking for free extent V2 Date: Fri, 19 Nov 2010 09:33:37 -0500 Message-Id: <1290177217-2677-1-git-send-email-josef@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 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]); Fri, 19 Nov 2010 14:43:40 +0000 (UTC) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 0c097f3..132276a 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4785,16 +4785,16 @@ wait_block_group_cache_done(struct btrfs_block_group_cache *cache) return 0; } -static int get_block_group_index(struct btrfs_block_group_cache *cache) +static int get_block_group_index(u64 flags) { int index; - if (cache->flags & BTRFS_BLOCK_GROUP_RAID10) + if (flags & BTRFS_BLOCK_GROUP_RAID10) index = 0; - else if (cache->flags & BTRFS_BLOCK_GROUP_RAID1) + else if (flags & BTRFS_BLOCK_GROUP_RAID1) index = 1; - else if (cache->flags & BTRFS_BLOCK_GROUP_DUP) + else if (flags & BTRFS_BLOCK_GROUP_DUP) index = 2; - else if (cache->flags & BTRFS_BLOCK_GROUP_RAID0) + else if (flags & BTRFS_BLOCK_GROUP_RAID0) index = 3; else index = 4; @@ -4834,7 +4834,7 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans, struct btrfs_space_info *space_info; int last_ptr_loop = 0; int loop = 0; - int index = 0; + int index = get_block_group_index(data); bool found_uncached_bg = false; bool failed_cluster_refill = false; bool failed_alloc = false; @@ -4913,7 +4913,6 @@ ideal_cache: btrfs_put_block_group(block_group); up_read(&space_info->groups_sem); } else { - index = get_block_group_index(block_group); goto have_block_group; } } else if (block_group) { @@ -5145,14 +5144,11 @@ checks: loop: failed_cluster_refill = false; failed_alloc = false; - BUG_ON(index != get_block_group_index(block_group)); + BUG_ON(index != get_block_group_index(block_group->flags)); btrfs_put_block_group(block_group); } up_read(&space_info->groups_sem); - if (!ins->objectid && ++index < BTRFS_NR_RAID_TYPES) - goto search; - /* LOOP_FIND_IDEAL, only search caching/cached bg's, and don't wait for * for them to make caching progress. Also * determine the best possible bg to cache @@ -5166,7 +5162,6 @@ loop: if (!ins->objectid && loop < LOOP_NO_EMPTY_SIZE && (found_uncached_bg || empty_size || empty_cluster || allowed_chunk_alloc)) { - index = 0; if (loop == LOOP_FIND_IDEAL && found_uncached_bg) { found_uncached_bg = false; loop++; @@ -8204,7 +8199,7 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info) static void __link_block_group(struct btrfs_space_info *space_info, struct btrfs_block_group_cache *cache) { - int index = get_block_group_index(cache); + int index = get_block_group_index(cache->flags); down_write(&space_info->groups_sem); list_add_tail(&cache->list, &space_info->block_groups[index]);