Lines Matching defs:root

77 	struct btrfs_root *root;
90 * The most common case is to have a single root for cloning, which corresponds
91 * to the send root. Having the user specify more than 16 clone roots is not
394 "Send: inconsistent snapshot, found %s %s for inode %llu without updated inode item, send root is %llu, parent root is %llu",
921 static int get_inode_info(struct btrfs_root *root, u64 ino,
936 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
966 static int get_inode_gen(struct btrfs_root *root, u64 ino, u64 *gen)
973 ret = get_inode_info(root, ino, &info);
990 static int iterate_inode_ref(struct btrfs_root *root, struct btrfs_path *path,
1052 start = btrfs_ref_to_path(root, tmp_path, name_len,
1065 start = btrfs_ref_to_path(root, tmp_path,
1108 static int iterate_dir_item(struct btrfs_root *root, struct btrfs_path *path,
1157 BTRFS_MAX_XATTR_SIZE(root->fs_info)) {
1235 static int get_inode_path(struct btrfs_root *root,
1252 ret = btrfs_search_slot_for_read(root, &key, p, 1, 0);
1267 ret = iterate_inode_ref(root, p, &found_key, 1,
1296 /* The owner (root id) of the data backref for the current extent. */
1304 u64 root = (u64)(uintptr_t)key;
1307 if (root < cr->root->root_key.objectid)
1309 if (root > cr->root->root_key.objectid)
1319 if (cr1->root->root_key.objectid < cr2->root->root_key.objectid)
1321 if (cr1->root->root_key.objectid > cr2->root->root_key.objectid)
1336 /* First check if the root is in the list of accepted clone sources */
1345 if (clone_root->root == bctx->sctx->send_root &&
1354 if (clone_root->root == bctx->sctx->send_root) {
1466 struct clone_root *root;
1468 root = bsearch((void *)(uintptr_t)root_id, sctx->clone_roots,
1471 if (!root)
1525 * If we have only one reference and only the send root as a
1548 static bool skip_self_data_ref(u64 root, u64 ino, u64 offset, void *ctx)
1553 root == bctx->backref_owner &&
1627 * Use the header owner and not the send root's id, because in case of a
1657 * If have a single clone root, then it's the send root and we can tell
1708 * Choose the root from which we can clone more bytes, to
1718 * any root is fine), so we're done.
1735 static int read_symlink(struct btrfs_root *root,
1755 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
1767 btrfs_err(root->fs_info,
1768 "Found empty symlink inode %llu at root %llu",
1769 ino, root->root_key.objectid);
1779 btrfs_crit(root->fs_info,
1780 "send: found symlink extent that is not inline, ino %llu root %llu extent type %d",
1781 ino, btrfs_root_id(root), type);
1787 btrfs_crit(root->fs_info,
1788 "send: found symlink extent with compression, ino %llu root %llu compression type %d",
1789 ino, btrfs_root_id(root), compression);
1804 * Helper function to generate a file name that is unique in the root of
1981 static int lookup_dir_item_inode(struct btrfs_root *root,
1995 di = btrfs_lookup_dir_item(NULL, root, path, dir, &name_str, 0);
2016 static int get_first_ref(struct btrfs_root *root, u64 ino,
2034 ret = btrfs_search_slot_for_read(root, &key, path, 1, 0);
2070 ret = get_inode_gen(root, parent_dir, dir_gen);
2082 static int is_first_ref(struct btrfs_root *root,
2094 ret = get_first_ref(root, ino, &tmp_dir, NULL, tmp_name);
2137 * If we have a parent root we need to verify that the parent dir was
2142 * parent root.
2201 * send root.
2292 * Used by get_cur_path for each ref up to the root.
2412 * We walk the path up to the root. For every inode in between, we check if it
3022 struct rb_root *root;
3042 rb_erase(&ref->node, ref->root);
3193 struct btrfs_root *root = sctx->parent_root;
3204 * Don't try to rmdir the top/root subvolume dir.
3224 * the parent root b+tree for dir index keys.
3230 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
3234 /* Can't happen, the root is never empty. */
3266 btrfs_for_each_slot(root, &key, &found_key, path, iter_ret) {
3721 * (in the send root) with a higher inode number than ours (sctx->cur_ino) was
3723 * in the parent root) of some other unrelated directory that got its rename
3797 * renamed to. We need to check if that inode is in the send root as
3845 static int check_ino_in_path(struct btrfs_root *root,
3863 ret = get_first_ref(root, ino, &parent, &parent_gen, fs_path);
3874 * Check if inode ino1 is an ancestor of inode ino2 in the given root for any
3878 static int is_ancestor(struct btrfs_root *root,
3907 btrfs_for_each_slot(root, &key, &key, path, iter_ret) {
3941 ret = get_inode_gen(root, parent, &parent_gen);
3944 ret = check_ino_in_path(root, ino1, ino1_gen,
3993 * parent root, we need to delay the rename of the
4182 * This should never happen as the root dir always has the same ref
4651 static int record_ref_in_tree(struct rb_root *root, struct list_head *refs,
4682 rb_add(&ref->node, root, rbtree_ref_less);
4683 ref->root = root;
4809 struct btrfs_root *root;
4821 root = sctx->send_root;
4824 root = sctx->parent_root;
4836 btrfs_for_each_slot(root, &key, &found_key, path, iter_ret) {
4842 ret = iterate_inode_ref(root, path, &found_key, 0, cb, sctx);
5014 static int find_xattr(struct btrfs_root *root,
5029 ret = iterate_dir_item(root, path, __find_xattr, &ctx);
5113 struct btrfs_root *root;
5122 root = sctx->send_root;
5127 btrfs_for_each_slot(root, &key, &found_key, path, iter_ret) {
5134 ret = iterate_dir_item(root, path, __process_new_xattr, sctx);
5258 struct btrfs_root *root = sctx->send_root;
5259 struct btrfs_fs_info *fs_info = root->fs_info;
5301 "send: IO error at offset %llu for inode %llu root %llu",
5374 offset, len, clone_root->root->root_key.objectid,
5393 if (clone_root->root == sctx->send_root) {
5399 ret = get_inode_path(clone_root->root, clone_root->ino, p);
5413 if (!btrfs_is_empty_uuid(clone_root->root->root_item.received_uuid))
5415 clone_root->root->root_item.received_uuid);
5418 clone_root->root->root_item.uuid);
5420 btrfs_root_ctransid(&clone_root->root->root_item));
5525 struct btrfs_root *root = sctx->send_root;
5526 struct btrfs_fs_info *fs_info = root->fs_info;
5536 inode = btrfs_iget(fs_info->sb, sctx->cur_ino, root);
5590 struct btrfs_root *root = sctx->send_root;
5591 struct btrfs_fs_info *fs_info = root->fs_info;
5603 inode = btrfs_iget(fs_info->sb, sctx->cur_ino, root);
5730 struct btrfs_root *root = sctx->send_root;
5732 sctx->cur_inode = btrfs_iget(root->fs_info->sb, sctx->cur_ino, root);
5903 ret = get_inode_info(clone_root->root, clone_root->ino, &info);
5934 ret = btrfs_search_slot(NULL, clone_root->root, &key, path, 0, 0);
5955 ret = btrfs_next_leaf(clone_root->root, path);
6109 * and using the send root as the clone root, we must stop once
6116 if (clone_root->root == sctx->send_root &&
6360 struct btrfs_root *root = sctx->send_root;
6373 ret = btrfs_search_slot_for_read(root, &key, path, 0, 1);
6393 struct btrfs_root *root = sctx->parent_root;
6404 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
6417 ret = btrfs_next_leaf(root, path);
6560 struct btrfs_root *root;
6565 root = sctx->send_root;
6573 btrfs_for_each_slot(root, &key, &found_key, path, iter_ret) {
6874 * The cur_ino = root dir case is special here. We can't treat
6876 * stream that tries to delete/mkdir the root dir.
7209 * We can not hold the commit root semaphore here. This is because in
7220 * 3) The transaction is waiting to write lock the commit root semaphore,
7236 * We always have a send root, so left_path is never NULL. We will not
7237 * have a leaf when we have reached the end of the send root but have
7238 * not yet reached the end of the parent root.
7244 * When doing a full send we don't have a parent root, so right_path is
7246 * the parent root already, so we don't have a leaf at right_path.
7302 struct btrfs_root *root,
7309 lockdep_assert_held_read(&root->fs_info->commit_root_sem);
7318 ret = btrfs_search_slot(NULL, root, key, path, 0, 0);
7322 btrfs_err(root->fs_info,
7323 "send: key (%llu %u %llu) not found in %s root %llu, lowest_level %d, slot %d",
7325 (root == sctx->parent_root ? "parent" : "send"),
7326 root->root_key.objectid, path->lowest_level,
7512 * relocation, we can assert that the last key of the root node still
7557 * and reallocated after the last time we released the commit root semaphore.
7558 * The exception are the root nodes, for which we always have a clone, see
7604 * commit root semaphore, even if relocation and reallocation happens in
7620 * Now clone the root nodes (unless they happen to be the leaves we have
7741 * We clone the root node of the send and parent roots to prevent races
7743 * root node of a tree, so after the transaction is committed the old
7745 * So we clone them, under the commit root semaphore, to be race free.
7763 * Our right root is the parent root, while the left root is the "send"
7764 * root. We know that all new nodes/leaves in the left root must have
7765 * a generation greater than the right root's generation, so we trigger
7766 * readahead for those nodes and leaves of the left root, as we know we
7973 * If orphan cleanup did remove any orphans from a root, it means the tree
7974 * was modified and therefore the commit root is not the same as the current
7975 * root anymore. This is a problem, because send uses the commit root and
7976 * therefore can see inode items that don't exist in the current root anymore,
7978 * on the current root and not on the commit root. Those lookups will fail,
7982 * before it started (meaning that the commit root will be the same as the
7983 * current root) or not.
7996 if (sctx->clone_roots[i].root->node !=
7997 sctx->clone_roots[i].root->commit_root)
8006 /* Use any root, all fs roots will get their commit roots updated. */
8018 * Make sure any existing dellaloc is flushed for any root used by a send
8027 struct btrfs_root *root = sctx->parent_root;
8031 if (root) {
8032 ret = btrfs_start_delalloc_snapshot(root, false);
8035 btrfs_wait_ordered_extents(root, U64_MAX, 0, U64_MAX);
8039 root = sctx->clone_roots[i].root;
8040 ret = btrfs_start_delalloc_snapshot(root, false);
8043 btrfs_wait_ordered_extents(root, U64_MAX, 0, U64_MAX);
8049 static void btrfs_root_dec_send_in_progress(struct btrfs_root* root)
8051 spin_lock(&root->root_item_lock);
8052 root->send_in_progress--;
8057 if (root->send_in_progress < 0)
8058 btrfs_err(root->fs_info,
8059 "send_in_progress unbalanced %d root %llu",
8060 root->send_in_progress, root->root_key.objectid);
8061 spin_unlock(&root->root_item_lock);
8064 static void dedupe_in_progress_warn(const struct btrfs_root *root)
8066 btrfs_warn_rl(root->fs_info,
8067 "cannot use root %llu for send while deduplications on it are in progress (%d in progress)",
8068 root->root_key.objectid, root->dedupe_in_progress);
8074 struct btrfs_root *send_root = BTRFS_I(inode)->root;
8267 sctx->clone_roots[i].root = clone_root;
8304 sctx->clone_roots[sctx->clone_roots_cnt++].root =
8383 sctx->clone_roots[i].root);
8384 btrfs_put_root(sctx->clone_roots[i].root);
8389 sctx->clone_roots[i].root);
8390 btrfs_put_root(sctx->clone_roots[i].root);