Btrfs: free bitmaps properly when evicting the cache

If our space cache is wrong, we do the right thing and free up everything that
we loaded, however we don't reset the total_bitmaps counter or the thresholds or
anything. So in btrfs_remove_free_space_cache make sure to call free_bitmap()
if it's a bitmap, this will keep us from panicing when we check to make sure we
don't have too many bitmaps. Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>

authored by Josef Bacik and committed by Chris Mason a4f0162f f789b684

+7 -4
+7 -4
fs/btrfs/free-space-cache.c
··· 1768 1768 1769 1769 while ((node = rb_last(&block_group->free_space_offset)) != NULL) { 1770 1770 info = rb_entry(node, struct btrfs_free_space, offset_index); 1771 - unlink_free_space(block_group, info); 1772 - if (info->bitmap) 1773 - kfree(info->bitmap); 1774 - kmem_cache_free(btrfs_free_space_cachep, info); 1771 + if (!info->bitmap) { 1772 + unlink_free_space(block_group, info); 1773 + kmem_cache_free(btrfs_free_space_cachep, info); 1774 + } else { 1775 + free_bitmap(block_group, info); 1776 + } 1777 + 1775 1778 if (need_resched()) { 1776 1779 spin_unlock(&block_group->tree_lock); 1777 1780 cond_resched();