aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.c
diff options
context:
space:
mode:
authorYan, Zheng <zheng.yan@oracle.com>2009-11-12 04:36:50 -0500
committerChris Mason <chris.mason@oracle.com>2009-12-17 12:33:35 -0500
commit86b9f2eca5e0984145e3c7698a7cd6dd65c2a93f (patch)
tree75dd0a52848b6f5396023f811f1a602f62b9d34e /fs/btrfs/ctree.c
parent55ef68990029fcd8d04d42fc184aa7fb18cf309e (diff)
Btrfs: Fix per root used space accounting
The bytes_used field in root item was originally planned to trace the amount of used data and tree blocks. But it never worked right since we can't trace freeing of data accurately. This patch changes it to only trace the amount of tree blocks. Signed-off-by: Yan Zheng <zheng.yan@oracle.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.c')
-rw-r--r--fs/btrfs/ctree.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 9d4ba3470c17..c4bc570a396e 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -456,9 +456,8 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
456 extent_buffer_get(cow); 456 extent_buffer_get(cow);
457 spin_unlock(&root->node_lock); 457 spin_unlock(&root->node_lock);
458 458
459 btrfs_free_extent(trans, root, buf->start, buf->len, 459 btrfs_free_tree_block(trans, root, buf->start, buf->len,
460 parent_start, root->root_key.objectid, 460 parent_start, root->root_key.objectid, level);
461 level, 0);
462 free_extent_buffer(buf); 461 free_extent_buffer(buf);
463 add_root_to_dirty_list(root); 462 add_root_to_dirty_list(root);
464 } else { 463 } else {
@@ -473,9 +472,8 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
473 btrfs_set_node_ptr_generation(parent, parent_slot, 472 btrfs_set_node_ptr_generation(parent, parent_slot,
474 trans->transid); 473 trans->transid);
475 btrfs_mark_buffer_dirty(parent); 474 btrfs_mark_buffer_dirty(parent);
476 btrfs_free_extent(trans, root, buf->start, buf->len, 475 btrfs_free_tree_block(trans, root, buf->start, buf->len,
477 parent_start, root->root_key.objectid, 476 parent_start, root->root_key.objectid, level);
478 level, 0);
479 } 477 }
480 if (unlock_orig) 478 if (unlock_orig)
481 btrfs_tree_unlock(buf); 479 btrfs_tree_unlock(buf);
@@ -1035,8 +1033,8 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
1035 btrfs_tree_unlock(mid); 1033 btrfs_tree_unlock(mid);
1036 /* once for the path */ 1034 /* once for the path */
1037 free_extent_buffer(mid); 1035 free_extent_buffer(mid);
1038 ret = btrfs_free_extent(trans, root, mid->start, mid->len, 1036 ret = btrfs_free_tree_block(trans, root, mid->start, mid->len,
1039 0, root->root_key.objectid, level, 1); 1037 0, root->root_key.objectid, level);
1040 /* once for the root ptr */ 1038 /* once for the root ptr */
1041 free_extent_buffer(mid); 1039 free_extent_buffer(mid);
1042 return ret; 1040 return ret;
@@ -1100,10 +1098,10 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
1100 1); 1098 1);
1101 if (wret) 1099 if (wret)
1102 ret = wret; 1100 ret = wret;
1103 wret = btrfs_free_extent(trans, root, bytenr, 1101 wret = btrfs_free_tree_block(trans, root,
1104 blocksize, 0, 1102 bytenr, blocksize, 0,
1105 root->root_key.objectid, 1103 root->root_key.objectid,
1106 level, 0); 1104 level);
1107 if (wret) 1105 if (wret)
1108 ret = wret; 1106 ret = wret;
1109 } else { 1107 } else {
@@ -1148,9 +1146,8 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
1148 wret = del_ptr(trans, root, path, level + 1, pslot); 1146 wret = del_ptr(trans, root, path, level + 1, pslot);
1149 if (wret) 1147 if (wret)
1150 ret = wret; 1148 ret = wret;
1151 wret = btrfs_free_extent(trans, root, bytenr, blocksize, 1149 wret = btrfs_free_tree_block(trans, root, bytenr, blocksize,
1152 0, root->root_key.objectid, 1150 0, root->root_key.objectid, level);
1153 level, 0);
1154 if (wret) 1151 if (wret)
1155 ret = wret; 1152 ret = wret;
1156 } else { 1153 } else {
@@ -3794,8 +3791,8 @@ static noinline int btrfs_del_leaf(struct btrfs_trans_handle *trans,
3794 */ 3791 */
3795 btrfs_unlock_up_safe(path, 0); 3792 btrfs_unlock_up_safe(path, 0);
3796 3793
3797 ret = btrfs_free_extent(trans, root, leaf->start, leaf->len, 3794 ret = btrfs_free_tree_block(trans, root, leaf->start, leaf->len,
3798 0, root->root_key.objectid, 0, 0); 3795 0, root->root_key.objectid, 0);
3799 return ret; 3796 return ret;
3800} 3797}
3801/* 3798/*