Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 285950
b: refs/heads/master
c: a5f6f71
h: refs/heads/master
v: v3
  • Loading branch information
Alexandre Oliva authored and Chris Mason committed Jan 6, 2012
1 parent bbb971d commit b17221c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 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: 1100373f8aa69e377386499350496e3d8565605f
refs/heads/master: a5f6f719a5cd7caeee8ed8137cf3f94c3bbebc65
34 changes: 23 additions & 11 deletions trunk/fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -5286,15 +5286,6 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans,
if (unlikely(block_group->ro))
goto loop;

spin_lock(&block_group->free_space_ctl->tree_lock);
if (cached &&
block_group->free_space_ctl->free_space <
num_bytes + empty_cluster + empty_size) {
spin_unlock(&block_group->free_space_ctl->tree_lock);
goto loop;
}
spin_unlock(&block_group->free_space_ctl->tree_lock);

/*
* Ok we want to try and use the cluster allocator, so
* lets look there
Expand Down Expand Up @@ -5340,8 +5331,15 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans,
* plenty of times and not have found
* anything, so we are likely way too
* fragmented for the clustering stuff to find
* anything. */
if (loop >= LOOP_NO_EMPTY_SIZE) {
* anything.
*
* However, if the cluster is taken from the
* current block group, release the cluster
* first, so that we stand a better chance of
* succeeding in the unclustered
* allocation. */
if (loop >= LOOP_NO_EMPTY_SIZE &&
last_ptr->block_group != block_group) {
spin_unlock(&last_ptr->refill_lock);
goto unclustered_alloc;
}
Expand All @@ -5352,6 +5350,11 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans,
*/
btrfs_return_cluster_to_free_space(NULL, last_ptr);

if (loop >= LOOP_NO_EMPTY_SIZE) {
spin_unlock(&last_ptr->refill_lock);
goto unclustered_alloc;
}

/* allocate a cluster in this block group */
ret = btrfs_find_space_cluster(trans, root,
block_group, last_ptr,
Expand Down Expand Up @@ -5392,6 +5395,15 @@ static noinline int find_free_extent(struct btrfs_trans_handle *trans,
}

unclustered_alloc:
spin_lock(&block_group->free_space_ctl->tree_lock);
if (cached &&
block_group->free_space_ctl->free_space <
num_bytes + empty_cluster + empty_size) {
spin_unlock(&block_group->free_space_ctl->tree_lock);
goto loop;
}
spin_unlock(&block_group->free_space_ctl->tree_lock);

offset = btrfs_find_space_for_alloc(block_group, search_start,
num_bytes, empty_size);
/*
Expand Down

0 comments on commit b17221c

Please sign in to comment.