Lines Matching defs:root
16 #include "root-tree.h"
20 * Read a root item from the tree. In case we detect a root item smaller then
21 * sizeof(root_item), we know it's an old version of the root structure and
23 * generation numbers as then we know the root was once mounted with an older
24 * kernel that was not aware of the root item structure change.
41 "mismatching generation and generation_v2 found in root item. This root was probably mounted with an older kernel. Resetting all new fields.");
53 * Lookup the root by the key.
55 * root: the root of the root tree
58 * root_item: the root item of the tree we look for
59 * root_key: the root key of the tree we look for
62 * of the search key, just lookup the root with the highest offset for a
67 int btrfs_find_root(struct btrfs_root *root, const struct btrfs_key *search_key,
76 ret = btrfs_search_slot(NULL, root, search_key, path, 0, 0);
85 * Key with offset -1 found, there would have to exist a root
129 *root, struct btrfs_key *key, struct btrfs_root_item
132 struct btrfs_fs_info *fs_info = root->fs_info;
144 ret = btrfs_search_slot(trans, root, key, path, 0, 1);
150 "unable to find root key " BTRFS_KEY_FMT " in tree %llu",
151 BTRFS_KEY_FMT_VALUE(key), btrfs_root_id(root));
163 * If this is the first time we update the root item which originated
169 ret = btrfs_search_slot(trans, root, key, path,
176 ret = btrfs_del_item(trans, root, path);
182 ret = btrfs_insert_empty_item(trans, root, path,
194 * Update generation_v2 so at the next mount we know the new root
203 int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
210 return btrfs_insert_item(trans, root, key, item, sizeof(*item));
219 struct btrfs_root *root;
257 root = btrfs_get_fs_root(fs_info, root_objectid, false);
258 ret = PTR_ERR_OR_ZERO(root);
276 "failed to delete root orphan item: %d", ret);
282 WARN_ON(!test_bit(BTRFS_ROOT_ORPHAN_ITEM_INSERTED, &root->state));
283 if (btrfs_root_refs(&root->root_item) == 0) {
286 btrfs_disk_key_to_cpu(&drop_key, &root->root_item.drop_progress);
296 set_bit(BTRFS_ROOT_UNFINISHED_DROP, &root->state);
299 set_bit(BTRFS_ROOT_DEAD_TREE, &root->state);
300 btrfs_add_dead_root(root);
302 btrfs_put_root(root);
308 /* drop the root item for 'key' from the tree root */
312 struct btrfs_root *root = trans->fs_info->tree_root;
319 ret = btrfs_search_slot(trans, root, key, path, -1, 1);
323 /* The root must exist but we did not find it by the key. */
326 return btrfs_del_item(trans, root, path);
387 * that is referencing the root.
390 * the root and ref_id is the id of the subvol or snapshot.
462 struct btrfs_root *root)
464 struct btrfs_root_item *item = &root->root_item;
468 spin_lock(&root->root_item_lock);
472 spin_unlock(&root->root_item_lock);
478 * root: the root of the parent directory
486 * and root tree, the number of items that the qgroup reserves is
490 int btrfs_subvolume_reserve_metadata(struct btrfs_root *root,
497 struct btrfs_fs_info *fs_info = root->fs_info;
503 ret = btrfs_qgroup_reserve_meta_prealloc(root,
520 btrfs_qgroup_free_meta_prealloc(root, qgroup_num_bytes);