summaryrefslogtreecommitdiff
path: root/volumes.c
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2013-07-03 21:25:13 +0800
committerChris Mason <chris.mason@fusionio.com>2013-07-03 14:06:54 -0400
commitd35300269709a0588b3252373c70eb94df7520fe (patch)
tree23d456e3f13677ff0dadb16848cdd67d3a55fe44 /volumes.c
parent615f2867854c186a37cb2e2e5a2e13e9ed4ab0df (diff)
Btrfs-progs: introduce common insert/search/delete functions for rb-tree
In fact, the code of many rb-tree insert/search/delete functions is similar, so we can abstract them, and implement common functions for rb-tree, and then simplify them. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'volumes.c')
-rw-r--r--volumes.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/volumes.c b/volumes.c
index 0f6a35ba..e8e7907a 100644
--- a/volumes.c
+++ b/volumes.c
@@ -665,12 +665,12 @@ int btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
{
u64 dev_offset;
struct btrfs_fs_info *info = extent_root->fs_info;
- struct btrfs_root *chunk_root = extent_root->fs_info->chunk_root;
+ struct btrfs_root *chunk_root = info->chunk_root;
struct btrfs_stripe *stripes;
struct btrfs_device *device = NULL;
struct btrfs_chunk *chunk;
struct list_head private_devs;
- struct list_head *dev_list = &extent_root->fs_info->fs_devices->devices;
+ struct list_head *dev_list = &info->fs_devices->devices;
struct list_head *cur;
struct map_lookup *map;
int min_stripe_size = 1 * 1024 * 1024;
@@ -890,9 +890,7 @@ again:
map->ce.start = key.offset;
map->ce.size = *num_bytes;
- ret = insert_existing_cache_extent(
- &extent_root->fs_info->mapping_tree.cache_tree,
- &map->ce);
+ ret = insert_cache_extent(&info->mapping_tree.cache_tree, &map->ce);
BUG_ON(ret);
if (type & BTRFS_BLOCK_GROUP_SYSTEM) {
@@ -911,11 +909,11 @@ int btrfs_alloc_data_chunk(struct btrfs_trans_handle *trans,
{
u64 dev_offset;
struct btrfs_fs_info *info = extent_root->fs_info;
- struct btrfs_root *chunk_root = extent_root->fs_info->chunk_root;
+ struct btrfs_root *chunk_root = info->chunk_root;
struct btrfs_stripe *stripes;
struct btrfs_device *device = NULL;
struct btrfs_chunk *chunk;
- struct list_head *dev_list = &extent_root->fs_info->fs_devices->devices;
+ struct list_head *dev_list = &info->fs_devices->devices;
struct list_head *cur;
struct map_lookup *map;
u64 calc_size = 8 * 1024 * 1024;
@@ -998,9 +996,7 @@ int btrfs_alloc_data_chunk(struct btrfs_trans_handle *trans,
map->ce.start = key.offset;
map->ce.size = num_bytes;
- ret = insert_existing_cache_extent(
- &extent_root->fs_info->mapping_tree.cache_tree,
- &map->ce);
+ ret = insert_cache_extent(&info->mapping_tree.cache_tree, &map->ce);
BUG_ON(ret);
kfree(chunk);
@@ -1447,7 +1443,7 @@ int btrfs_bootstrap_super_map(struct btrfs_mapping_tree *map_tree,
map->stripes[i].dev = device;
i++;
}
- ret = insert_existing_cache_extent(&map_tree->cache_tree, &map->ce);
+ ret = insert_cache_extent(&map_tree->cache_tree, &map->ce);
if (ret == -EEXIST) {
struct cache_extent *old;
struct map_lookup *old_map;
@@ -1455,7 +1451,7 @@ int btrfs_bootstrap_super_map(struct btrfs_mapping_tree *map_tree,
old_map = container_of(old, struct map_lookup, ce);
remove_cache_extent(&map_tree->cache_tree, old);
kfree(old_map);
- ret = insert_existing_cache_extent(&map_tree->cache_tree,
+ ret = insert_cache_extent(&map_tree->cache_tree,
&map->ce);
}
BUG_ON(ret);
@@ -1550,7 +1546,7 @@ static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key,
}
}
- ret = insert_existing_cache_extent(&map_tree->cache_tree, &map->ce);
+ ret = insert_cache_extent(&map_tree->cache_tree, &map->ce);
BUG_ON(ret);
return 0;