Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 165909
b: refs/heads/master
c: 0a24325
h: refs/heads/master
i:
  165907: b300f04
v: v3
  • Loading branch information
Josef Bacik authored and Chris Mason committed Sep 21, 2009
1 parent 4ff629b commit 344bcff
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ba1bf4818baf68d914ef9e3b06fbea6acb674fe4
refs/heads/master: 0a24325e6d8cfb150eba0aa279615ef27b5f6aec
25 changes: 17 additions & 8 deletions trunk/fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -3726,6 +3726,7 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans,
int last_ptr_loop = 0;
int loop = 0;
bool found_uncached_bg = false;
bool failed_cluster_refill = false;

WARN_ON(num_bytes < root->sectorsize);
btrfs_set_key_type(ins, BTRFS_EXTENT_ITEM_KEY);
Expand Down Expand Up @@ -3823,7 +3824,16 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans,
if (unlikely(block_group->ro))
goto loop;

if (last_ptr) {
/*
* Ok we want to try and use the cluster allocator, so lets look
* there, unless we are on LOOP_NO_EMPTY_SIZE, since we will
* have tried the cluster allocator plenty of times at this
* point and not have found anything, so we are likely way too
* fragmented for the clustering stuff to find anything, so lets
* just skip it and let the allocator find whatever block it can
* find
*/
if (last_ptr && loop < LOOP_NO_EMPTY_SIZE) {
/*
* the refill lock keeps out other
* people trying to start a new cluster
Expand Down Expand Up @@ -3898,9 +3908,11 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans,
spin_unlock(&last_ptr->refill_lock);
goto checks;
}
} else if (!cached && loop > LOOP_CACHING_NOWAIT) {
} else if (!cached && loop > LOOP_CACHING_NOWAIT
&& !failed_cluster_refill) {
spin_unlock(&last_ptr->refill_lock);

failed_cluster_refill = true;
wait_block_group_cache_progress(block_group,
num_bytes + empty_cluster + empty_size);
goto have_block_group;
Expand All @@ -3912,13 +3924,9 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans,
* cluster. Free the cluster we've been trying
* to use, and go to the next block group
*/
if (loop < LOOP_NO_EMPTY_SIZE) {
btrfs_return_cluster_to_free_space(NULL,
last_ptr);
spin_unlock(&last_ptr->refill_lock);
goto loop;
}
btrfs_return_cluster_to_free_space(NULL, last_ptr);
spin_unlock(&last_ptr->refill_lock);
goto loop;
}

offset = btrfs_find_space_for_alloc(block_group, search_start,
Expand Down Expand Up @@ -3977,6 +3985,7 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans,
/* we are all good, lets return */
break;
loop:
failed_cluster_refill = false;
btrfs_put_block_group(block_group);
}
up_read(&space_info->groups_sem);
Expand Down

0 comments on commit 344bcff

Please sign in to comment.