Commit 9b90f5135320bc74dc6c9a8c74d69fd4821d9282

Authored by Josef Bacik
Committed by Chris Mason
1 parent e0f5406727

Btrfs: make sure to update total_bitmaps when freeing cache V3

A user reported this bug again where we have more bitmaps than we are supposed
to.  This is because we failed to load the free space cache, but don't update
the ctl->total_bitmaps counter when we remove entries from the tree.  This patch
fixes this problem and we should be good to go again.  Thanks,

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

Showing 1 changed file with 6 additions and 3 deletions Side-by-side Diff

fs/btrfs/free-space-cache.c
... ... @@ -1893,9 +1893,12 @@
1893 1893  
1894 1894 while ((node = rb_last(&ctl->free_space_offset)) != NULL) {
1895 1895 info = rb_entry(node, struct btrfs_free_space, offset_index);
1896   - unlink_free_space(ctl, info);
1897   - kfree(info->bitmap);
1898   - kmem_cache_free(btrfs_free_space_cachep, info);
  1896 + if (!info->bitmap) {
  1897 + unlink_free_space(ctl, info);
  1898 + kmem_cache_free(btrfs_free_space_cachep, info);
  1899 + } else {
  1900 + free_bitmap(ctl, info);
  1901 + }
1899 1902 if (need_resched()) {
1900 1903 spin_unlock(&ctl->tree_lock);
1901 1904 cond_resched();