summaryrefslogtreecommitdiff
path: root/free-space-tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'free-space-tree.c')
-rw-r--r--free-space-tree.c102
1 files changed, 1 insertions, 101 deletions
diff --git a/free-space-tree.c b/free-space-tree.c
index 6ef5792..c854768 100644
--- a/free-space-tree.c
+++ b/free-space-tree.c
@@ -20,39 +20,11 @@
#include "disk-io.h"
#include "free-space-cache.h"
#include "free-space-tree.h"
+#include "volumes.h"
#include "transaction.h"
#include "bitops.h"
#include "internal.h"
-static inline void set_free_space_tree_thresholds(struct btrfs_block_group_cache *cache,
- u64 sectorsize)
-{
- u32 bitmap_range;
- size_t bitmap_size;
- u64 num_bitmaps, total_bitmap_size;
-
- /*
- * We convert to bitmaps when the disk space required for using extents
- * exceeds that required for using bitmaps.
- */
- bitmap_range = sectorsize * BTRFS_FREE_SPACE_BITMAP_BITS;
- num_bitmaps = div_u64(cache->key.offset + bitmap_range - 1,
- bitmap_range);
- bitmap_size = sizeof(struct btrfs_item) + BTRFS_FREE_SPACE_BITMAP_SIZE;
- total_bitmap_size = num_bitmaps * bitmap_size;
- cache->bitmap_high_thresh = div_u64(total_bitmap_size,
- sizeof(struct btrfs_item));
-
- /*
- * We allow for a small buffer between the high threshold and low
- * threshold to avoid thrashing back and forth between the two formats.
- */
- if (cache->bitmap_high_thresh > 100)
- cache->bitmap_low_thresh = cache->bitmap_high_thresh - 100;
- else
- cache->bitmap_low_thresh = 0;
-}
-
static struct btrfs_free_space_info *
search_free_space_info(struct btrfs_trans_handle *trans,
struct btrfs_fs_info *fs_info,
@@ -1420,78 +1392,6 @@ out:
return ret;
}
-static struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
- struct btrfs_fs_info *fs_info,
- u64 objectid)
-{
- struct extent_buffer *leaf;
- struct btrfs_root *tree_root = fs_info->tree_root;
- struct btrfs_root *root;
- struct btrfs_key key;
- int ret = 0;
-
- root = kzalloc(sizeof(*root), GFP_KERNEL);
- if (!root)
- return ERR_PTR(-ENOMEM);
-
- btrfs_setup_root(root, fs_info, objectid);
- root->root_key.objectid = objectid;
- root->root_key.type = BTRFS_ROOT_ITEM_KEY;
- root->root_key.offset = 0;
-
- leaf = btrfs_alloc_free_block(trans, root, fs_info->nodesize, objectid,
- NULL, 0, 0, 0);
- if (IS_ERR(leaf)) {
- ret = PTR_ERR(leaf);
- leaf = NULL;
- goto fail;
- }
-
- memset_extent_buffer(leaf, 0, 0, sizeof(struct btrfs_header));
- btrfs_set_header_bytenr(leaf, leaf->start);
- btrfs_set_header_generation(leaf, trans->transid);
- btrfs_set_header_backref_rev(leaf, BTRFS_MIXED_BACKREF_REV);
- btrfs_set_header_owner(leaf, objectid);
- root->node = leaf;
- write_extent_buffer(leaf, fs_info->fsid, btrfs_header_fsid(), BTRFS_FSID_SIZE);
- write_extent_buffer(leaf, fs_info->chunk_tree_uuid,
- btrfs_header_chunk_tree_uuid(leaf),
- BTRFS_UUID_SIZE);
- btrfs_mark_buffer_dirty(leaf);
-
- extent_buffer_get(root->node);
- root->commit_root = root->node;
- root->track_dirty = 1;
-
- root->root_item.flags = 0;
- root->root_item.byte_limit = 0;
- btrfs_set_root_bytenr(&root->root_item, leaf->start);
- btrfs_set_root_generation(&root->root_item, trans->transid);
- btrfs_set_root_level(&root->root_item, 0);
- btrfs_set_root_refs(&root->root_item, 1);
- btrfs_set_root_used(&root->root_item, leaf->len);
- btrfs_set_root_last_snapshot(&root->root_item, 0);
- btrfs_set_root_dirid(&root->root_item, 0);
- memset(root->root_item.uuid, 0, BTRFS_UUID_SIZE);
- root->root_item.drop_level = 0;
-
- key.objectid = objectid;
- key.type = BTRFS_ROOT_ITEM_KEY;
- key.offset = 0;
- ret = btrfs_insert_root(trans, tree_root, &key, &root->root_item);
- if (ret)
- goto fail;
-
- return root;
-
-fail:
- if (leaf)
- free_extent_buffer(leaf);
-
- kfree(root);
- return ERR_PTR(ret);
-}
-
#define btrfs_set_fs_compat_ro(__fs_info, opt) \
__btrfs_set_fs_compat_ro((__fs_info), BTRFS_FEATURE_COMPAT_RO_##opt)