From: Chris Mason Date: Mon, 10 Nov 2008 12:26:33 +0000 (-0500) Subject: Btrfs: Don't substract too much from the allocation target (avoid wrapping) X-Git-Tag: v2.6.29-rc1~27^2~9^2~55^2~33 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=5b7c3fcc46b5deb8a368d5319cf87c78c2df65fe;p=linux-2.6-omap-h63xx.git 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: Chris Mason --- diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index b92e92c29e3..2451717d36d 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2255,9 +2255,9 @@ new_group: 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. @@ -2277,8 +2277,8 @@ new_group_no_lock: 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);