Lines Matching full:root

54 static void btrfs_destroy_ordered_extents(struct btrfs_root *root);
57 static void btrfs_destroy_delalloc_inodes(struct btrfs_root *root);
126 * Lockdep class keys for extent_buffer->lock's in this root. For a given
132 * static, assign keysets according to the purpose of the root as indicated
154 u64 id; /* root objectid */
159 { .id = BTRFS_ROOT_TREE_OBJECTID, .name_stem = "root" },
781 struct btrfs_root *root; in btree_csum_one_bio() local
787 root = BTRFS_I(bvec->bv_page->mapping->host)->root; in btree_csum_one_bio()
788 ret = csum_dirty_buffer(root->fs_info, bvec->bv_page); in btree_csum_one_bio()
891 fs_info = BTRFS_I(mapping->host)->root->fs_info; in btree_writepages()
918 btrfs_warn(BTRFS_I(page->mapping->host)->root->fs_info, in btree_invalidatepage()
1022 static void __setup_root(struct btrfs_root *root, struct btrfs_fs_info *fs_info, in __setup_root() argument
1026 root->fs_info = fs_info; in __setup_root()
1027 root->node = NULL; in __setup_root()
1028 root->commit_root = NULL; in __setup_root()
1029 root->state = 0; in __setup_root()
1030 root->orphan_cleanup_state = 0; in __setup_root()
1032 root->last_trans = 0; in __setup_root()
1033 root->highest_objectid = 0; in __setup_root()
1034 root->nr_delalloc_inodes = 0; in __setup_root()
1035 root->nr_ordered_extents = 0; in __setup_root()
1036 root->inode_tree = RB_ROOT; in __setup_root()
1037 INIT_RADIX_TREE(&root->delayed_nodes_tree, GFP_ATOMIC); in __setup_root()
1038 root->block_rsv = NULL; in __setup_root()
1040 INIT_LIST_HEAD(&root->dirty_list); in __setup_root()
1041 INIT_LIST_HEAD(&root->root_list); in __setup_root()
1042 INIT_LIST_HEAD(&root->delalloc_inodes); in __setup_root()
1043 INIT_LIST_HEAD(&root->delalloc_root); in __setup_root()
1044 INIT_LIST_HEAD(&root->ordered_extents); in __setup_root()
1045 INIT_LIST_HEAD(&root->ordered_root); in __setup_root()
1046 INIT_LIST_HEAD(&root->reloc_dirty_list); in __setup_root()
1047 INIT_LIST_HEAD(&root->logged_list[0]); in __setup_root()
1048 INIT_LIST_HEAD(&root->logged_list[1]); in __setup_root()
1049 spin_lock_init(&root->inode_lock); in __setup_root()
1050 spin_lock_init(&root->delalloc_lock); in __setup_root()
1051 spin_lock_init(&root->ordered_extent_lock); in __setup_root()
1052 spin_lock_init(&root->accounting_lock); in __setup_root()
1053 spin_lock_init(&root->log_extents_lock[0]); in __setup_root()
1054 spin_lock_init(&root->log_extents_lock[1]); in __setup_root()
1055 spin_lock_init(&root->qgroup_meta_rsv_lock); in __setup_root()
1056 mutex_init(&root->objectid_mutex); in __setup_root()
1057 mutex_init(&root->log_mutex); in __setup_root()
1058 mutex_init(&root->ordered_extent_mutex); in __setup_root()
1059 mutex_init(&root->delalloc_mutex); in __setup_root()
1060 init_waitqueue_head(&root->qgroup_flush_wait); in __setup_root()
1061 init_waitqueue_head(&root->log_writer_wait); in __setup_root()
1062 init_waitqueue_head(&root->log_commit_wait[0]); in __setup_root()
1063 init_waitqueue_head(&root->log_commit_wait[1]); in __setup_root()
1064 INIT_LIST_HEAD(&root->log_ctxs[0]); in __setup_root()
1065 INIT_LIST_HEAD(&root->log_ctxs[1]); in __setup_root()
1066 atomic_set(&root->log_commit[0], 0); in __setup_root()
1067 atomic_set(&root->log_commit[1], 0); in __setup_root()
1068 atomic_set(&root->log_writers, 0); in __setup_root()
1069 atomic_set(&root->log_batch, 0); in __setup_root()
1070 refcount_set(&root->refs, 1); in __setup_root()
1071 atomic_set(&root->snapshot_force_cow, 0); in __setup_root()
1072 atomic_set(&root->nr_swapfiles, 0); in __setup_root()
1073 root->log_transid = 0; in __setup_root()
1074 root->log_transid_committed = -1; in __setup_root()
1075 root->last_log_commit = 0; in __setup_root()
1077 extent_io_tree_init(fs_info, &root->dirty_log_pages, in __setup_root()
1079 extent_io_tree_init(fs_info, &root->log_csum_range, in __setup_root()
1083 memset(&root->root_key, 0, sizeof(root->root_key)); in __setup_root()
1084 memset(&root->root_item, 0, sizeof(root->root_item)); in __setup_root()
1085 memset(&root->defrag_progress, 0, sizeof(root->defrag_progress)); in __setup_root()
1086 root->root_key.objectid = objectid; in __setup_root()
1087 root->anon_dev = 0; in __setup_root()
1089 spin_lock_init(&root->root_item_lock); in __setup_root()
1090 btrfs_qgroup_init_swapped_blocks(&root->swapped_blocks); in __setup_root()
1092 INIT_LIST_HEAD(&root->leak_list); in __setup_root()
1094 list_add_tail(&root->leak_list, &fs_info->allocated_roots); in __setup_root()
1102 struct btrfs_root *root = kzalloc(sizeof(*root), flags); in btrfs_alloc_root() local
1103 if (root) in btrfs_alloc_root()
1104 __setup_root(root, fs_info, objectid); in btrfs_alloc_root()
1105 return root; in btrfs_alloc_root()
1112 struct btrfs_root *root; in btrfs_alloc_dummy_root() local
1117 root = btrfs_alloc_root(fs_info, BTRFS_ROOT_TREE_OBJECTID, GFP_KERNEL); in btrfs_alloc_dummy_root()
1118 if (!root) in btrfs_alloc_dummy_root()
1122 root->alloc_bytenr = 0; in btrfs_alloc_dummy_root()
1124 return root; in btrfs_alloc_dummy_root()
1134 struct btrfs_root *root; in btrfs_create_tree() local
1144 root = btrfs_alloc_root(fs_info, objectid, GFP_KERNEL); in btrfs_create_tree()
1146 if (!root) in btrfs_create_tree()
1149 root->root_key.objectid = objectid; in btrfs_create_tree()
1150 root->root_key.type = BTRFS_ROOT_ITEM_KEY; in btrfs_create_tree()
1151 root->root_key.offset = 0; in btrfs_create_tree()
1153 leaf = btrfs_alloc_tree_block(trans, root, 0, objectid, NULL, 0, 0, 0, in btrfs_create_tree()
1161 root->node = leaf; in btrfs_create_tree()
1164 root->commit_root = btrfs_root_node(root); in btrfs_create_tree()
1165 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); in btrfs_create_tree()
1167 root->root_item.flags = 0; in btrfs_create_tree()
1168 root->root_item.byte_limit = 0; in btrfs_create_tree()
1169 btrfs_set_root_bytenr(&root->root_item, leaf->start); in btrfs_create_tree()
1170 btrfs_set_root_generation(&root->root_item, trans->transid); in btrfs_create_tree()
1171 btrfs_set_root_level(&root->root_item, 0); in btrfs_create_tree()
1172 btrfs_set_root_refs(&root->root_item, 1); in btrfs_create_tree()
1173 btrfs_set_root_used(&root->root_item, leaf->len); in btrfs_create_tree()
1174 btrfs_set_root_last_snapshot(&root->root_item, 0); in btrfs_create_tree()
1175 btrfs_set_root_dirid(&root->root_item, 0); in btrfs_create_tree()
1177 generate_random_guid(root->root_item.uuid); in btrfs_create_tree()
1179 export_guid(root->root_item.uuid, &guid_null); in btrfs_create_tree()
1180 root->root_item.drop_level = 0; in btrfs_create_tree()
1185 ret = btrfs_insert_root(trans, tree_root, &key, &root->root_item); in btrfs_create_tree()
1191 return root; in btrfs_create_tree()
1196 btrfs_put_root(root); in btrfs_create_tree()
1204 struct btrfs_root *root; in alloc_log_tree() local
1207 root = btrfs_alloc_root(fs_info, BTRFS_TREE_LOG_OBJECTID, GFP_NOFS); in alloc_log_tree()
1208 if (!root) in alloc_log_tree()
1211 root->root_key.objectid = BTRFS_TREE_LOG_OBJECTID; in alloc_log_tree()
1212 root->root_key.type = BTRFS_ROOT_ITEM_KEY; in alloc_log_tree()
1213 root->root_key.offset = BTRFS_TREE_LOG_OBJECTID; in alloc_log_tree()
1225 leaf = btrfs_alloc_tree_block(trans, root, 0, BTRFS_TREE_LOG_OBJECTID, in alloc_log_tree()
1228 btrfs_put_root(root); in alloc_log_tree()
1232 root->node = leaf; in alloc_log_tree()
1234 btrfs_mark_buffer_dirty(root->node); in alloc_log_tree()
1235 btrfs_tree_unlock(root->node); in alloc_log_tree()
1236 return root; in alloc_log_tree()
1253 struct btrfs_root *root) in btrfs_add_log_tree() argument
1255 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_add_log_tree()
1264 log_root->root_key.offset = root->root_key.objectid; in btrfs_add_log_tree()
1276 WARN_ON(root->log_root); in btrfs_add_log_tree()
1277 root->log_root = log_root; in btrfs_add_log_tree()
1278 root->log_transid = 0; in btrfs_add_log_tree()
1279 root->log_transid_committed = -1; in btrfs_add_log_tree()
1280 root->last_log_commit = 0; in btrfs_add_log_tree()
1288 struct btrfs_root *root; in read_tree_root_path() local
1294 root = btrfs_alloc_root(fs_info, key->objectid, GFP_NOFS); in read_tree_root_path()
1295 if (!root) in read_tree_root_path()
1299 &root->root_item, &root->root_key); in read_tree_root_path()
1306 generation = btrfs_root_generation(&root->root_item); in read_tree_root_path()
1307 level = btrfs_root_level(&root->root_item); in read_tree_root_path()
1308 root->node = read_tree_block(fs_info, in read_tree_root_path()
1309 btrfs_root_bytenr(&root->root_item), in read_tree_root_path()
1311 if (IS_ERR(root->node)) { in read_tree_root_path()
1312 ret = PTR_ERR(root->node); in read_tree_root_path()
1313 root->node = NULL; in read_tree_root_path()
1315 } else if (!btrfs_buffer_uptodate(root->node, generation, 0)) { in read_tree_root_path()
1319 root->commit_root = btrfs_root_node(root); in read_tree_root_path()
1320 return root; in read_tree_root_path()
1322 btrfs_put_root(root); in read_tree_root_path()
1329 struct btrfs_root *root; in btrfs_read_tree_root() local
1335 root = read_tree_root_path(tree_root, path, key); in btrfs_read_tree_root()
1338 return root; in btrfs_read_tree_root()
1342 * Initialize subvolume root in-memory structure
1344 * @anon_dev: anonymous device to attach to the root, if zero, allocate new
1346 static int btrfs_init_fs_root(struct btrfs_root *root, dev_t anon_dev) in btrfs_init_fs_root() argument
1351 root->free_ino_ctl = kzalloc(sizeof(*root->free_ino_ctl), GFP_NOFS); in btrfs_init_fs_root()
1352 root->free_ino_pinned = kzalloc(sizeof(*root->free_ino_pinned), in btrfs_init_fs_root()
1354 if (!root->free_ino_pinned || !root->free_ino_ctl) { in btrfs_init_fs_root()
1364 ret = btrfs_drew_lock_init(&root->snapshot_lock); in btrfs_init_fs_root()
1369 if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID && in btrfs_init_fs_root()
1370 root->root_key.objectid != BTRFS_DATA_RELOC_TREE_OBJECTID) { in btrfs_init_fs_root()
1371 set_bit(BTRFS_ROOT_SHAREABLE, &root->state); in btrfs_init_fs_root()
1372 btrfs_check_and_init_root_item(&root->root_item); in btrfs_init_fs_root()
1375 btrfs_init_free_ino_ctl(root); in btrfs_init_fs_root()
1376 spin_lock_init(&root->ino_cache_lock); in btrfs_init_fs_root()
1377 init_waitqueue_head(&root->ino_cache_wait); in btrfs_init_fs_root()
1383 if (is_fstree(root->root_key.objectid) && in btrfs_init_fs_root()
1384 btrfs_root_refs(&root->root_item) > 0) { in btrfs_init_fs_root()
1386 ret = get_anon_bdev(&root->anon_dev); in btrfs_init_fs_root()
1390 root->anon_dev = anon_dev; in btrfs_init_fs_root()
1394 mutex_lock(&root->objectid_mutex); in btrfs_init_fs_root()
1395 ret = btrfs_find_highest_objectid(root, in btrfs_init_fs_root()
1396 &root->highest_objectid); in btrfs_init_fs_root()
1398 mutex_unlock(&root->objectid_mutex); in btrfs_init_fs_root()
1402 ASSERT(root->highest_objectid <= BTRFS_LAST_FREE_OBJECTID); in btrfs_init_fs_root()
1404 mutex_unlock(&root->objectid_mutex); in btrfs_init_fs_root()
1415 struct btrfs_root *root; in btrfs_lookup_fs_root() local
1418 root = radix_tree_lookup(&fs_info->fs_roots_radix, in btrfs_lookup_fs_root()
1420 if (root) in btrfs_lookup_fs_root()
1421 root = btrfs_grab_root(root); in btrfs_lookup_fs_root()
1423 return root; in btrfs_lookup_fs_root()
1452 struct btrfs_root *root) in btrfs_insert_fs_root() argument
1462 (unsigned long)root->root_key.objectid, in btrfs_insert_fs_root()
1463 root); in btrfs_insert_fs_root()
1465 btrfs_grab_root(root); in btrfs_insert_fs_root()
1466 set_bit(BTRFS_ROOT_IN_RADIX, &root->state); in btrfs_insert_fs_root()
1477 struct btrfs_root *root; in btrfs_check_leaked_roots() local
1482 root = list_first_entry(&fs_info->allocated_roots, in btrfs_check_leaked_roots()
1484 btrfs_err(fs_info, "leaked root %s refcount %d", in btrfs_check_leaked_roots()
1485 btrfs_root_name(root->root_key.objectid, buf), in btrfs_check_leaked_roots()
1486 refcount_read(&root->refs)); in btrfs_check_leaked_roots()
1487 while (refcount_read(&root->refs) > 1) in btrfs_check_leaked_roots()
1488 btrfs_put_root(root); in btrfs_check_leaked_roots()
1489 btrfs_put_root(root); in btrfs_check_leaked_roots()
1524 * Get an in-memory reference of a root structure.
1526 * For essential trees like root/extent tree, we grab it from fs_info directly.
1530 * Caller should release the root by calling btrfs_put_root() after the usage.
1533 * same root objectid.
1535 * @objectid: root id
1538 * @check_ref: whether to check root item references, If true, return -ENOENT
1545 struct btrfs_root *root; in btrfs_get_root_ref() local
1550 root = btrfs_get_global_root(fs_info, objectid); in btrfs_get_root_ref()
1551 if (root) in btrfs_get_root_ref()
1552 return root; in btrfs_get_root_ref()
1554 root = btrfs_lookup_fs_root(fs_info, objectid); in btrfs_get_root_ref()
1555 if (root) { in btrfs_get_root_ref()
1558 if (check_ref && btrfs_root_refs(&root->root_item) == 0) { in btrfs_get_root_ref()
1559 btrfs_put_root(root); in btrfs_get_root_ref()
1562 return root; in btrfs_get_root_ref()
1568 root = btrfs_read_tree_root(fs_info->tree_root, &key); in btrfs_get_root_ref()
1569 if (IS_ERR(root)) in btrfs_get_root_ref()
1570 return root; in btrfs_get_root_ref()
1572 if (check_ref && btrfs_root_refs(&root->root_item) == 0) { in btrfs_get_root_ref()
1577 ret = btrfs_init_fs_root(root, anon_dev); in btrfs_get_root_ref()
1595 set_bit(BTRFS_ROOT_ORPHAN_ITEM_INSERTED, &root->state); in btrfs_get_root_ref()
1597 ret = btrfs_insert_fs_root(fs_info, root); in btrfs_get_root_ref()
1599 btrfs_put_root(root); in btrfs_get_root_ref()
1604 return root; in btrfs_get_root_ref()
1606 btrfs_put_root(root); in btrfs_get_root_ref()
1611 * Get in-memory reference of a root structure
1624 * Get in-memory reference of a root structure, created as new, optionally pass
1638 * btrfs_get_fs_root_commit_root - return a root for the given objectid
1645 * up a fs root that is not in memory. If the root is not in memory we will
1646 * read the tree root commit root and look up the fs root from there. This is a
1647 * temporary root, it will not be inserted into the radix tree as it doesn't
1649 * backref code is finished using the root.
1655 struct btrfs_root *root; in btrfs_get_fs_root_commit_root() local
1661 * This can return -ENOENT if we ask for a root that doesn't exist, but in btrfs_get_fs_root_commit_root()
1663 * up a root that doesn't exist, unless there's corruption. So if root in btrfs_get_fs_root_commit_root()
1666 root = btrfs_get_global_root(fs_info, objectid); in btrfs_get_fs_root_commit_root()
1667 if (root) in btrfs_get_fs_root_commit_root()
1668 return root; in btrfs_get_fs_root_commit_root()
1670 root = btrfs_lookup_fs_root(fs_info, objectid); in btrfs_get_fs_root_commit_root()
1671 if (root) in btrfs_get_fs_root_commit_root()
1672 return root; in btrfs_get_fs_root_commit_root()
1677 root = read_tree_root_path(fs_info->tree_root, path, &key); in btrfs_get_fs_root_commit_root()
1680 return root; in btrfs_get_fs_root_commit_root()
1704 struct btrfs_root *root = arg; in cleaner_kthread() local
1705 struct btrfs_fs_info *fs_info = root->fs_info; in cleaner_kthread()
1738 again = btrfs_clean_one_deleted_snapshot(root); in cleaner_kthread()
1772 struct btrfs_root *root = arg; in transaction_kthread() local
1773 struct btrfs_fs_info *fs_info = root->fs_info; in transaction_kthread()
1805 trans = btrfs_attach_transaction(root); in transaction_kthread()
1832 * This will find the highest generation in the array of root backups. The
1837 * generation of the latest root in the array with the generation
1858 * copy all the root pointers into the super backup array.
1938 * read_backup_root - Reads a backup root based on the passed priority. Prio 0
1942 * priority - priority of backup root required
1944 * Returns backup root index on success and -EINVAL otherwise.
2008 static void free_root_extent_buffers(struct btrfs_root *root) in free_root_extent_buffers() argument
2010 if (root) { in free_root_extent_buffers()
2011 free_extent_buffer(root->node); in free_root_extent_buffers()
2012 free_extent_buffer(root->commit_root); in free_root_extent_buffers()
2013 root->node = NULL; in free_root_extent_buffers()
2014 root->commit_root = NULL; in free_root_extent_buffers()
2035 void btrfs_put_root(struct btrfs_root *root) in btrfs_put_root() argument
2037 if (!root) in btrfs_put_root()
2040 if (refcount_dec_and_test(&root->refs)) { in btrfs_put_root()
2041 WARN_ON(!RB_EMPTY_ROOT(&root->inode_tree)); in btrfs_put_root()
2042 WARN_ON(test_bit(BTRFS_ROOT_DEAD_RELOC_TREE, &root->state)); in btrfs_put_root()
2043 if (root->anon_dev) in btrfs_put_root()
2044 free_anon_bdev(root->anon_dev); in btrfs_put_root()
2045 btrfs_drew_lock_destroy(&root->snapshot_lock); in btrfs_put_root()
2046 free_root_extent_buffers(root); in btrfs_put_root()
2047 kfree(root->free_ino_ctl); in btrfs_put_root()
2048 kfree(root->free_ino_pinned); in btrfs_put_root()
2050 spin_lock(&root->fs_info->fs_roots_radix_lock); in btrfs_put_root()
2051 list_del_init(&root->leak_list); in btrfs_put_root()
2052 spin_unlock(&root->fs_info->fs_roots_radix_lock); in btrfs_put_root()
2054 kfree(root); in btrfs_put_root()
2126 BTRFS_I(inode)->root = btrfs_grab_root(fs_info->tree_root); in btrfs_init_btree_inode()
2297 struct btrfs_root *root; in btrfs_read_roots() local
2307 root = btrfs_read_tree_root(tree_root, &location); in btrfs_read_roots()
2308 if (IS_ERR(root)) { in btrfs_read_roots()
2309 ret = PTR_ERR(root); in btrfs_read_roots()
2312 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); in btrfs_read_roots()
2313 fs_info->extent_root = root; in btrfs_read_roots()
2316 root = btrfs_read_tree_root(tree_root, &location); in btrfs_read_roots()
2317 if (IS_ERR(root)) { in btrfs_read_roots()
2318 ret = PTR_ERR(root); in btrfs_read_roots()
2321 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); in btrfs_read_roots()
2322 fs_info->dev_root = root; in btrfs_read_roots()
2326 root = btrfs_read_tree_root(tree_root, &location); in btrfs_read_roots()
2327 if (IS_ERR(root)) { in btrfs_read_roots()
2328 ret = PTR_ERR(root); in btrfs_read_roots()
2331 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); in btrfs_read_roots()
2332 fs_info->csum_root = root; in btrfs_read_roots()
2338 root = btrfs_get_fs_root(tree_root->fs_info, in btrfs_read_roots()
2340 if (IS_ERR(root)) { in btrfs_read_roots()
2341 ret = PTR_ERR(root); in btrfs_read_roots()
2344 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); in btrfs_read_roots()
2345 fs_info->data_reloc_root = root; in btrfs_read_roots()
2348 root = btrfs_read_tree_root(tree_root, &location); in btrfs_read_roots()
2349 if (!IS_ERR(root)) { in btrfs_read_roots()
2350 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); in btrfs_read_roots()
2352 fs_info->quota_root = root; in btrfs_read_roots()
2356 root = btrfs_read_tree_root(tree_root, &location); in btrfs_read_roots()
2357 if (IS_ERR(root)) { in btrfs_read_roots()
2358 ret = PTR_ERR(root); in btrfs_read_roots()
2362 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); in btrfs_read_roots()
2363 fs_info->uuid_root = root; in btrfs_read_roots()
2368 root = btrfs_read_tree_root(tree_root, &location); in btrfs_read_roots()
2369 if (IS_ERR(root)) { in btrfs_read_roots()
2370 ret = PTR_ERR(root); in btrfs_read_roots()
2373 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); in btrfs_read_roots()
2374 fs_info->free_space_root = root; in btrfs_read_roots()
2379 btrfs_warn(fs_info, "failed to read root (objectid=%llu): %d", in btrfs_read_roots()
2453 /* Root alignment check */ in validate_super()
2635 btrfs_warn(fs_info, "couldn't read tree root"); in init_tree_roots()
2641 btrfs_warn(fs_info, "error while reading tree root"); in init_tree_roots()
3117 btrfs_err(fs_info, "failed to read chunk root"); in open_ctree()
3152 * If we have a uuid root and we're not being told to rescan we need to in open_ctree()
3923 /* Drop a fs root from the radix tree and free it. */
3925 struct btrfs_root *root) in btrfs_drop_and_free_fs_root() argument
3931 (unsigned long)root->root_key.objectid); in btrfs_drop_and_free_fs_root()
3932 if (test_and_clear_bit(BTRFS_ROOT_IN_RADIX, &root->state)) in btrfs_drop_and_free_fs_root()
3937 ASSERT(root->log_root == NULL); in btrfs_drop_and_free_fs_root()
3938 if (root->reloc_root) { in btrfs_drop_and_free_fs_root()
3939 btrfs_put_root(root->reloc_root); in btrfs_drop_and_free_fs_root()
3940 root->reloc_root = NULL; in btrfs_drop_and_free_fs_root()
3944 if (root->free_ino_pinned) in btrfs_drop_and_free_fs_root()
3945 __btrfs_remove_free_space_cache(root->free_ino_pinned); in btrfs_drop_and_free_fs_root()
3946 if (root->free_ino_ctl) in btrfs_drop_and_free_fs_root()
3947 __btrfs_remove_free_space_cache(root->free_ino_ctl); in btrfs_drop_and_free_fs_root()
3948 if (root->ino_cache_inode) { in btrfs_drop_and_free_fs_root()
3949 iput(root->ino_cache_inode); in btrfs_drop_and_free_fs_root()
3950 root->ino_cache_inode = NULL; in btrfs_drop_and_free_fs_root()
3953 btrfs_put_root(root); in btrfs_drop_and_free_fs_root()
4008 struct btrfs_root *root = fs_info->tree_root; in btrfs_commit_super() local
4020 trans = btrfs_join_transaction(root); in btrfs_commit_super()
4175 struct btrfs_root *root; in btrfs_mark_buffer_dirty() local
4188 root = BTRFS_I(buf->pages[0]->mapping->host)->root; in btrfs_mark_buffer_dirty()
4189 fs_info = root->fs_info; in btrfs_mark_buffer_dirty()
4296 static void btrfs_destroy_ordered_extents(struct btrfs_root *root) in btrfs_destroy_ordered_extents() argument
4300 spin_lock(&root->ordered_extent_lock); in btrfs_destroy_ordered_extents()
4305 list_for_each_entry(ordered, &root->ordered_extents, in btrfs_destroy_ordered_extents()
4308 spin_unlock(&root->ordered_extent_lock); in btrfs_destroy_ordered_extents()
4313 struct btrfs_root *root; in btrfs_destroy_all_ordered_extents() local
4321 root = list_first_entry(&splice, struct btrfs_root, in btrfs_destroy_all_ordered_extents()
4323 list_move_tail(&root->ordered_root, in btrfs_destroy_all_ordered_extents()
4327 btrfs_destroy_ordered_extents(root); in btrfs_destroy_all_ordered_extents()
4426 static void btrfs_destroy_delalloc_inodes(struct btrfs_root *root) in btrfs_destroy_delalloc_inodes() argument
4433 spin_lock(&root->delalloc_lock); in btrfs_destroy_delalloc_inodes()
4434 list_splice_init(&root->delalloc_inodes, &splice); in btrfs_destroy_delalloc_inodes()
4440 __btrfs_del_delalloc_inode(root, btrfs_inode); in btrfs_destroy_delalloc_inodes()
4441 spin_unlock(&root->delalloc_lock); in btrfs_destroy_delalloc_inodes()
4452 spin_lock(&root->delalloc_lock); in btrfs_destroy_delalloc_inodes()
4454 spin_unlock(&root->delalloc_lock); in btrfs_destroy_delalloc_inodes()
4459 struct btrfs_root *root; in btrfs_destroy_all_delalloc_inodes() local
4467 root = list_first_entry(&splice, struct btrfs_root, in btrfs_destroy_all_delalloc_inodes()
4469 root = btrfs_grab_root(root); in btrfs_destroy_all_delalloc_inodes()
4470 BUG_ON(!root); in btrfs_destroy_all_delalloc_inodes()
4473 btrfs_destroy_delalloc_inodes(root); in btrfs_destroy_all_delalloc_inodes()
4474 btrfs_put_root(root); in btrfs_destroy_all_delalloc_inodes()