Lines Matching full:root

55 static void btrfs_destroy_ordered_extents(struct btrfs_root *root);
58 static void btrfs_destroy_delalloc_inodes(struct btrfs_root *root);
125 * Lockdep class keys for extent_buffer->lock's in this root. For a given
131 * static, assign keysets according to the purpose of the root as indicated
166 u64 id; /* root objectid */
171 { .id = BTRFS_ROOT_TREE_OBJECTID, DEFINE_NAME("root") },
850 struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info; in btrfs_wq_submit_bio()
879 struct btrfs_root *root; in btree_csum_one_bio() local
885 root = BTRFS_I(bvec->bv_page->mapping->host)->root; in btree_csum_one_bio()
886 ret = csum_dirty_buffer(root->fs_info, bvec); in btree_csum_one_bio()
990 fs_info = BTRFS_I(mapping->host)->root->fs_info; in btree_writepages()
1017 btrfs_warn(BTRFS_I(page->mapping->host)->root->fs_info, in btree_invalidatepage()
1097 * @owner_root: the objectid of the root owner for this block.
1139 static void __setup_root(struct btrfs_root *root, struct btrfs_fs_info *fs_info, in __setup_root() argument
1143 root->fs_info = fs_info; in __setup_root()
1144 root->node = NULL; in __setup_root()
1145 root->commit_root = NULL; in __setup_root()
1146 root->state = 0; in __setup_root()
1147 root->orphan_cleanup_state = 0; in __setup_root()
1149 root->last_trans = 0; in __setup_root()
1150 root->free_objectid = 0; in __setup_root()
1151 root->nr_delalloc_inodes = 0; in __setup_root()
1152 root->nr_ordered_extents = 0; in __setup_root()
1153 root->inode_tree = RB_ROOT; in __setup_root()
1154 INIT_RADIX_TREE(&root->delayed_nodes_tree, GFP_ATOMIC); in __setup_root()
1155 root->block_rsv = NULL; in __setup_root()
1157 INIT_LIST_HEAD(&root->dirty_list); in __setup_root()
1158 INIT_LIST_HEAD(&root->root_list); in __setup_root()
1159 INIT_LIST_HEAD(&root->delalloc_inodes); in __setup_root()
1160 INIT_LIST_HEAD(&root->delalloc_root); in __setup_root()
1161 INIT_LIST_HEAD(&root->ordered_extents); in __setup_root()
1162 INIT_LIST_HEAD(&root->ordered_root); in __setup_root()
1163 INIT_LIST_HEAD(&root->reloc_dirty_list); in __setup_root()
1164 INIT_LIST_HEAD(&root->logged_list[0]); in __setup_root()
1165 INIT_LIST_HEAD(&root->logged_list[1]); in __setup_root()
1166 spin_lock_init(&root->inode_lock); in __setup_root()
1167 spin_lock_init(&root->delalloc_lock); in __setup_root()
1168 spin_lock_init(&root->ordered_extent_lock); in __setup_root()
1169 spin_lock_init(&root->accounting_lock); in __setup_root()
1170 spin_lock_init(&root->log_extents_lock[0]); in __setup_root()
1171 spin_lock_init(&root->log_extents_lock[1]); in __setup_root()
1172 spin_lock_init(&root->qgroup_meta_rsv_lock); in __setup_root()
1173 mutex_init(&root->objectid_mutex); in __setup_root()
1174 mutex_init(&root->log_mutex); in __setup_root()
1175 mutex_init(&root->ordered_extent_mutex); in __setup_root()
1176 mutex_init(&root->delalloc_mutex); in __setup_root()
1177 init_waitqueue_head(&root->qgroup_flush_wait); in __setup_root()
1178 init_waitqueue_head(&root->log_writer_wait); in __setup_root()
1179 init_waitqueue_head(&root->log_commit_wait[0]); in __setup_root()
1180 init_waitqueue_head(&root->log_commit_wait[1]); in __setup_root()
1181 INIT_LIST_HEAD(&root->log_ctxs[0]); in __setup_root()
1182 INIT_LIST_HEAD(&root->log_ctxs[1]); in __setup_root()
1183 atomic_set(&root->log_commit[0], 0); in __setup_root()
1184 atomic_set(&root->log_commit[1], 0); in __setup_root()
1185 atomic_set(&root->log_writers, 0); in __setup_root()
1186 atomic_set(&root->log_batch, 0); in __setup_root()
1187 refcount_set(&root->refs, 1); in __setup_root()
1188 atomic_set(&root->snapshot_force_cow, 0); in __setup_root()
1189 atomic_set(&root->nr_swapfiles, 0); in __setup_root()
1190 root->log_transid = 0; in __setup_root()
1191 root->log_transid_committed = -1; in __setup_root()
1192 root->last_log_commit = 0; in __setup_root()
1194 extent_io_tree_init(fs_info, &root->dirty_log_pages, in __setup_root()
1196 extent_io_tree_init(fs_info, &root->log_csum_range, in __setup_root()
1200 memset(&root->root_key, 0, sizeof(root->root_key)); in __setup_root()
1201 memset(&root->root_item, 0, sizeof(root->root_item)); in __setup_root()
1202 memset(&root->defrag_progress, 0, sizeof(root->defrag_progress)); in __setup_root()
1203 root->root_key.objectid = objectid; in __setup_root()
1204 root->anon_dev = 0; in __setup_root()
1206 spin_lock_init(&root->root_item_lock); in __setup_root()
1207 btrfs_qgroup_init_swapped_blocks(&root->swapped_blocks); in __setup_root()
1209 INIT_LIST_HEAD(&root->leak_list); in __setup_root()
1211 list_add_tail(&root->leak_list, &fs_info->allocated_roots); in __setup_root()
1219 struct btrfs_root *root = kzalloc(sizeof(*root), flags); in btrfs_alloc_root() local
1220 if (root) in btrfs_alloc_root()
1221 __setup_root(root, fs_info, objectid); in btrfs_alloc_root()
1222 return root; in btrfs_alloc_root()
1229 struct btrfs_root *root; in btrfs_alloc_dummy_root() local
1234 root = btrfs_alloc_root(fs_info, BTRFS_ROOT_TREE_OBJECTID, GFP_KERNEL); in btrfs_alloc_dummy_root()
1235 if (!root) in btrfs_alloc_dummy_root()
1239 root->alloc_bytenr = 0; in btrfs_alloc_dummy_root()
1241 return root; in btrfs_alloc_dummy_root()
1251 struct btrfs_root *root; in btrfs_create_tree() local
1261 root = btrfs_alloc_root(fs_info, objectid, GFP_KERNEL); in btrfs_create_tree()
1263 if (!root) in btrfs_create_tree()
1266 root->root_key.objectid = objectid; in btrfs_create_tree()
1267 root->root_key.type = BTRFS_ROOT_ITEM_KEY; in btrfs_create_tree()
1268 root->root_key.offset = 0; in btrfs_create_tree()
1270 leaf = btrfs_alloc_tree_block(trans, root, 0, objectid, NULL, 0, 0, 0, in btrfs_create_tree()
1278 root->node = leaf; in btrfs_create_tree()
1281 root->commit_root = btrfs_root_node(root); in btrfs_create_tree()
1282 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); in btrfs_create_tree()
1284 btrfs_set_root_flags(&root->root_item, 0); in btrfs_create_tree()
1285 btrfs_set_root_limit(&root->root_item, 0); in btrfs_create_tree()
1286 btrfs_set_root_bytenr(&root->root_item, leaf->start); in btrfs_create_tree()
1287 btrfs_set_root_generation(&root->root_item, trans->transid); in btrfs_create_tree()
1288 btrfs_set_root_level(&root->root_item, 0); in btrfs_create_tree()
1289 btrfs_set_root_refs(&root->root_item, 1); in btrfs_create_tree()
1290 btrfs_set_root_used(&root->root_item, leaf->len); in btrfs_create_tree()
1291 btrfs_set_root_last_snapshot(&root->root_item, 0); in btrfs_create_tree()
1292 btrfs_set_root_dirid(&root->root_item, 0); in btrfs_create_tree()
1294 generate_random_guid(root->root_item.uuid); in btrfs_create_tree()
1296 export_guid(root->root_item.uuid, &guid_null); in btrfs_create_tree()
1297 btrfs_set_root_drop_level(&root->root_item, 0); in btrfs_create_tree()
1304 ret = btrfs_insert_root(trans, tree_root, &key, &root->root_item); in btrfs_create_tree()
1308 return root; in btrfs_create_tree()
1314 btrfs_put_root(root); in btrfs_create_tree()
1322 struct btrfs_root *root; in alloc_log_tree() local
1324 root = btrfs_alloc_root(fs_info, BTRFS_TREE_LOG_OBJECTID, GFP_NOFS); in alloc_log_tree()
1325 if (!root) in alloc_log_tree()
1328 root->root_key.objectid = BTRFS_TREE_LOG_OBJECTID; in alloc_log_tree()
1329 root->root_key.type = BTRFS_ROOT_ITEM_KEY; in alloc_log_tree()
1330 root->root_key.offset = BTRFS_TREE_LOG_OBJECTID; in alloc_log_tree()
1332 return root; in alloc_log_tree()
1336 struct btrfs_root *root) in btrfs_alloc_log_tree_node() argument
1350 leaf = btrfs_alloc_tree_block(trans, root, 0, BTRFS_TREE_LOG_OBJECTID, in btrfs_alloc_log_tree_node()
1355 root->node = leaf; in btrfs_alloc_log_tree_node()
1357 btrfs_mark_buffer_dirty(root->node); in btrfs_alloc_log_tree_node()
1358 btrfs_tree_unlock(root->node); in btrfs_alloc_log_tree_node()
1387 struct btrfs_root *root) in btrfs_add_log_tree() argument
1389 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_add_log_tree()
1405 log_root->root_key.offset = root->root_key.objectid; in btrfs_add_log_tree()
1417 WARN_ON(root->log_root); in btrfs_add_log_tree()
1418 root->log_root = log_root; in btrfs_add_log_tree()
1419 root->log_transid = 0; in btrfs_add_log_tree()
1420 root->log_transid_committed = -1; in btrfs_add_log_tree()
1421 root->last_log_commit = 0; in btrfs_add_log_tree()
1429 struct btrfs_root *root; in read_tree_root_path() local
1435 root = btrfs_alloc_root(fs_info, key->objectid, GFP_NOFS); in read_tree_root_path()
1436 if (!root) in read_tree_root_path()
1440 &root->root_item, &root->root_key); in read_tree_root_path()
1447 generation = btrfs_root_generation(&root->root_item); in read_tree_root_path()
1448 level = btrfs_root_level(&root->root_item); in read_tree_root_path()
1449 root->node = read_tree_block(fs_info, in read_tree_root_path()
1450 btrfs_root_bytenr(&root->root_item), in read_tree_root_path()
1452 if (IS_ERR(root->node)) { in read_tree_root_path()
1453 ret = PTR_ERR(root->node); in read_tree_root_path()
1454 root->node = NULL; in read_tree_root_path()
1456 } else if (!btrfs_buffer_uptodate(root->node, generation, 0)) { in read_tree_root_path()
1460 root->commit_root = btrfs_root_node(root); in read_tree_root_path()
1461 return root; in read_tree_root_path()
1463 btrfs_put_root(root); in read_tree_root_path()
1470 struct btrfs_root *root; in btrfs_read_tree_root() local
1476 root = read_tree_root_path(tree_root, path, key); in btrfs_read_tree_root()
1479 return root; in btrfs_read_tree_root()
1483 * Initialize subvolume root in-memory structure
1485 * @anon_dev: anonymous device to attach to the root, if zero, allocate new
1487 static int btrfs_init_fs_root(struct btrfs_root *root, dev_t anon_dev) in btrfs_init_fs_root() argument
1497 ret = btrfs_drew_lock_init(&root->snapshot_lock); in btrfs_init_fs_root()
1502 if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID && in btrfs_init_fs_root()
1503 root->root_key.objectid != BTRFS_DATA_RELOC_TREE_OBJECTID) { in btrfs_init_fs_root()
1504 set_bit(BTRFS_ROOT_SHAREABLE, &root->state); in btrfs_init_fs_root()
1505 btrfs_check_and_init_root_item(&root->root_item); in btrfs_init_fs_root()
1512 if (is_fstree(root->root_key.objectid) && in btrfs_init_fs_root()
1513 btrfs_root_refs(&root->root_item) > 0) { in btrfs_init_fs_root()
1515 ret = get_anon_bdev(&root->anon_dev); in btrfs_init_fs_root()
1519 root->anon_dev = anon_dev; in btrfs_init_fs_root()
1523 mutex_lock(&root->objectid_mutex); in btrfs_init_fs_root()
1524 ret = btrfs_init_root_free_objectid(root); in btrfs_init_fs_root()
1526 mutex_unlock(&root->objectid_mutex); in btrfs_init_fs_root()
1530 ASSERT(root->free_objectid <= BTRFS_LAST_FREE_OBJECTID); in btrfs_init_fs_root()
1532 mutex_unlock(&root->objectid_mutex); in btrfs_init_fs_root()
1543 struct btrfs_root *root; in btrfs_lookup_fs_root() local
1546 root = radix_tree_lookup(&fs_info->fs_roots_radix, in btrfs_lookup_fs_root()
1548 if (root) in btrfs_lookup_fs_root()
1549 root = btrfs_grab_root(root); in btrfs_lookup_fs_root()
1551 return root; in btrfs_lookup_fs_root()
1580 struct btrfs_root *root) in btrfs_insert_fs_root() argument
1590 (unsigned long)root->root_key.objectid, in btrfs_insert_fs_root()
1591 root); in btrfs_insert_fs_root()
1593 btrfs_grab_root(root); in btrfs_insert_fs_root()
1594 set_bit(BTRFS_ROOT_IN_RADIX, &root->state); in btrfs_insert_fs_root()
1605 struct btrfs_root *root; in btrfs_check_leaked_roots() local
1610 root = list_first_entry(&fs_info->allocated_roots, in btrfs_check_leaked_roots()
1612 btrfs_err(fs_info, "leaked root %s refcount %d", in btrfs_check_leaked_roots()
1613 btrfs_root_name(&root->root_key, buf), in btrfs_check_leaked_roots()
1614 refcount_read(&root->refs)); in btrfs_check_leaked_roots()
1615 while (refcount_read(&root->refs) > 1) in btrfs_check_leaked_roots()
1616 btrfs_put_root(root); in btrfs_check_leaked_roots()
1617 btrfs_put_root(root); in btrfs_check_leaked_roots()
1652 * Get an in-memory reference of a root structure.
1654 * For essential trees like root/extent tree, we grab it from fs_info directly.
1658 * Caller should release the root by calling btrfs_put_root() after the usage.
1661 * same root objectid.
1663 * @objectid: root id
1666 * @check_ref: whether to check root item references, If true, return -ENOENT
1673 struct btrfs_root *root; in btrfs_get_root_ref() local
1678 root = btrfs_get_global_root(fs_info, objectid); in btrfs_get_root_ref()
1679 if (root) in btrfs_get_root_ref()
1680 return root; in btrfs_get_root_ref()
1682 root = btrfs_lookup_fs_root(fs_info, objectid); in btrfs_get_root_ref()
1683 if (root) { in btrfs_get_root_ref()
1686 if (check_ref && btrfs_root_refs(&root->root_item) == 0) { in btrfs_get_root_ref()
1687 btrfs_put_root(root); in btrfs_get_root_ref()
1690 return root; in btrfs_get_root_ref()
1696 root = btrfs_read_tree_root(fs_info->tree_root, &key); in btrfs_get_root_ref()
1697 if (IS_ERR(root)) in btrfs_get_root_ref()
1698 return root; in btrfs_get_root_ref()
1700 if (check_ref && btrfs_root_refs(&root->root_item) == 0) { in btrfs_get_root_ref()
1705 ret = btrfs_init_fs_root(root, anon_dev); in btrfs_get_root_ref()
1723 set_bit(BTRFS_ROOT_ORPHAN_ITEM_INSERTED, &root->state); in btrfs_get_root_ref()
1725 ret = btrfs_insert_fs_root(fs_info, root); in btrfs_get_root_ref()
1727 btrfs_put_root(root); in btrfs_get_root_ref()
1732 return root; in btrfs_get_root_ref()
1734 btrfs_put_root(root); in btrfs_get_root_ref()
1739 * Get in-memory reference of a root structure
1752 * Get in-memory reference of a root structure, created as new, optionally pass
1766 * btrfs_get_fs_root_commit_root - return a root for the given objectid
1773 * up a fs root that is not in memory. If the root is not in memory we will
1774 * read the tree root commit root and look up the fs root from there. This is a
1775 * temporary root, it will not be inserted into the radix tree as it doesn't
1777 * backref code is finished using the root.
1783 struct btrfs_root *root; in btrfs_get_fs_root_commit_root() local
1789 * This can return -ENOENT if we ask for a root that doesn't exist, but in btrfs_get_fs_root_commit_root()
1791 * up a root that doesn't exist, unless there's corruption. So if root in btrfs_get_fs_root_commit_root()
1794 root = btrfs_get_global_root(fs_info, objectid); in btrfs_get_fs_root_commit_root()
1795 if (root) in btrfs_get_fs_root_commit_root()
1796 return root; in btrfs_get_fs_root_commit_root()
1798 root = btrfs_lookup_fs_root(fs_info, objectid); in btrfs_get_fs_root_commit_root()
1799 if (root) in btrfs_get_fs_root_commit_root()
1800 return root; in btrfs_get_fs_root_commit_root()
1805 root = read_tree_root_path(fs_info->tree_root, path, &key); in btrfs_get_fs_root_commit_root()
1808 return root; in btrfs_get_fs_root_commit_root()
1832 struct btrfs_root *root = arg; in cleaner_kthread() local
1833 struct btrfs_fs_info *fs_info = root->fs_info; in cleaner_kthread()
1866 again = btrfs_clean_one_deleted_snapshot(root); in cleaner_kthread()
1907 struct btrfs_root *root = arg; in transaction_kthread() local
1908 struct btrfs_fs_info *fs_info = root->fs_info; in transaction_kthread()
1941 trans = btrfs_attach_transaction(root); in transaction_kthread()
1968 * This will find the highest generation in the array of root backups. The
1973 * generation of the latest root in the array with the generation
1994 * copy all the root pointers into the super backup array.
2074 * read_backup_root - Reads a backup root based on the passed priority. Prio 0
2078 * priority - priority of backup root required
2080 * Returns backup root index on success and -EINVAL otherwise.
2144 static void free_root_extent_buffers(struct btrfs_root *root) in free_root_extent_buffers() argument
2146 if (root) { in free_root_extent_buffers()
2147 free_extent_buffer(root->node); in free_root_extent_buffers()
2148 free_extent_buffer(root->commit_root); in free_root_extent_buffers()
2149 root->node = NULL; in free_root_extent_buffers()
2150 root->commit_root = NULL; in free_root_extent_buffers()
2171 void btrfs_put_root(struct btrfs_root *root) in btrfs_put_root() argument
2173 if (!root) in btrfs_put_root()
2176 if (refcount_dec_and_test(&root->refs)) { in btrfs_put_root()
2177 WARN_ON(!RB_EMPTY_ROOT(&root->inode_tree)); in btrfs_put_root()
2178 WARN_ON(test_bit(BTRFS_ROOT_DEAD_RELOC_TREE, &root->state)); in btrfs_put_root()
2179 if (root->anon_dev) in btrfs_put_root()
2180 free_anon_bdev(root->anon_dev); in btrfs_put_root()
2181 btrfs_drew_lock_destroy(&root->snapshot_lock); in btrfs_put_root()
2182 free_root_extent_buffers(root); in btrfs_put_root()
2184 spin_lock(&root->fs_info->fs_roots_radix_lock); in btrfs_put_root()
2185 list_del_init(&root->leak_list); in btrfs_put_root()
2186 spin_unlock(&root->fs_info->fs_roots_radix_lock); in btrfs_put_root()
2188 kfree(root); in btrfs_put_root()
2261 BTRFS_I(inode)->root = btrfs_grab_root(fs_info->tree_root); in btrfs_init_btree_inode()
2433 struct btrfs_root *root; in btrfs_read_roots() local
2443 root = btrfs_read_tree_root(tree_root, &location); in btrfs_read_roots()
2444 if (IS_ERR(root)) { in btrfs_read_roots()
2446 ret = PTR_ERR(root); in btrfs_read_roots()
2450 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); in btrfs_read_roots()
2451 fs_info->extent_root = root; in btrfs_read_roots()
2455 root = btrfs_read_tree_root(tree_root, &location); in btrfs_read_roots()
2456 if (IS_ERR(root)) { in btrfs_read_roots()
2458 ret = PTR_ERR(root); in btrfs_read_roots()
2462 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); in btrfs_read_roots()
2463 fs_info->dev_root = root; in btrfs_read_roots()
2468 /* If IGNOREDATACSUMS is set don't bother reading the csum root. */ in btrfs_read_roots()
2471 root = btrfs_read_tree_root(tree_root, &location); in btrfs_read_roots()
2472 if (IS_ERR(root)) { in btrfs_read_roots()
2474 ret = PTR_ERR(root); in btrfs_read_roots()
2478 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); in btrfs_read_roots()
2479 fs_info->csum_root = root; in btrfs_read_roots()
2487 root = btrfs_get_fs_root(tree_root->fs_info, in btrfs_read_roots()
2489 if (IS_ERR(root)) { in btrfs_read_roots()
2491 ret = PTR_ERR(root); in btrfs_read_roots()
2495 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); in btrfs_read_roots()
2496 fs_info->data_reloc_root = root; in btrfs_read_roots()
2500 root = btrfs_read_tree_root(tree_root, &location); in btrfs_read_roots()
2501 if (!IS_ERR(root)) { in btrfs_read_roots()
2502 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); in btrfs_read_roots()
2504 fs_info->quota_root = root; in btrfs_read_roots()
2508 root = btrfs_read_tree_root(tree_root, &location); in btrfs_read_roots()
2509 if (IS_ERR(root)) { in btrfs_read_roots()
2511 ret = PTR_ERR(root); in btrfs_read_roots()
2516 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); in btrfs_read_roots()
2517 fs_info->uuid_root = root; in btrfs_read_roots()
2522 root = btrfs_read_tree_root(tree_root, &location); in btrfs_read_roots()
2523 if (IS_ERR(root)) { in btrfs_read_roots()
2525 ret = PTR_ERR(root); in btrfs_read_roots()
2529 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); in btrfs_read_roots()
2530 fs_info->free_space_root = root; in btrfs_read_roots()
2536 btrfs_warn(fs_info, "failed to read root (objectid=%llu): %d", in btrfs_read_roots()
2618 /* Root alignment check */ in validate_super()
2819 btrfs_warn(fs_info, "couldn't read tree root"); in init_tree_roots()
2825 btrfs_warn(fs_info, "error while reading tree root"); in init_tree_roots()
3114 * calling btrfs_orphan_cleanup() on the tree root. If we don't do it in btrfs_start_pre_rw_mount()
3115 * first, then btrfs_orphan_cleanup() will delete a dead root's orphan in btrfs_start_pre_rw_mount()
3116 * item before the root's tree is deleted - this means that if we unmount in btrfs_start_pre_rw_mount()
3441 btrfs_err(fs_info, "failed to read chunk root"); in open_ctree()
3491 * If we have a uuid root and we're not being told to rescan we need to in open_ctree()
4211 /* Drop a fs root from the radix tree and free it. */
4213 struct btrfs_root *root) in btrfs_drop_and_free_fs_root() argument
4219 (unsigned long)root->root_key.objectid); in btrfs_drop_and_free_fs_root()
4220 if (test_and_clear_bit(BTRFS_ROOT_IN_RADIX, &root->state)) in btrfs_drop_and_free_fs_root()
4225 ASSERT(root->log_root == NULL); in btrfs_drop_and_free_fs_root()
4226 if (root->reloc_root) { in btrfs_drop_and_free_fs_root()
4227 btrfs_put_root(root->reloc_root); in btrfs_drop_and_free_fs_root()
4228 root->reloc_root = NULL; in btrfs_drop_and_free_fs_root()
4233 btrfs_put_root(root); in btrfs_drop_and_free_fs_root()
4288 struct btrfs_root *root = fs_info->tree_root; in btrfs_commit_super() local
4300 trans = btrfs_join_transaction(root); in btrfs_commit_super()
4579 static void btrfs_destroy_ordered_extents(struct btrfs_root *root) in btrfs_destroy_ordered_extents() argument
4583 spin_lock(&root->ordered_extent_lock); in btrfs_destroy_ordered_extents()
4588 list_for_each_entry(ordered, &root->ordered_extents, in btrfs_destroy_ordered_extents()
4591 spin_unlock(&root->ordered_extent_lock); in btrfs_destroy_ordered_extents()
4596 struct btrfs_root *root; in btrfs_destroy_all_ordered_extents() local
4604 root = list_first_entry(&splice, struct btrfs_root, in btrfs_destroy_all_ordered_extents()
4606 list_move_tail(&root->ordered_root, in btrfs_destroy_all_ordered_extents()
4610 btrfs_destroy_ordered_extents(root); in btrfs_destroy_all_ordered_extents()
4706 static void btrfs_destroy_delalloc_inodes(struct btrfs_root *root) in btrfs_destroy_delalloc_inodes() argument
4713 spin_lock(&root->delalloc_lock); in btrfs_destroy_delalloc_inodes()
4714 list_splice_init(&root->delalloc_inodes, &splice); in btrfs_destroy_delalloc_inodes()
4720 __btrfs_del_delalloc_inode(root, btrfs_inode); in btrfs_destroy_delalloc_inodes()
4721 spin_unlock(&root->delalloc_lock); in btrfs_destroy_delalloc_inodes()
4732 spin_lock(&root->delalloc_lock); in btrfs_destroy_delalloc_inodes()
4734 spin_unlock(&root->delalloc_lock); in btrfs_destroy_delalloc_inodes()
4739 struct btrfs_root *root; in btrfs_destroy_all_delalloc_inodes() local
4747 root = list_first_entry(&splice, struct btrfs_root, in btrfs_destroy_all_delalloc_inodes()
4749 root = btrfs_grab_root(root); in btrfs_destroy_all_delalloc_inodes()
4750 BUG_ON(!root); in btrfs_destroy_all_delalloc_inodes()
4753 btrfs_destroy_delalloc_inodes(root); in btrfs_destroy_all_delalloc_inodes()
4754 btrfs_put_root(root); in btrfs_destroy_all_delalloc_inodes()
4977 int btrfs_init_root_free_objectid(struct btrfs_root *root) in btrfs_init_root_free_objectid() argument
4993 ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0); in btrfs_init_root_free_objectid()
5001 root->free_objectid = max_t(u64, found_key.objectid + 1, in btrfs_init_root_free_objectid()
5004 root->free_objectid = BTRFS_FIRST_FREE_OBJECTID; in btrfs_init_root_free_objectid()
5012 int btrfs_get_free_objectid(struct btrfs_root *root, u64 *objectid) in btrfs_get_free_objectid() argument
5015 mutex_lock(&root->objectid_mutex); in btrfs_get_free_objectid()
5017 if (unlikely(root->free_objectid >= BTRFS_LAST_FREE_OBJECTID)) { in btrfs_get_free_objectid()
5018 btrfs_warn(root->fs_info, in btrfs_get_free_objectid()
5019 "the objectid of root %llu reaches its highest value", in btrfs_get_free_objectid()
5020 root->root_key.objectid); in btrfs_get_free_objectid()
5025 *objectid = root->free_objectid++; in btrfs_get_free_objectid()
5028 mutex_unlock(&root->objectid_mutex); in btrfs_get_free_objectid()