aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index c31e84d42653..ff3f7c2be605 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -858,16 +858,23 @@ static int __free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
858 btrfs_set_extent_refs(ei, refs); 858 btrfs_set_extent_refs(ei, refs);
859 btrfs_mark_buffer_dirty(path->nodes[0]); 859 btrfs_mark_buffer_dirty(path->nodes[0]);
860 if (refs == 0) { 860 if (refs == 0) {
861 u64 super_blocks_used; 861 u64 super_blocks_used, root_blocks_used;
862 862
863 if (pin) { 863 if (pin) {
864 ret = pin_down_block(root, blocknr, 0); 864 ret = pin_down_block(root, blocknr, 0);
865 BUG_ON(ret); 865 BUG_ON(ret);
866 } 866 }
867 867
868 /* block accounting for super block */
868 super_blocks_used = btrfs_super_blocks_used(&info->super_copy); 869 super_blocks_used = btrfs_super_blocks_used(&info->super_copy);
869 btrfs_set_super_blocks_used(&info->super_copy, 870 btrfs_set_super_blocks_used(&info->super_copy,
870 super_blocks_used - num_blocks); 871 super_blocks_used - num_blocks);
872
873 /* block accounting for root item */
874 root_blocks_used = btrfs_root_blocks_used(&root->root_item);
875 btrfs_set_root_blocks_used(&root->root_item,
876 root_blocks_used - num_blocks);
877
871 ret = btrfs_del_item(trans, extent_root, path); 878 ret = btrfs_del_item(trans, extent_root, path);
872 if (ret) { 879 if (ret) {
873 return ret; 880 return ret;
@@ -1175,7 +1182,7 @@ int btrfs_alloc_extent(struct btrfs_trans_handle *trans,
1175{ 1182{
1176 int ret; 1183 int ret;
1177 int pending_ret; 1184 int pending_ret;
1178 u64 super_blocks_used; 1185 u64 super_blocks_used, root_blocks_used;
1179 u64 search_start = 0; 1186 u64 search_start = 0;
1180 struct btrfs_fs_info *info = root->fs_info; 1187 struct btrfs_fs_info *info = root->fs_info;
1181 struct btrfs_root *extent_root = info->extent_root; 1188 struct btrfs_root *extent_root = info->extent_root;
@@ -1193,10 +1200,16 @@ int btrfs_alloc_extent(struct btrfs_trans_handle *trans,
1193 if (ret) 1200 if (ret)
1194 return ret; 1201 return ret;
1195 1202
1203 /* block accounting for super block */
1196 super_blocks_used = btrfs_super_blocks_used(&info->super_copy); 1204 super_blocks_used = btrfs_super_blocks_used(&info->super_copy);
1197 btrfs_set_super_blocks_used(&info->super_copy, super_blocks_used + 1205 btrfs_set_super_blocks_used(&info->super_copy, super_blocks_used +
1198 num_blocks); 1206 num_blocks);
1199 1207
1208 /* block accounting for root item */
1209 root_blocks_used = btrfs_root_blocks_used(&root->root_item);
1210 btrfs_set_root_blocks_used(&root->root_item, root_blocks_used +
1211 num_blocks);
1212
1200 if (root == extent_root) { 1213 if (root == extent_root) {
1201 BUG_ON(num_blocks != 1); 1214 BUG_ON(num_blocks != 1);
1202 set_radix_bit(&root->fs_info->extent_ins_radix, ins->objectid); 1215 set_radix_bit(&root->fs_info->extent_ins_radix, ins->objectid);