• Home
  • Raw
  • Download

Lines Matching refs:root

51 	struct btrfs_root *root;  member
282 static struct rb_node *tree_insert(struct rb_root *root, u64 bytenr, in tree_insert() argument
285 struct rb_node **p = &root->rb_node; in tree_insert()
302 rb_insert_color(node, root); in tree_insert()
306 static struct rb_node *tree_search(struct rb_root *root, u64 bytenr) in tree_search() argument
308 struct rb_node *n = root->rb_node; in tree_search()
330 if (bnode->root) in backref_tree_panic()
331 fs_info = bnode->root->fs_info; in backref_tree_panic()
520 static bool reloc_root_is_dead(struct btrfs_root *root) in reloc_root_is_dead() argument
528 if (test_bit(BTRFS_ROOT_DEAD_RELOC_TREE, &root->state)) in reloc_root_is_dead()
540 static bool have_reloc_root(struct btrfs_root *root) in have_reloc_root() argument
542 if (reloc_root_is_dead(root)) in have_reloc_root()
544 if (!root->reloc_root) in have_reloc_root()
549 static int should_ignore_root(struct btrfs_root *root) in should_ignore_root() argument
553 if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state)) in should_ignore_root()
557 if (reloc_root_is_dead(root)) in should_ignore_root()
560 reloc_root = root->reloc_root; in should_ignore_root()
565 root->fs_info->running_transaction->transid - 1) in should_ignore_root()
583 struct btrfs_root *root = NULL; in find_reloc_root() local
589 root = (struct btrfs_root *)node->data; in find_reloc_root()
592 return root; in find_reloc_root()
690 struct btrfs_root *root; in build_backref_tree() local
837 root = find_reloc_root(rc, cur->bytenr); in build_backref_tree()
838 ASSERT(root); in build_backref_tree()
839 cur->root = root; in build_backref_tree()
889 root = read_fs_root(rc->extent_root->fs_info, key.offset); in build_backref_tree()
890 if (IS_ERR(root)) { in build_backref_tree()
891 err = PTR_ERR(root); in build_backref_tree()
895 if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state)) in build_backref_tree()
898 if (btrfs_root_level(&root->root_item) == cur->level) { in build_backref_tree()
900 ASSERT(btrfs_root_bytenr(&root->root_item) == in build_backref_tree()
902 if (should_ignore_root(root)) in build_backref_tree()
905 cur->root = root; in build_backref_tree()
915 ret = btrfs_search_slot(NULL, root, node_key, path2, 0, 0); in build_backref_tree()
927 btrfs_err(root->fs_info, in build_backref_tree()
930 root->root_key.objectid, in build_backref_tree()
942 ASSERT(btrfs_root_bytenr(&root->root_item) == in build_backref_tree()
944 if (should_ignore_root(root)) in build_backref_tree()
947 lower->root = root; in build_backref_tree()
970 &root->state)) in build_backref_tree()
977 if (btrfs_block_can_be_shared(root, eb)) in build_backref_tree()
1247 new_node->root = dest; in clone_backref_node()
1290 static int __must_check __add_reloc_root(struct btrfs_root *root) in __add_reloc_root() argument
1292 struct btrfs_fs_info *fs_info = root->fs_info; in __add_reloc_root()
1301 node->bytenr = root->node->start; in __add_reloc_root()
1302 node->data = root; in __add_reloc_root()
1314 list_add_tail(&root->root_list, &rc->reloc_roots); in __add_reloc_root()
1322 static void __del_reloc_root(struct btrfs_root *root) in __del_reloc_root() argument
1324 struct btrfs_fs_info *fs_info = root->fs_info; in __del_reloc_root()
1329 if (rc && root->node) { in __del_reloc_root()
1332 root->node->start); in __del_reloc_root()
1340 BUG_ON((struct btrfs_root *)node->data != root); in __del_reloc_root()
1344 list_del_init(&root->root_list); in __del_reloc_root()
1353 static int __update_reloc_root(struct btrfs_root *root, u64 new_bytenr) in __update_reloc_root() argument
1355 struct btrfs_fs_info *fs_info = root->fs_info; in __update_reloc_root()
1362 root->node->start); in __update_reloc_root()
1371 BUG_ON((struct btrfs_root *)node->data != root); in __update_reloc_root()
1384 struct btrfs_root *root, u64 objectid) in create_reloc_root() argument
1386 struct btrfs_fs_info *fs_info = root->fs_info; in create_reloc_root()
1400 if (root->root_key.objectid == objectid) { in create_reloc_root()
1404 ret = btrfs_copy_root(trans, root, root->commit_root, &eb, in create_reloc_root()
1415 commit_root_gen = btrfs_header_generation(root->commit_root); in create_reloc_root()
1416 btrfs_set_root_last_snapshot(&root->root_item, commit_root_gen); in create_reloc_root()
1425 ret = btrfs_copy_root(trans, root, root->node, &eb, in create_reloc_root()
1430 memcpy(root_item, &root->root_item, sizeof(*root_item)); in create_reloc_root()
1435 if (root->root_key.objectid == objectid) { in create_reloc_root()
1461 struct btrfs_root *root) in btrfs_init_reloc_root() argument
1463 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_init_reloc_root()
1474 if (reloc_root_is_dead(root)) in btrfs_init_reloc_root()
1477 if (root->reloc_root) { in btrfs_init_reloc_root()
1478 reloc_root = root->reloc_root; in btrfs_init_reloc_root()
1484 root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) in btrfs_init_reloc_root()
1492 reloc_root = create_reloc_root(trans, root, root->root_key.objectid); in btrfs_init_reloc_root()
1498 root->reloc_root = reloc_root; in btrfs_init_reloc_root()
1506 struct btrfs_root *root) in btrfs_update_reloc_root() argument
1508 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_update_reloc_root()
1513 if (!have_reloc_root(root)) in btrfs_update_reloc_root()
1516 reloc_root = root->reloc_root; in btrfs_update_reloc_root()
1522 set_bit(BTRFS_ROOT_DEAD_RELOC_TREE, &root->state); in btrfs_update_reloc_root()
1549 static struct inode *find_next_inode(struct btrfs_root *root, u64 objectid) in find_next_inode() argument
1556 spin_lock(&root->inode_lock); in find_next_inode()
1558 node = root->inode_tree.rb_node; in find_next_inode()
1585 spin_unlock(&root->inode_lock); in find_next_inode()
1590 if (cond_resched_lock(&root->inode_lock)) in find_next_inode()
1595 spin_unlock(&root->inode_lock); in find_next_inode()
1614 struct btrfs_root *root = BTRFS_I(reloc_inode)->root; in get_new_location() local
1625 ret = btrfs_lookup_file_extent(NULL, root, path, in get_new_location()
1662 struct btrfs_root *root, in replace_file_extents() argument
1665 struct btrfs_fs_info *fs_info = root->fs_info; in replace_file_extents()
1684 if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) in replace_file_extents()
1712 if (root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID) { in replace_file_extents()
1714 inode = find_next_inode(root, key.objectid); in replace_file_extents()
1718 inode = find_next_inode(root, key.objectid); in replace_file_extents()
1755 ref.real_root = root->root_key.objectid; in replace_file_extents()
1766 ref.real_root = root->root_key.objectid; in replace_file_extents()
2013 int walk_up_reloc_tree(struct btrfs_root *root, struct btrfs_path *path, in walk_up_reloc_tree() argument
2021 last_snapshot = btrfs_root_last_snapshot(&root->root_item); in walk_up_reloc_tree()
2050 int walk_down_reloc_tree(struct btrfs_root *root, struct btrfs_path *path, in walk_down_reloc_tree() argument
2053 struct btrfs_fs_info *fs_info = root->fs_info; in walk_down_reloc_tree()
2061 last_snapshot = btrfs_root_last_snapshot(&root->root_item); in walk_down_reloc_tree()
2106 static int invalidate_extent_cache(struct btrfs_root *root, in invalidate_extent_cache() argument
2110 struct btrfs_fs_info *fs_info = root->fs_info; in invalidate_extent_cache()
2124 inode = find_next_inode(root, objectid); in invalidate_extent_cache()
2198 struct btrfs_root *root) in insert_dirty_subvol() argument
2200 struct btrfs_root *reloc_root = root->reloc_root; in insert_dirty_subvol()
2204 ASSERT(root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID); in insert_dirty_subvol()
2212 btrfs_update_reloc_root(trans, root); in insert_dirty_subvol()
2214 if (list_empty(&root->reloc_dirty_list)) { in insert_dirty_subvol()
2215 btrfs_grab_fs_root(root); in insert_dirty_subvol()
2216 list_add_tail(&root->reloc_dirty_list, &rc->dirty_subvol_roots); in insert_dirty_subvol()
2222 struct btrfs_root *root; in clean_dirty_subvols() local
2227 list_for_each_entry_safe(root, next, &rc->dirty_subvol_roots, in clean_dirty_subvols()
2229 if (root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID) { in clean_dirty_subvols()
2231 struct btrfs_root *reloc_root = root->reloc_root; in clean_dirty_subvols()
2233 list_del_init(&root->reloc_dirty_list); in clean_dirty_subvols()
2234 root->reloc_root = NULL; in clean_dirty_subvols()
2246 clear_bit(BTRFS_ROOT_DEAD_RELOC_TREE, &root->state); in clean_dirty_subvols()
2247 btrfs_put_fs_root(root); in clean_dirty_subvols()
2250 ret2 = btrfs_drop_snapshot(root, NULL, 0, 1); in clean_dirty_subvols()
2263 struct btrfs_root *root) in merge_reloc_root() argument
2285 reloc_root = root->reloc_root; in merge_reloc_root()
2317 ret = btrfs_block_rsv_refill(root, rc->block_rsv, min_reserved, in merge_reloc_root()
2323 trans = btrfs_start_transaction(root, 0); in merge_reloc_root()
2346 ret = replace_path(trans, rc, root, reloc_root, path, in merge_reloc_root()
2380 invalidate_extent_cache(root, &key, &next_key); in merge_reloc_root()
2387 leaf = btrfs_lock_root_node(root); in merge_reloc_root()
2388 ret = btrfs_cow_block(trans, root, leaf, NULL, 0, &leaf); in merge_reloc_root()
2397 insert_dirty_subvol(trans, rc, root); in merge_reloc_root()
2405 invalidate_extent_cache(root, &key, &next_key); in merge_reloc_root()
2413 struct btrfs_root *root = rc->extent_root; in prepare_to_merge() local
2414 struct btrfs_fs_info *fs_info = root->fs_info; in prepare_to_merge()
2429 ret = btrfs_block_rsv_add(root, rc->block_rsv, num_bytes, in prepare_to_merge()
2459 root = read_fs_root(fs_info, reloc_root->root_key.offset); in prepare_to_merge()
2460 BUG_ON(IS_ERR(root)); in prepare_to_merge()
2461 BUG_ON(root->reloc_root != reloc_root); in prepare_to_merge()
2469 btrfs_update_reloc_root(trans, root); in prepare_to_merge()
2503 struct btrfs_root *root; in merge_reloc_roots() local
2509 root = rc->extent_root; in merge_reloc_roots()
2527 root = read_fs_root(fs_info, in merge_reloc_roots()
2529 BUG_ON(IS_ERR(root)); in merge_reloc_roots()
2530 BUG_ON(root->reloc_root != reloc_root); in merge_reloc_roots()
2532 ret = merge_reloc_root(rc, root); in merge_reloc_roots()
2583 struct btrfs_root *root; in record_reloc_root_in_trans() local
2588 root = read_fs_root(fs_info, reloc_root->root_key.offset); in record_reloc_root_in_trans()
2589 BUG_ON(IS_ERR(root)); in record_reloc_root_in_trans()
2590 BUG_ON(root->reloc_root != reloc_root); in record_reloc_root_in_trans()
2592 return btrfs_record_root_in_trans(trans, root); in record_reloc_root_in_trans()
2602 struct btrfs_root *root; in select_reloc_root() local
2609 root = next->root; in select_reloc_root()
2610 BUG_ON(!root); in select_reloc_root()
2611 BUG_ON(!test_bit(BTRFS_ROOT_REF_COWS, &root->state)); in select_reloc_root()
2613 if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) { in select_reloc_root()
2614 record_reloc_root_in_trans(trans, root); in select_reloc_root()
2618 btrfs_record_root_in_trans(trans, root); in select_reloc_root()
2619 root = root->reloc_root; in select_reloc_root()
2621 if (next->new_bytenr != root->node->start) { in select_reloc_root()
2624 next->new_bytenr = root->node->start; in select_reloc_root()
2625 next->root = root; in select_reloc_root()
2633 root = NULL; in select_reloc_root()
2638 if (!root) in select_reloc_root()
2649 return root; in select_reloc_root()
2662 struct btrfs_root *root; in select_one_root() local
2671 root = next->root; in select_one_root()
2672 BUG_ON(!root); in select_one_root()
2675 if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state)) in select_one_root()
2676 return root; in select_one_root()
2678 if (root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID) in select_one_root()
2679 fs_root = root; in select_one_root()
2732 struct btrfs_root *root = rc->extent_root; in reserve_metadata_space() local
2733 struct btrfs_fs_info *fs_info = root->fs_info; in reserve_metadata_space()
2748 ret = btrfs_block_rsv_refill(root, rc->block_rsv, num_bytes, in reserve_metadata_space()
2786 struct btrfs_root *root; in do_relocation() local
2806 root = select_reloc_root(trans, rc, upper, edges); in do_relocation()
2807 BUG_ON(!root); in do_relocation()
2826 ret = btrfs_search_slot(trans, root, key, path, 0, 1); in do_relocation()
2862 btrfs_err(root->fs_info, in do_relocation()
2874 blocksize = root->fs_info->nodesize; in do_relocation()
2891 ret = btrfs_cow_block(trans, root, eb, upper->eb, in do_relocation()
2910 ref.real_root = root->root_key.objectid; in do_relocation()
2916 ret = btrfs_drop_subtree(trans, root, eb, upper->eb); in do_relocation()
3071 struct btrfs_root *root; in relocate_tree_block() local
3078 root = select_one_root(node); in relocate_tree_block()
3079 if (root == ERR_PTR(-ENOENT)) { in relocate_tree_block()
3084 if (!root || test_bit(BTRFS_ROOT_REF_COWS, &root->state)) { in relocate_tree_block()
3090 if (root) { in relocate_tree_block()
3091 if (test_bit(BTRFS_ROOT_REF_COWS, &root->state)) { in relocate_tree_block()
3094 btrfs_record_root_in_trans(trans, root); in relocate_tree_block()
3095 root = root->reloc_root; in relocate_tree_block()
3096 node->new_bytenr = root->node->start; in relocate_tree_block()
3097 node->root = root; in relocate_tree_block()
3101 ret = btrfs_search_slot(trans, root, key, path, 0, 1); in relocate_tree_block()
3593 struct btrfs_root *root = fs_info->tree_root; in delete_block_group_cache() local
3604 inode = btrfs_iget(fs_info->sb, &key, root, NULL); in delete_block_group_cache()
3614 trans = btrfs_join_transaction(root); in delete_block_group_cache()
3642 struct btrfs_root *root; in find_data_references() local
3678 root = read_fs_root(fs_info, ref_root); in find_data_references()
3679 if (IS_ERR(root)) { in find_data_references()
3680 err = PTR_ERR(root); in find_data_references()
3693 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in find_data_references()
3719 ret = btrfs_next_leaf(root, path); in find_data_references()
4228 struct btrfs_root *root, u64 objectid) in __insert_orphan_inode() argument
4239 ret = btrfs_insert_empty_inode(trans, root, path, objectid); in __insert_orphan_inode()
4267 struct btrfs_root *root; in create_reloc_inode() local
4272 root = read_fs_root(fs_info, BTRFS_DATA_RELOC_TREE_OBJECTID); in create_reloc_inode()
4273 if (IS_ERR(root)) in create_reloc_inode()
4274 return ERR_CAST(root); in create_reloc_inode()
4276 trans = btrfs_start_transaction(root, 6); in create_reloc_inode()
4280 err = btrfs_find_free_objectid(root, &objectid); in create_reloc_inode()
4284 err = __insert_orphan_inode(trans, root, objectid); in create_reloc_inode()
4290 inode = btrfs_iget(fs_info->sb, &key, root, NULL); in create_reloc_inode()
4459 static noinline_for_stack int mark_garbage_root(struct btrfs_root *root) in mark_garbage_root() argument
4461 struct btrfs_fs_info *fs_info = root->fs_info; in mark_garbage_root()
4469 memset(&root->root_item.drop_progress, 0, in mark_garbage_root()
4470 sizeof(root->root_item.drop_progress)); in mark_garbage_root()
4471 root->root_item.drop_level = 0; in mark_garbage_root()
4472 btrfs_set_root_refs(&root->root_item, 0); in mark_garbage_root()
4474 &root->root_key, &root->root_item); in mark_garbage_root()
4488 int btrfs_recover_relocation(struct btrfs_root *root) in btrfs_recover_relocation() argument
4490 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_recover_relocation()
4531 reloc_root = btrfs_read_fs_root(root, &key); in btrfs_recover_relocation()
4697 struct btrfs_root *root, struct extent_buffer *buf, in btrfs_reloc_cow_block() argument
4700 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_reloc_cow_block()
4712 root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID); in btrfs_reloc_cow_block()
4714 if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) { in btrfs_reloc_cow_block()
4715 if (buf == root->node) in btrfs_reloc_cow_block()
4716 __update_reloc_root(root, cow->start); in btrfs_reloc_cow_block()
4721 btrfs_root_last_snapshot(&root->root_item)) in btrfs_reloc_cow_block()
4724 if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID && in btrfs_reloc_cow_block()
4751 ret = replace_file_extents(trans, rc, root, cow); in btrfs_reloc_cow_block()
4762 struct btrfs_root *root = pending->root; in btrfs_reloc_pre_snapshot() local
4763 struct reloc_control *rc = root->fs_info->reloc_ctl; in btrfs_reloc_pre_snapshot()
4765 if (!rc || !have_reloc_root(root)) in btrfs_reloc_pre_snapshot()
4771 root = root->reloc_root; in btrfs_reloc_pre_snapshot()
4772 BUG_ON(btrfs_root_refs(&root->root_item) == 0); in btrfs_reloc_pre_snapshot()
4793 struct btrfs_root *root = pending->root; in btrfs_reloc_post_snapshot() local
4796 struct reloc_control *rc = root->fs_info->reloc_ctl; in btrfs_reloc_post_snapshot()
4799 if (!rc || !have_reloc_root(root)) in btrfs_reloc_post_snapshot()
4802 rc = root->fs_info->reloc_ctl; in btrfs_reloc_post_snapshot()
4814 reloc_root = create_reloc_root(trans, root->reloc_root, in btrfs_reloc_post_snapshot()
4824 ret = clone_backref_node(trans, rc, root, reloc_root); in btrfs_reloc_post_snapshot()