summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorJosef Bacik2007-08-29 21:47:34 +0200
committerDavid Woodhouse2007-08-29 21:47:34 +0200
commit58176a9604c5db1784d2c979aea472b3be40b6f0 (patch)
treea0d887c81b2f174de619dfefca19674a43756971 /fs/btrfs/extent-tree.c
parentBtrfs: Add delayed allocation to the extent based page tree code (diff)
downloadkernel-qcow2-linux-58176a9604c5db1784d2c979aea472b3be40b6f0.tar.gz
kernel-qcow2-linux-58176a9604c5db1784d2c979aea472b3be40b6f0.tar.xz
kernel-qcow2-linux-58176a9604c5db1784d2c979aea472b3be40b6f0.zip
Btrfs: Add per-root block accounting and sysfs entries
Signed-off-by: Chris Mason <chris.mason@oracle.com>
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
btrfs_set_extent_refs(ei, refs);
btrfs_mark_buffer_dirty(path->nodes[0]);
if (refs == 0) {
- u64 super_blocks_used;
+ u64 super_blocks_used, root_blocks_used;
if (pin) {
ret = pin_down_block(root, blocknr, 0);
BUG_ON(ret);
}
+ /* block accounting for super block */
super_blocks_used = btrfs_super_blocks_used(&info->super_copy);
btrfs_set_super_blocks_used(&info->super_copy,
super_blocks_used - num_blocks);
+
+ /* block accounting for root item */
+ root_blocks_used = btrfs_root_blocks_used(&root->root_item);
+ btrfs_set_root_blocks_used(&root->root_item,
+ root_blocks_used - num_blocks);
+
ret = btrfs_del_item(trans, extent_root, path);
if (ret) {
return ret;
@@ -1175,7 +1182,7 @@ int btrfs_alloc_extent(struct btrfs_trans_handle *trans,
{
int ret;
int pending_ret;
- u64 super_blocks_used;
+ u64 super_blocks_used, root_blocks_used;
u64 search_start = 0;
struct btrfs_fs_info *info = root->fs_info;
struct btrfs_root *extent_root = info->extent_root;
@@ -1193,10 +1200,16 @@ int btrfs_alloc_extent(struct btrfs_trans_handle *trans,
if (ret)
return ret;
+ /* block accounting for super block */
super_blocks_used = btrfs_super_blocks_used(&info->super_copy);
btrfs_set_super_blocks_used(&info->super_copy, super_blocks_used +
num_blocks);
+ /* block accounting for root item */
+ root_blocks_used = btrfs_root_blocks_used(&root->root_item);
+ btrfs_set_root_blocks_used(&root->root_item, root_blocks_used +
+ num_blocks);
+
if (root == extent_root) {
BUG_ON(num_blocks != 1);
set_radix_bit(&root->fs_info->extent_ins_radix, ins->objectid);