diff options
author | Josef Bacik <jbacik@redhat.com> | 2007-08-29 15:47:34 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-08-29 15:47:34 -0400 |
commit | 58176a9604c5db1784d2c979aea472b3be40b6f0 (patch) | |
tree | a0d887c81b2f174de619dfefca19674a43756971 /fs/btrfs/extent-tree.c | |
parent | b888db2bd7b67f190b32934e6a86181f262ac3ec (diff) |
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.c | 17 |
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); |