Lines Matching refs:reloc_root

271 	if (!root->reloc_root)  in have_reloc_root()
278 struct btrfs_root *reloc_root; in btrfs_should_ignore_reloc_root() local
287 reloc_root = root->reloc_root; in btrfs_should_ignore_reloc_root()
288 if (!reloc_root) in btrfs_should_ignore_reloc_root()
291 if (btrfs_header_generation(reloc_root->commit_root) == in btrfs_should_ignore_reloc_root()
587 struct btrfs_root *reloc_root; in create_reloc_root() local
682 reloc_root = btrfs_read_tree_root(fs_info->tree_root, &root_key); in create_reloc_root()
683 if (IS_ERR(reloc_root)) { in create_reloc_root()
684 ret = PTR_ERR(reloc_root); in create_reloc_root()
687 set_bit(BTRFS_ROOT_SHAREABLE, &reloc_root->state); in create_reloc_root()
688 btrfs_set_root_last_trans(reloc_root, trans->transid); in create_reloc_root()
689 return reloc_root; in create_reloc_root()
709 struct btrfs_root *reloc_root; in btrfs_init_reloc_root() local
733 if (root->reloc_root) { in btrfs_init_reloc_root()
734 reloc_root = root->reloc_root; in btrfs_init_reloc_root()
735 btrfs_set_root_last_trans(reloc_root, trans->transid); in btrfs_init_reloc_root()
751 reloc_root = create_reloc_root(trans, root, btrfs_root_id(root)); in btrfs_init_reloc_root()
754 if (IS_ERR(reloc_root)) in btrfs_init_reloc_root()
755 return PTR_ERR(reloc_root); in btrfs_init_reloc_root()
757 ret = __add_reloc_root(reloc_root); in btrfs_init_reloc_root()
761 btrfs_put_root(reloc_root); in btrfs_init_reloc_root()
764 root->reloc_root = btrfs_grab_root(reloc_root); in btrfs_init_reloc_root()
775 struct btrfs_root *reloc_root; in btrfs_update_reloc_root() local
782 reloc_root = root->reloc_root; in btrfs_update_reloc_root()
783 root_item = &reloc_root->root_item; in btrfs_update_reloc_root()
790 btrfs_grab_root(reloc_root); in btrfs_update_reloc_root()
801 __del_reloc_root(reloc_root); in btrfs_update_reloc_root()
804 if (reloc_root->commit_root != reloc_root->node) { in btrfs_update_reloc_root()
805 __update_reloc_root(reloc_root); in btrfs_update_reloc_root()
806 btrfs_set_root_node(root_item, reloc_root->node); in btrfs_update_reloc_root()
807 free_extent_buffer(reloc_root->commit_root); in btrfs_update_reloc_root()
808 reloc_root->commit_root = btrfs_root_node(reloc_root); in btrfs_update_reloc_root()
812 &reloc_root->root_key, root_item); in btrfs_update_reloc_root()
813 btrfs_put_root(reloc_root); in btrfs_update_reloc_root()
1441 struct btrfs_root *reloc_root = root->reloc_root; in insert_dirty_subvol() local
1447 ASSERT(reloc_root); in insert_dirty_subvol()
1449 reloc_root_item = &reloc_root->root_item; in insert_dirty_subvol()
1477 struct btrfs_root *reloc_root = root->reloc_root; in clean_dirty_subvols() local
1480 root->reloc_root = NULL; in clean_dirty_subvols()
1487 if (reloc_root) { in clean_dirty_subvols()
1493 ret2 = btrfs_drop_snapshot(reloc_root, 0, 1); in clean_dirty_subvols()
1495 btrfs_put_root(reloc_root); in clean_dirty_subvols()
1525 struct btrfs_root *reloc_root; in merge_reloc_root() local
1541 reloc_root = root->reloc_root; in merge_reloc_root()
1542 root_item = &reloc_root->root_item; in merge_reloc_root()
1546 refcount_inc(&reloc_root->node->refs); in merge_reloc_root()
1547 path->nodes[level] = reloc_root->node; in merge_reloc_root()
1555 ret = btrfs_search_slot(NULL, reloc_root, &key, path, 0, 0); in merge_reloc_root()
1604 btrfs_set_root_last_trans(reloc_root, trans->transid); in merge_reloc_root()
1610 ret = walk_down_reloc_tree(reloc_root, path, &level); in merge_reloc_root()
1620 ret = replace_path(trans, rc, root, reloc_root, path, in merge_reloc_root()
1632 ret = walk_up_reloc_tree(reloc_root, path, &level); in merge_reloc_root()
1688 struct btrfs_root *reloc_root; in prepare_to_merge() local
1728 reloc_root = list_first_entry(&rc->reloc_roots, in prepare_to_merge()
1730 list_del_init(&reloc_root->root_list); in prepare_to_merge()
1732 root = btrfs_get_fs_root(fs_info, reloc_root->root_key.offset, in prepare_to_merge()
1739 list_add(&reloc_root->root_list, &reloc_roots); in prepare_to_merge()
1746 if (unlikely(root->reloc_root != reloc_root)) { in prepare_to_merge()
1747 if (root->reloc_root) { in prepare_to_merge()
1751 btrfs_root_id(root->reloc_root), in prepare_to_merge()
1752 root->reloc_root->root_key.type, in prepare_to_merge()
1753 root->reloc_root->root_key.offset, in prepare_to_merge()
1755 &root->reloc_root->root_item), in prepare_to_merge()
1756 btrfs_root_id(reloc_root), in prepare_to_merge()
1757 reloc_root->root_key.type, in prepare_to_merge()
1758 reloc_root->root_key.offset, in prepare_to_merge()
1760 &reloc_root->root_item)); in prepare_to_merge()
1765 btrfs_root_id(reloc_root), in prepare_to_merge()
1766 reloc_root->root_key.type, in prepare_to_merge()
1767 reloc_root->root_key.offset, in prepare_to_merge()
1769 &reloc_root->root_item)); in prepare_to_merge()
1771 list_add(&reloc_root->root_list, &reloc_roots); in prepare_to_merge()
1784 btrfs_set_root_refs(&reloc_root->root_item, 1); in prepare_to_merge()
1791 list_add(&reloc_root->root_list, &reloc_roots); in prepare_to_merge()
1814 struct btrfs_root *reloc_root, *tmp; in free_reloc_roots() local
1816 list_for_each_entry_safe(reloc_root, tmp, list, root_list) in free_reloc_roots()
1817 __del_reloc_root(reloc_root); in free_reloc_roots()
1825 struct btrfs_root *reloc_root; in merge_reloc_roots() local
1844 reloc_root = list_first_entry(&reloc_roots, struct btrfs_root, root_list); in merge_reloc_roots()
1846 root = btrfs_get_fs_root(fs_info, reloc_root->root_key.offset, in merge_reloc_roots()
1848 if (btrfs_root_refs(&reloc_root->root_item) > 0) { in merge_reloc_roots()
1861 if (WARN_ON(root->reloc_root != reloc_root)) { in merge_reloc_roots()
1872 if (list_empty(&reloc_root->root_list)) in merge_reloc_roots()
1873 list_add_tail(&reloc_root->root_list, in merge_reloc_roots()
1879 if (root->reloc_root == reloc_root) { in merge_reloc_roots()
1880 root->reloc_root = NULL; in merge_reloc_roots()
1881 btrfs_put_root(reloc_root); in merge_reloc_roots()
1888 list_del_init(&reloc_root->root_list); in merge_reloc_roots()
1890 list_add_tail(&reloc_root->reloc_dirty_list, in merge_reloc_roots()
1940 struct btrfs_root *reloc_root) in record_reloc_root_in_trans() argument
1942 struct btrfs_fs_info *fs_info = reloc_root->fs_info; in record_reloc_root_in_trans()
1946 if (btrfs_get_root_last_trans(reloc_root) == trans->transid) in record_reloc_root_in_trans()
1949 root = btrfs_get_fs_root(fs_info, reloc_root->root_key.offset, false); in record_reloc_root_in_trans()
1963 if (root->reloc_root != reloc_root) { in record_reloc_root_in_trans()
1967 reloc_root->root_key.offset); in record_reloc_root_in_trans()
2025 root = root->reloc_root; in select_reloc_root()
2536 if (!root->reloc_root) { in relocate_tree_block()
2540 root = root->reloc_root; in relocate_tree_block()
4082 struct btrfs_root *reloc_root; in btrfs_recover_relocation() local
4118 reloc_root = btrfs_read_tree_root(fs_info->tree_root, &key); in btrfs_recover_relocation()
4119 if (IS_ERR(reloc_root)) { in btrfs_recover_relocation()
4120 ret = PTR_ERR(reloc_root); in btrfs_recover_relocation()
4124 set_bit(BTRFS_ROOT_SHAREABLE, &reloc_root->state); in btrfs_recover_relocation()
4125 list_add(&reloc_root->root_list, &reloc_roots); in btrfs_recover_relocation()
4127 if (btrfs_root_refs(&reloc_root->root_item) > 0) { in btrfs_recover_relocation()
4129 reloc_root->root_key.offset, false); in btrfs_recover_relocation()
4134 ret = mark_garbage_root(reloc_root); in btrfs_recover_relocation()
4176 reloc_root = list_first_entry(&reloc_roots, struct btrfs_root, root_list); in btrfs_recover_relocation()
4177 list_del(&reloc_root->root_list); in btrfs_recover_relocation()
4179 if (btrfs_root_refs(&reloc_root->root_item) == 0) { in btrfs_recover_relocation()
4180 list_add_tail(&reloc_root->root_list, in btrfs_recover_relocation()
4185 fs_root = btrfs_get_fs_root(fs_info, reloc_root->root_key.offset, in btrfs_recover_relocation()
4189 list_add_tail(&reloc_root->root_list, &reloc_roots); in btrfs_recover_relocation()
4194 ret = __add_reloc_root(reloc_root); in btrfs_recover_relocation()
4197 list_add_tail(&reloc_root->root_list, &reloc_roots); in btrfs_recover_relocation()
4202 fs_root->reloc_root = btrfs_grab_root(reloc_root); in btrfs_recover_relocation()
4371 root = root->reloc_root; in btrfs_reloc_pre_snapshot()
4398 struct btrfs_root *reloc_root; in btrfs_reloc_post_snapshot() local
4418 reloc_root = create_reloc_root(trans, root->reloc_root, btrfs_root_id(new_root)); in btrfs_reloc_post_snapshot()
4419 if (IS_ERR(reloc_root)) in btrfs_reloc_post_snapshot()
4420 return PTR_ERR(reloc_root); in btrfs_reloc_post_snapshot()
4422 ret = __add_reloc_root(reloc_root); in btrfs_reloc_post_snapshot()
4426 btrfs_put_root(reloc_root); in btrfs_reloc_post_snapshot()
4429 new_root->reloc_root = btrfs_grab_root(reloc_root); in btrfs_reloc_post_snapshot()