aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2010-11-09 01:55:34 -0500
committerLi Zefan <lizf@cn.fujitsu.com>2011-01-26 12:04:46 -0500
commit5e71b5d5ec07e4b3fb4c78c4e4b108ff667f123f (patch)
tree4fdb07b18c010f132d10b074bff60226b6517a08 /fs
parent70b7da304f9f9bbf1566085155895e32e775a745 (diff)
btrfs: Update stats when allocating from a cluster
When allocating extent entry from a cluster, we should update the free_space and free_extents fields of the block group. Reviewed-by: Josef Bacik <josef@redhat.com> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
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