Skip to content

Commit

Permalink
Btrfs: Don't substract too much from the allocation target (avoid wra…
Browse files Browse the repository at this point in the history
…pping)

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: Chris Mason <chris.mason@oracle.com>
  • Loading branch information
Chris Mason committed Nov 10, 2008
1 parent 5f2cc08 commit 5b7c3fc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -2255,9 +2255,9 @@ static int noinline find_free_extent(struct btrfs_trans_handle *trans,
mutex_unlock(&block_group->alloc_mutex);
new_group_no_lock:
last_wanted = 0;
if (!allowed_chunk_alloc && loop > 0) {
total_needed -= empty_cluster;
empty_cluster = 0;
if (!allowed_chunk_alloc) {
total_needed -= empty_size;
empty_size = 0;
}
/*
* Here's how this works.
Expand All @@ -2277,8 +2277,8 @@ static int noinline find_free_extent(struct btrfs_trans_handle *trans,
loop++;
} else if (loop == 1 && cur == head) {

total_needed -= empty_cluster;
empty_cluster = 0;
total_needed -= empty_size;
empty_size = 0;

if (allowed_chunk_alloc && !chunk_alloc_done) {
up_read(&space_info->groups_sem);
Expand Down

0 comments on commit 5b7c3fc

Please sign in to comment.