diff options
-rw-r--r-- | fs/btrfs/extent-tree.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 813c6bb96c9a..db0b23b14f20 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -5285,15 +5285,10 @@ alloc: | |||
5285 | spin_unlock(&block_group->free_space_ctl->tree_lock); | 5285 | spin_unlock(&block_group->free_space_ctl->tree_lock); |
5286 | 5286 | ||
5287 | /* | 5287 | /* |
5288 | * Ok we want to try and use the cluster allocator, so lets look | 5288 | * Ok we want to try and use the cluster allocator, so |
5289 | * there, unless we are on LOOP_NO_EMPTY_SIZE, since we will | 5289 | * lets look there |
5290 | * have tried the cluster allocator plenty of times at this | ||
5291 | * point and not have found anything, so we are likely way too | ||
5292 | * fragmented for the clustering stuff to find anything, so lets | ||
5293 | * just skip it and let the allocator find whatever block it can | ||
5294 | * find | ||
5295 | */ | 5290 | */ |
5296 | if (last_ptr && loop < LOOP_NO_EMPTY_SIZE) { | 5291 | if (last_ptr) { |
5297 | /* | 5292 | /* |
5298 | * the refill lock keeps out other | 5293 | * the refill lock keeps out other |
5299 | * people trying to start a new cluster | 5294 | * people trying to start a new cluster |
@@ -5342,6 +5337,20 @@ alloc: | |||
5342 | } | 5337 | } |
5343 | spin_unlock(&last_ptr->lock); | 5338 | spin_unlock(&last_ptr->lock); |
5344 | refill_cluster: | 5339 | refill_cluster: |
5340 | /* If we are on LOOP_NO_EMPTY_SIZE, we can't | ||
5341 | * set up a new clusters, so lets just skip it | ||
5342 | * and let the allocator find whatever block | ||
5343 | * it can find. If we reach this point, we | ||
5344 | * will have tried the cluster allocator | ||
5345 | * plenty of times and not have found | ||
5346 | * anything, so we are likely way too | ||
5347 | * fragmented for the clustering stuff to find | ||
5348 | * anything. */ | ||
5349 | if (loop >= LOOP_NO_EMPTY_SIZE) { | ||
5350 | spin_unlock(&last_ptr->refill_lock); | ||
5351 | goto unclustered_alloc; | ||
5352 | } | ||
5353 | |||
5345 | /* | 5354 | /* |
5346 | * this cluster didn't work out, free it and | 5355 | * this cluster didn't work out, free it and |
5347 | * start over | 5356 | * start over |
@@ -5389,6 +5398,7 @@ refill_cluster: | |||
5389 | goto loop; | 5398 | goto loop; |
5390 | } | 5399 | } |
5391 | 5400 | ||
5401 | unclustered_alloc: | ||
5392 | offset = btrfs_find_space_for_alloc(block_group, search_start, | 5402 | offset = btrfs_find_space_for_alloc(block_group, search_start, |
5393 | num_bytes, empty_size); | 5403 | num_bytes, empty_size); |
5394 | /* | 5404 | /* |