summaryrefslogtreecommitdiff
path: root/extent-tree.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@redhat.com>2007-08-29 15:56:44 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-08-29 15:56:44 -0400
commitffaff17911e4eb0c6177aa4661f90734f7af7b54 (patch)
tree2397e812d960a76464f987465b9663e1152b5875 /extent-tree.c
parentdbd1848d1ffa2e4e00b49e7766c46f0ba512a8aa (diff)
btrfs-progs support for root block accounting
This adds support for keeping track of the number of blocks used by root_item's. This makes it so that mkfs lays down the "default" subvol with the correct block accounting in place. Thank you,
Diffstat (limited to 'extent-tree.c')
-rw-r--r--extent-tree.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/extent-tree.c b/extent-tree.c
index 466ed206..8b91df53 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -252,7 +252,7 @@ static int finish_current_insert(struct btrfs_trans_handle *trans, struct
struct btrfs_extent_item extent_item;
int i;
int ret;
- u64 super_blocks_used;
+ u64 super_blocks_used, root_blocks_used;
struct btrfs_fs_info *info = extent_root->fs_info;
btrfs_set_extent_refs(&extent_item, 1);
@@ -267,6 +267,9 @@ static int finish_current_insert(struct btrfs_trans_handle *trans, struct
super_blocks_used = btrfs_super_blocks_used(info->disk_super);
btrfs_set_super_blocks_used(info->disk_super,
super_blocks_used + 1);
+ root_blocks_used = btrfs_root_blocks_used(&extent_root->root_item);
+ btrfs_set_root_blocks_used(&extent_root->root_item,
+ root_blocks_used + 1);
ret = btrfs_insert_item(trans, extent_root, &ins, &extent_item,
sizeof(extent_item));
if (ret) {
@@ -314,7 +317,7 @@ static int __free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
refs = btrfs_extent_refs(ei) - 1;
btrfs_set_extent_refs(ei, refs);
if (refs == 0) {
- u64 super_blocks_used;
+ u64 super_blocks_used, root_blocks_used;
if (pin) {
int err;
unsigned long bl = blocknr;
@@ -327,6 +330,10 @@ static int __free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
super_blocks_used = btrfs_super_blocks_used(info->disk_super);
btrfs_set_super_blocks_used(info->disk_super,
super_blocks_used - num_blocks);
+ 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 (!pin && extent_root->fs_info->last_insert.objectid >
blocknr)
@@ -527,7 +534,7 @@ static int alloc_extent(struct btrfs_trans_handle *trans, struct btrfs_root
{
int ret;
int pending_ret;
- u64 super_blocks_used;
+ u64 super_blocks_used, root_blocks_used;
struct btrfs_fs_info *info = root->fs_info;
struct btrfs_root *extent_root = info->extent_root;
struct btrfs_extent_item extent_item;
@@ -553,6 +560,10 @@ static int alloc_extent(struct btrfs_trans_handle *trans, struct btrfs_root
super_blocks_used = btrfs_super_blocks_used(info->disk_super);
btrfs_set_super_blocks_used(info->disk_super, super_blocks_used +
num_blocks);
+ 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_insert_item(trans, extent_root, ins, &extent_item,
sizeof(extent_item));