Lines Matching refs:root

144 	struct rb_root_cached root;
148 #define PREFTREE_INIT { .root = RB_ROOT_CACHED, .count = 0 }
166 struct btrfs_root *root;
172 * the same root or different roots) that we could find. The sharedness
267 if (newref->root_id == sc->root->root_key.objectid &&
274 * Add @newref to the @root rbtree, merging identical refs.
283 struct rb_root_cached *root;
290 root = &preftree->root;
291 p = &root->rb_root.rb_node;
332 rb_insert_color_cached(&newref->rbnode, root, leftmost);
337 * just free everything and then reset the tree root.
344 &preftree->root.rb_root, rbnode) {
349 preftree->root = RB_ROOT_CACHED;
368 * root for resolving | y | y | y | y
381 * root for resolving | - | y | y | y
421 /* direct refs use root == 0, key == NULL */
448 struct rb_node **p = &preftrees->direct.root.rb_root.rb_node;
472 struct btrfs_root *root, struct btrfs_path *path,
504 * 3. The leaf owner is not equal to the root we are searching
513 ret = btrfs_next_leaf(root, path);
515 ret = btrfs_next_old_leaf(root, path, ctx->time_seq);
531 * the leaf owner is not equal to the root we are searching for
537 ret = btrfs_next_leaf(root, path);
539 ret = btrfs_next_old_leaf(root, path, ctx->time_seq);
577 ret = btrfs_next_item(root, path);
579 ret = btrfs_next_old_item(root, path, ctx->time_seq);
599 struct btrfs_root *root;
610 * for the root, and if we don't find it then we need to search the
611 * tree_root's commit root, thus the btrfs_get_fs_root_commit_root usage
615 root = btrfs_get_fs_root_commit_root(ctx->fs_info, path, ref->root_id);
617 root = btrfs_get_fs_root(ctx->fs_info, ref->root_id, false);
618 if (IS_ERR(root)) {
619 ret = PTR_ERR(root);
624 test_bit(BTRFS_ROOT_DELETING, &root->state)) {
635 root_level = btrfs_header_level(root->commit_root);
637 root_level = btrfs_header_level(root->node);
639 root_level = btrfs_old_root_level(root, ctx->time_seq);
668 ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0);
670 ret = btrfs_search_old_slot(root, &search_key, path, ctx->time_seq);
673 "search slot in root %llu (level %d, ref count %d) returned %d for key (%llu %u %llu)",
690 ret = add_all_parents(ctx, root, path, parents, preftrees, ref, level);
692 btrfs_put_root(root);
757 while ((rnode = rb_first_cached(&preftrees->indirect.root))) {
767 rb_erase_cached(&ref->rbnode, &preftrees->indirect.root);
775 if (sc && ref->root_id != sc->root->root_key.objectid) {
848 while ((node = rb_first_cached(&tree->root))) {
852 rb_erase_cached(node, &tree->root);
934 ret = add_indirect_ref(fs_info, preftrees, ref->root,
978 ret = add_indirect_ref(fs_info, preftrees, ref->root,
1107 u64 root;
1122 root = btrfs_extent_data_ref_root(leaf, dref);
1125 !ctx->skip_data_ref(root, key.objectid, key.offset,
1128 root, &key, 0, ctx->bytenr,
1210 u64 root;
1226 root = btrfs_extent_data_ref_root(leaf, dref);
1229 !ctx->skip_data_ref(root, key.objectid, key.offset,
1231 ret = add_indirect_ref(fs_info, preftrees, root,
1249 * fs_info->commit_root_sem semaphore, so no need to worry about the root's last
1253 struct btrfs_root *root,
1256 const struct btrfs_fs_info *fs_info = root->fs_info;
1272 * the root node down to the leaf with the file extent item.
1284 * root changed, so we now have a snapshot. Don't trust the result.
1287 entry->gen != btrfs_root_last_snapshot(&root->root_item))
1292 * a root changed, we can not trust the result, because the dropped root
1319 * fs_info->commit_root_sem semaphore, so no need to worry about the root's last
1323 struct btrfs_root *root,
1326 const struct btrfs_fs_info *fs_info = root->fs_info;
1343 * the root node down to the leaf with the file extent item.
1350 gen = btrfs_root_last_snapshot(&root->root_item);
1390 struct btrfs_root *root = btrfs_extent_root(ctx->fs_info, ctx->bytenr);
1431 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
1494 ret = add_keyed_refs(ctx, root, path, info_level,
1519 * tree (going from the root node down to the leaf that has the file
1526 * last generation used to snapshot the root, then we know that
1530 * root node down to the leaf that has the file extent item that
1534 btrfs_root_last_snapshot(&sc->root->root_item)) {
1555 cached = lookup_backref_shared_cache(sc->ctx, sc->root,
1574 WARN_ON(!RB_EMPTY_ROOT(&preftrees.indirect_missing_keys.root.rb_root));
1580 WARN_ON(!RB_EMPTY_ROOT(&preftrees.indirect.root.rb_root));
1589 node = rb_first_cached(&preftrees.direct.root);
1604 /* no parent == root of tree */
1843 * circuit as soon as it finds a root or inode that doesn't match the
1858 struct btrfs_root *root = inode->root;
1859 struct btrfs_fs_info *fs_info = root->fs_info;
1867 .root = root,
1886 trans = btrfs_join_transaction_nostart(root);
1908 leaf_cached = lookup_backref_shared_cache(ctx, root,
1934 store_backref_shared_cache(ctx, root, bytenr,
1976 store_backref_shared_cache(ctx, root, bytenr,
1987 cached = lookup_backref_shared_cache(ctx, root, bytenr,
2013 store_backref_shared_cache(ctx, root, bytenr, level, ret);
2049 int btrfs_find_one_extref(struct btrfs_root *root, u64 inode_objectid,
2065 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
2082 ret = btrfs_next_leaf(root, path);
2329 * reads the tree block backref for an extent. tree level and root are returned
2381 u64 root, u64 extent_item_objectid,
2389 "ref for %llu resolved, key (%llu EXTEND_DATA %llu), root %llu",
2391 eie->offset, root);
2392 ret = iterate(eie->inum, eie->offset, eie->num_bytes, root, ctx);
2501 "root %llu references leaf %llu, data list %#llx",
2530 static int build_ino_list(u64 inum, u64 offset, u64 num_bytes, u64 root, void *ctx)
2539 inodes->val[inodes->elem_cnt + 2] = root;
2842 /* Current backref iterator only supports iteration in commit root */
3142 /* Only reloc root uses backref pointing to itself */
3144 struct btrfs_root *root;
3147 /* Only reloc backref cache cares about a specific root */
3149 root = find_reloc_root(cache->fs_info, cur->bytenr);
3150 if (!root)
3152 cur->root = root;
3155 * For generic purpose backref cache, reloc root node
3217 struct btrfs_root *root;
3223 root = btrfs_get_fs_root(fs_info, ref_key->offset, false);
3224 if (IS_ERR(root))
3225 return PTR_ERR(root);
3226 if (!test_bit(BTRFS_ROOT_SHAREABLE, &root->state))
3229 if (btrfs_root_level(&root->root_item) == cur->level) {
3230 /* Tree root */
3231 ASSERT(btrfs_root_bytenr(&root->root_item) == cur->bytenr);
3233 * For reloc backref cache, we may ignore reloc root. But for
3236 * current running relocation and lead to missing root.
3238 * For general purpose backref cache, reloc root detection is
3242 if (btrfs_should_ignore_reloc_root(root) && cache->is_reloc) {
3243 btrfs_put_root(root);
3246 cur->root = root;
3257 ret = btrfs_search_slot(NULL, root, tree_key, path, 0, 0);
3260 btrfs_put_root(root);
3270 cur->bytenr, level - 1, root->root_key.objectid,
3272 btrfs_put_root(root);
3281 ASSERT(btrfs_root_bytenr(&root->root_item) ==
3284 if (btrfs_should_ignore_reloc_root(root) &&
3286 btrfs_put_root(root);
3289 lower->root = root;
3296 btrfs_put_root(root);
3307 btrfs_put_root(root);
3313 if (!test_bit(BTRFS_ROOT_SHAREABLE, &root->state))
3320 if (btrfs_block_can_be_shared(trans, root, eb))
3350 btrfs_put_root(root);
3471 * offset means the root objectid. We need to search