aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/free-space-cache.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index cb0137e4047..2974c4744d5 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -1843,15 +1843,26 @@ u64 btrfs_alloc_from_cluster(struct btrfs_block_group_cache *block_group,
1843 entry->offset += bytes; 1843 entry->offset += bytes;
1844 entry->bytes -= bytes; 1844 entry->bytes -= bytes;
1845 1845
1846 if (entry->bytes == 0) { 1846 if (entry->bytes == 0)
1847 rb_erase(&entry->offset_index, &cluster->root); 1847 rb_erase(&entry->offset_index, &cluster->root);
1848 kfree(entry);
1849 }
1850 break; 1848 break;
1851 } 1849 }
1852out: 1850out:
1853 spin_unlock(&cluster->lock); 1851 spin_unlock(&cluster->lock);
1854 1852
1853 if (!ret)
1854 return 0;
1855
1856 spin_lock(&block_group->tree_lock);
1857
1858 block_group->free_space -= bytes;
1859 if (entry->bytes == 0) {
1860 block_group->free_extents--;
1861 kfree(entry);
1862 }
1863
1864 spin_unlock(&block_group->tree_lock);
1865
1855 return ret; 1866 return ret;
1856} 1867}
1857 1868