aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/transaction.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/transaction.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/transaction.c')
-rw-r--r--fs/btrfs/transaction.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 75b31caade29..b2acc79f1b34 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -501,13 +501,16 @@ static int update_cowonly_root(struct btrfs_trans_handle *trans,
501{ 501{
502 int ret; 502 int ret;
503 u64 old_root_bytenr; 503 u64 old_root_bytenr;
504 u64 old_root_used;
504 struct btrfs_root *tree_root = root->fs_info->tree_root; 505 struct btrfs_root *tree_root = root->fs_info->tree_root;
505 506
507 old_root_used = btrfs_root_used(&root->root_item);
506 btrfs_write_dirty_block_groups(trans, root); 508 btrfs_write_dirty_block_groups(trans, root);
507 509
508 while (1) { 510 while (1) {
509 old_root_bytenr = btrfs_root_bytenr(&root->root_item); 511 old_root_bytenr = btrfs_root_bytenr(&root->root_item);
510 if (old_root_bytenr == root->node->start) 512 if (old_root_bytenr == root->node->start &&
513 old_root_used == btrfs_root_used(&root->root_item))
511 break; 514 break;
512 515
513 btrfs_set_root_node(&root->root_item, root->node); 516 btrfs_set_root_node(&root->root_item, root->node);
@@ -516,6 +519,7 @@ static int update_cowonly_root(struct btrfs_trans_handle *trans,
516 &root->root_item); 519 &root->root_item);
517 BUG_ON(ret); 520 BUG_ON(ret);
518 521
522 old_root_used = btrfs_root_used(&root->root_item);
519 ret = btrfs_write_dirty_block_groups(trans, root); 523 ret = btrfs_write_dirty_block_groups(trans, root);
520 BUG_ON(ret); 524 BUG_ON(ret);
521 } 525 }