Commit 5b7c3fcc authored by Chris Mason's avatar Chris Mason

Btrfs: Don't substract too much from the allocation target (avoid wrapping)

When metadata allocation clustering has to fall back to unclustered
allocs because large free areas could not be found, it was sometimes
substracting too much from the total bytes to allocate.  This would
make it wrap below zero.
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 5f2cc086
...@@ -2255,9 +2255,9 @@ static int noinline find_free_extent(struct btrfs_trans_handle *trans, ...@@ -2255,9 +2255,9 @@ static int noinline find_free_extent(struct btrfs_trans_handle *trans,
mutex_unlock(&block_group->alloc_mutex); mutex_unlock(&block_group->alloc_mutex);
new_group_no_lock: new_group_no_lock:
last_wanted = 0; last_wanted = 0;
if (!allowed_chunk_alloc && loop > 0) { if (!allowed_chunk_alloc) {
total_needed -= empty_cluster; total_needed -= empty_size;
empty_cluster = 0; empty_size = 0;
} }
/* /*
* Here's how this works. * Here's how this works.
...@@ -2277,8 +2277,8 @@ static int noinline find_free_extent(struct btrfs_trans_handle *trans, ...@@ -2277,8 +2277,8 @@ static int noinline find_free_extent(struct btrfs_trans_handle *trans,
loop++; loop++;
} else if (loop == 1 && cur == head) { } else if (loop == 1 && cur == head) {
total_needed -= empty_cluster; total_needed -= empty_size;
empty_cluster = 0; empty_size = 0;
if (allowed_chunk_alloc && !chunk_alloc_done) { if (allowed_chunk_alloc && !chunk_alloc_done) {
up_read(&space_info->groups_sem); up_read(&space_info->groups_sem);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment