Lines Matching refs:root
484 fs_info = BTRFS_I(mapping->host)->root->fs_info; in btree_writepages()
511 btrfs_warn(BTRFS_I(folio->mapping->host)->root->fs_info, in btree_invalidate_folio()
621 static void __setup_root(struct btrfs_root *root, struct btrfs_fs_info *fs_info, in __setup_root() argument
626 memset(&root->root_key, 0, sizeof(root->root_key)); in __setup_root()
627 memset(&root->root_item, 0, sizeof(root->root_item)); in __setup_root()
628 memset(&root->defrag_progress, 0, sizeof(root->defrag_progress)); in __setup_root()
629 root->fs_info = fs_info; in __setup_root()
630 root->root_key.objectid = objectid; in __setup_root()
631 root->node = NULL; in __setup_root()
632 root->commit_root = NULL; in __setup_root()
633 root->state = 0; in __setup_root()
634 RB_CLEAR_NODE(&root->rb_node); in __setup_root()
636 root->last_trans = 0; in __setup_root()
637 root->free_objectid = 0; in __setup_root()
638 root->nr_delalloc_inodes = 0; in __setup_root()
639 root->nr_ordered_extents = 0; in __setup_root()
640 root->inode_tree = RB_ROOT; in __setup_root()
641 INIT_RADIX_TREE(&root->delayed_nodes_tree, GFP_ATOMIC); in __setup_root()
643 btrfs_init_root_block_rsv(root); in __setup_root()
645 INIT_LIST_HEAD(&root->dirty_list); in __setup_root()
646 INIT_LIST_HEAD(&root->root_list); in __setup_root()
647 INIT_LIST_HEAD(&root->delalloc_inodes); in __setup_root()
648 INIT_LIST_HEAD(&root->delalloc_root); in __setup_root()
649 INIT_LIST_HEAD(&root->ordered_extents); in __setup_root()
650 INIT_LIST_HEAD(&root->ordered_root); in __setup_root()
651 INIT_LIST_HEAD(&root->reloc_dirty_list); in __setup_root()
652 INIT_LIST_HEAD(&root->logged_list[0]); in __setup_root()
653 INIT_LIST_HEAD(&root->logged_list[1]); in __setup_root()
654 spin_lock_init(&root->inode_lock); in __setup_root()
655 spin_lock_init(&root->delalloc_lock); in __setup_root()
656 spin_lock_init(&root->ordered_extent_lock); in __setup_root()
657 spin_lock_init(&root->accounting_lock); in __setup_root()
658 spin_lock_init(&root->log_extents_lock[0]); in __setup_root()
659 spin_lock_init(&root->log_extents_lock[1]); in __setup_root()
660 spin_lock_init(&root->qgroup_meta_rsv_lock); in __setup_root()
661 mutex_init(&root->objectid_mutex); in __setup_root()
662 mutex_init(&root->log_mutex); in __setup_root()
663 mutex_init(&root->ordered_extent_mutex); in __setup_root()
664 mutex_init(&root->delalloc_mutex); in __setup_root()
665 init_waitqueue_head(&root->qgroup_flush_wait); in __setup_root()
666 init_waitqueue_head(&root->log_writer_wait); in __setup_root()
667 init_waitqueue_head(&root->log_commit_wait[0]); in __setup_root()
668 init_waitqueue_head(&root->log_commit_wait[1]); in __setup_root()
669 INIT_LIST_HEAD(&root->log_ctxs[0]); in __setup_root()
670 INIT_LIST_HEAD(&root->log_ctxs[1]); in __setup_root()
671 atomic_set(&root->log_commit[0], 0); in __setup_root()
672 atomic_set(&root->log_commit[1], 0); in __setup_root()
673 atomic_set(&root->log_writers, 0); in __setup_root()
674 atomic_set(&root->log_batch, 0); in __setup_root()
675 refcount_set(&root->refs, 1); in __setup_root()
676 atomic_set(&root->snapshot_force_cow, 0); in __setup_root()
677 atomic_set(&root->nr_swapfiles, 0); in __setup_root()
678 root->log_transid = 0; in __setup_root()
679 root->log_transid_committed = -1; in __setup_root()
680 root->last_log_commit = 0; in __setup_root()
681 root->anon_dev = 0; in __setup_root()
683 extent_io_tree_init(fs_info, &root->dirty_log_pages, in __setup_root()
685 extent_io_tree_init(fs_info, &root->log_csum_range, in __setup_root()
689 spin_lock_init(&root->root_item_lock); in __setup_root()
690 btrfs_qgroup_init_swapped_blocks(&root->swapped_blocks); in __setup_root()
692 INIT_LIST_HEAD(&root->leak_list); in __setup_root()
694 list_add_tail(&root->leak_list, &fs_info->allocated_roots); in __setup_root()
702 struct btrfs_root *root = kzalloc(sizeof(*root), flags); in btrfs_alloc_root() local
703 if (root) in btrfs_alloc_root()
704 __setup_root(root, fs_info, objectid); in btrfs_alloc_root()
705 return root; in btrfs_alloc_root()
712 struct btrfs_root *root; in btrfs_alloc_dummy_root() local
717 root = btrfs_alloc_root(fs_info, BTRFS_ROOT_TREE_OBJECTID, GFP_KERNEL); in btrfs_alloc_dummy_root()
718 if (!root) in btrfs_alloc_dummy_root()
722 root->alloc_bytenr = 0; in btrfs_alloc_dummy_root()
724 return root; in btrfs_alloc_dummy_root()
739 const struct btrfs_root *root = rb_entry(node, struct btrfs_root, rb_node); in global_root_key_cmp() local
741 return btrfs_comp_cpu_keys(key, &root->root_key); in global_root_key_cmp()
744 int btrfs_global_root_insert(struct btrfs_root *root) in btrfs_global_root_insert() argument
746 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_global_root_insert()
751 tmp = rb_find_add(&root->rb_node, &fs_info->global_root_tree, global_root_cmp); in btrfs_global_root_insert()
757 root->root_key.objectid, root->root_key.offset); in btrfs_global_root_insert()
762 void btrfs_global_root_delete(struct btrfs_root *root) in btrfs_global_root_delete() argument
764 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_global_root_delete()
767 rb_erase(&root->rb_node, &fs_info->global_root_tree); in btrfs_global_root_delete()
775 struct btrfs_root *root = NULL; in btrfs_global_root() local
780 root = container_of(node, struct btrfs_root, rb_node); in btrfs_global_root()
783 return root; in btrfs_global_root()
842 struct btrfs_root *root; in btrfs_create_tree() local
852 root = btrfs_alloc_root(fs_info, objectid, GFP_KERNEL); in btrfs_create_tree()
854 if (!root) in btrfs_create_tree()
857 root->root_key.objectid = objectid; in btrfs_create_tree()
858 root->root_key.type = BTRFS_ROOT_ITEM_KEY; in btrfs_create_tree()
859 root->root_key.offset = 0; in btrfs_create_tree()
861 leaf = btrfs_alloc_tree_block(trans, root, 0, objectid, NULL, 0, 0, 0, in btrfs_create_tree()
869 root->node = leaf; in btrfs_create_tree()
872 root->commit_root = btrfs_root_node(root); in btrfs_create_tree()
873 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); in btrfs_create_tree()
875 btrfs_set_root_flags(&root->root_item, 0); in btrfs_create_tree()
876 btrfs_set_root_limit(&root->root_item, 0); in btrfs_create_tree()
877 btrfs_set_root_bytenr(&root->root_item, leaf->start); in btrfs_create_tree()
878 btrfs_set_root_generation(&root->root_item, trans->transid); in btrfs_create_tree()
879 btrfs_set_root_level(&root->root_item, 0); in btrfs_create_tree()
880 btrfs_set_root_refs(&root->root_item, 1); in btrfs_create_tree()
881 btrfs_set_root_used(&root->root_item, leaf->len); in btrfs_create_tree()
882 btrfs_set_root_last_snapshot(&root->root_item, 0); in btrfs_create_tree()
883 btrfs_set_root_dirid(&root->root_item, 0); in btrfs_create_tree()
885 generate_random_guid(root->root_item.uuid); in btrfs_create_tree()
887 export_guid(root->root_item.uuid, &guid_null); in btrfs_create_tree()
888 btrfs_set_root_drop_level(&root->root_item, 0); in btrfs_create_tree()
895 ret = btrfs_insert_root(trans, tree_root, &key, &root->root_item); in btrfs_create_tree()
899 return root; in btrfs_create_tree()
902 btrfs_put_root(root); in btrfs_create_tree()
910 struct btrfs_root *root; in alloc_log_tree() local
912 root = btrfs_alloc_root(fs_info, BTRFS_TREE_LOG_OBJECTID, GFP_NOFS); in alloc_log_tree()
913 if (!root) in alloc_log_tree()
916 root->root_key.objectid = BTRFS_TREE_LOG_OBJECTID; in alloc_log_tree()
917 root->root_key.type = BTRFS_ROOT_ITEM_KEY; in alloc_log_tree()
918 root->root_key.offset = BTRFS_TREE_LOG_OBJECTID; in alloc_log_tree()
920 return root; in alloc_log_tree()
924 struct btrfs_root *root) in btrfs_alloc_log_tree_node() argument
938 leaf = btrfs_alloc_tree_block(trans, root, 0, BTRFS_TREE_LOG_OBJECTID, in btrfs_alloc_log_tree_node()
943 root->node = leaf; in btrfs_alloc_log_tree_node()
945 btrfs_mark_buffer_dirty(trans, root->node); in btrfs_alloc_log_tree_node()
946 btrfs_tree_unlock(root->node); in btrfs_alloc_log_tree_node()
975 struct btrfs_root *root) in btrfs_add_log_tree() argument
977 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_add_log_tree()
993 log_root->root_key.offset = root->root_key.objectid; in btrfs_add_log_tree()
1005 WARN_ON(root->log_root); in btrfs_add_log_tree()
1006 root->log_root = log_root; in btrfs_add_log_tree()
1007 root->log_transid = 0; in btrfs_add_log_tree()
1008 root->log_transid_committed = -1; in btrfs_add_log_tree()
1009 root->last_log_commit = 0; in btrfs_add_log_tree()
1017 struct btrfs_root *root; in read_tree_root_path() local
1024 root = btrfs_alloc_root(fs_info, key->objectid, GFP_NOFS); in read_tree_root_path()
1025 if (!root) in read_tree_root_path()
1029 &root->root_item, &root->root_key); in read_tree_root_path()
1036 generation = btrfs_root_generation(&root->root_item); in read_tree_root_path()
1037 level = btrfs_root_level(&root->root_item); in read_tree_root_path()
1041 root->node = read_tree_block(fs_info, btrfs_root_bytenr(&root->root_item), in read_tree_root_path()
1043 if (IS_ERR(root->node)) { in read_tree_root_path()
1044 ret = PTR_ERR(root->node); in read_tree_root_path()
1045 root->node = NULL; in read_tree_root_path()
1048 if (!btrfs_buffer_uptodate(root->node, generation, 0)) { in read_tree_root_path()
1058 root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID && in read_tree_root_path()
1059 root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID && in read_tree_root_path()
1060 root->root_key.objectid != btrfs_header_owner(root->node)) { in read_tree_root_path()
1063 root->root_key.objectid, root->node->start, in read_tree_root_path()
1064 btrfs_header_owner(root->node), in read_tree_root_path()
1065 root->root_key.objectid); in read_tree_root_path()
1069 root->commit_root = btrfs_root_node(root); in read_tree_root_path()
1070 return root; in read_tree_root_path()
1072 btrfs_put_root(root); in read_tree_root_path()
1079 struct btrfs_root *root; in btrfs_read_tree_root() local
1085 root = read_tree_root_path(tree_root, path, key); in btrfs_read_tree_root()
1088 return root; in btrfs_read_tree_root()
1096 static int btrfs_init_fs_root(struct btrfs_root *root, dev_t anon_dev) in btrfs_init_fs_root() argument
1100 btrfs_drew_lock_init(&root->snapshot_lock); in btrfs_init_fs_root()
1102 if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID && in btrfs_init_fs_root()
1103 !btrfs_is_data_reloc_root(root) && in btrfs_init_fs_root()
1104 is_fstree(root->root_key.objectid)) { in btrfs_init_fs_root()
1105 set_bit(BTRFS_ROOT_SHAREABLE, &root->state); in btrfs_init_fs_root()
1106 btrfs_check_and_init_root_item(&root->root_item); in btrfs_init_fs_root()
1113 if (is_fstree(root->root_key.objectid) && in btrfs_init_fs_root()
1114 btrfs_root_refs(&root->root_item) > 0) { in btrfs_init_fs_root()
1116 ret = get_anon_bdev(&root->anon_dev); in btrfs_init_fs_root()
1120 root->anon_dev = anon_dev; in btrfs_init_fs_root()
1124 mutex_lock(&root->objectid_mutex); in btrfs_init_fs_root()
1125 ret = btrfs_init_root_free_objectid(root); in btrfs_init_fs_root()
1127 mutex_unlock(&root->objectid_mutex); in btrfs_init_fs_root()
1131 ASSERT(root->free_objectid <= BTRFS_LAST_FREE_OBJECTID); in btrfs_init_fs_root()
1133 mutex_unlock(&root->objectid_mutex); in btrfs_init_fs_root()
1144 struct btrfs_root *root; in btrfs_lookup_fs_root() local
1147 root = radix_tree_lookup(&fs_info->fs_roots_radix, in btrfs_lookup_fs_root()
1149 root = btrfs_grab_root(root); in btrfs_lookup_fs_root()
1151 return root; in btrfs_lookup_fs_root()
1188 struct btrfs_root *root) in btrfs_insert_fs_root() argument
1198 (unsigned long)root->root_key.objectid, in btrfs_insert_fs_root()
1199 root); in btrfs_insert_fs_root()
1201 btrfs_grab_root(root); in btrfs_insert_fs_root()
1202 set_bit(BTRFS_ROOT_IN_RADIX, &root->state); in btrfs_insert_fs_root()
1213 struct btrfs_root *root; in btrfs_check_leaked_roots() local
1218 root = list_first_entry(&fs_info->allocated_roots, in btrfs_check_leaked_roots()
1221 btrfs_root_name(&root->root_key, buf), in btrfs_check_leaked_roots()
1222 refcount_read(&root->refs)); in btrfs_check_leaked_roots()
1223 while (refcount_read(&root->refs) > 1) in btrfs_check_leaked_roots()
1224 btrfs_put_root(root); in btrfs_check_leaked_roots()
1225 btrfs_put_root(root); in btrfs_check_leaked_roots()
1232 struct btrfs_root *root; in free_global_roots() local
1236 root = rb_entry(node, struct btrfs_root, rb_node); in free_global_roots()
1237 rb_erase(&root->rb_node, &fs_info->global_root_tree); in free_global_roots()
1238 btrfs_put_root(root); in free_global_roots()
1293 struct btrfs_root *root; in btrfs_get_root_ref() local
1298 root = btrfs_get_global_root(fs_info, objectid); in btrfs_get_root_ref()
1299 if (root) in btrfs_get_root_ref()
1300 return root; in btrfs_get_root_ref()
1312 root = btrfs_lookup_fs_root(fs_info, objectid); in btrfs_get_root_ref()
1313 if (root) { in btrfs_get_root_ref()
1325 if (check_ref && btrfs_root_refs(&root->root_item) == 0) { in btrfs_get_root_ref()
1326 btrfs_put_root(root); in btrfs_get_root_ref()
1329 return root; in btrfs_get_root_ref()
1335 root = btrfs_read_tree_root(fs_info->tree_root, &key); in btrfs_get_root_ref()
1336 if (IS_ERR(root)) in btrfs_get_root_ref()
1337 return root; in btrfs_get_root_ref()
1339 if (check_ref && btrfs_root_refs(&root->root_item) == 0) { in btrfs_get_root_ref()
1344 ret = btrfs_init_fs_root(root, anon_dev ? *anon_dev : 0); in btrfs_get_root_ref()
1362 set_bit(BTRFS_ROOT_ORPHAN_ITEM_INSERTED, &root->state); in btrfs_get_root_ref()
1364 ret = btrfs_insert_fs_root(fs_info, root); in btrfs_get_root_ref()
1367 btrfs_put_root(root); in btrfs_get_root_ref()
1372 return root; in btrfs_get_root_ref()
1381 root->anon_dev = 0; in btrfs_get_root_ref()
1382 btrfs_put_root(root); in btrfs_get_root_ref()
1431 struct btrfs_root *root; in btrfs_get_fs_root_commit_root() local
1442 root = btrfs_get_global_root(fs_info, objectid); in btrfs_get_fs_root_commit_root()
1443 if (root) in btrfs_get_fs_root_commit_root()
1444 return root; in btrfs_get_fs_root_commit_root()
1446 root = btrfs_lookup_fs_root(fs_info, objectid); in btrfs_get_fs_root_commit_root()
1447 if (root) in btrfs_get_fs_root_commit_root()
1448 return root; in btrfs_get_fs_root_commit_root()
1453 root = read_tree_root_path(fs_info->tree_root, path, &key); in btrfs_get_fs_root_commit_root()
1456 return root; in btrfs_get_fs_root_commit_root()
1538 struct btrfs_root *root = arg; in transaction_kthread() local
1539 struct btrfs_fs_info *fs_info = root->fs_info; in transaction_kthread()
1573 trans = btrfs_attach_transaction(root); in transaction_kthread()
1783 static void free_root_extent_buffers(struct btrfs_root *root) in free_root_extent_buffers() argument
1785 if (root) { in free_root_extent_buffers()
1786 free_extent_buffer(root->node); in free_root_extent_buffers()
1787 free_extent_buffer(root->commit_root); in free_root_extent_buffers()
1788 root->node = NULL; in free_root_extent_buffers()
1789 root->commit_root = NULL; in free_root_extent_buffers()
1795 struct btrfs_root *root, *tmp; in free_global_root_pointers() local
1797 rbtree_postorder_for_each_entry_safe(root, tmp, in free_global_root_pointers()
1800 free_root_extent_buffers(root); in free_global_root_pointers()
1819 void btrfs_put_root(struct btrfs_root *root) in btrfs_put_root() argument
1821 if (!root) in btrfs_put_root()
1824 if (refcount_dec_and_test(&root->refs)) { in btrfs_put_root()
1825 WARN_ON(!RB_EMPTY_ROOT(&root->inode_tree)); in btrfs_put_root()
1826 WARN_ON(test_bit(BTRFS_ROOT_DEAD_RELOC_TREE, &root->state)); in btrfs_put_root()
1827 if (root->anon_dev) in btrfs_put_root()
1828 free_anon_bdev(root->anon_dev); in btrfs_put_root()
1829 free_root_extent_buffers(root); in btrfs_put_root()
1831 spin_lock(&root->fs_info->fs_roots_radix_lock); in btrfs_put_root()
1832 list_del_init(&root->leak_list); in btrfs_put_root()
1833 spin_unlock(&root->fs_info->fs_roots_radix_lock); in btrfs_put_root()
1835 kfree(root); in btrfs_put_root()
1915 BTRFS_I(inode)->root = btrfs_grab_root(fs_info->tree_root); in btrfs_init_btree_inode()
2104 struct btrfs_root *root; in load_global_roots_objectid() local
2149 root = read_tree_root_path(tree_root, path, &key); in load_global_roots_objectid()
2150 if (IS_ERR(root)) { in load_global_roots_objectid()
2152 ret = PTR_ERR(root); in load_global_roots_objectid()
2155 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); in load_global_roots_objectid()
2156 ret = btrfs_global_root_insert(root); in load_global_roots_objectid()
2158 btrfs_put_root(root); in load_global_roots_objectid()
2211 struct btrfs_root *root; in btrfs_read_roots() local
2226 root = btrfs_read_tree_root(tree_root, &location); in btrfs_read_roots()
2227 if (IS_ERR(root)) { in btrfs_read_roots()
2229 ret = PTR_ERR(root); in btrfs_read_roots()
2233 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); in btrfs_read_roots()
2234 fs_info->block_group_root = root; in btrfs_read_roots()
2239 root = btrfs_read_tree_root(tree_root, &location); in btrfs_read_roots()
2240 if (IS_ERR(root)) { in btrfs_read_roots()
2242 ret = PTR_ERR(root); in btrfs_read_roots()
2246 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); in btrfs_read_roots()
2247 fs_info->dev_root = root; in btrfs_read_roots()
2258 root = btrfs_get_fs_root(tree_root->fs_info, in btrfs_read_roots()
2260 if (IS_ERR(root)) { in btrfs_read_roots()
2262 ret = PTR_ERR(root); in btrfs_read_roots()
2266 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); in btrfs_read_roots()
2267 fs_info->data_reloc_root = root; in btrfs_read_roots()
2271 root = btrfs_read_tree_root(tree_root, &location); in btrfs_read_roots()
2272 if (!IS_ERR(root)) { in btrfs_read_roots()
2273 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); in btrfs_read_roots()
2275 fs_info->quota_root = root; in btrfs_read_roots()
2279 root = btrfs_read_tree_root(tree_root, &location); in btrfs_read_roots()
2280 if (IS_ERR(root)) { in btrfs_read_roots()
2282 ret = PTR_ERR(root); in btrfs_read_roots()
2287 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); in btrfs_read_roots()
2288 fs_info->uuid_root = root; in btrfs_read_roots()
2540 static int load_super_root(struct btrfs_root *root, u64 bytenr, u64 gen, int level) in load_super_root() argument
2545 .owner_root = root->root_key.objectid in load_super_root()
2549 root->node = read_tree_block(root->fs_info, bytenr, &check); in load_super_root()
2550 if (IS_ERR(root->node)) { in load_super_root()
2551 ret = PTR_ERR(root->node); in load_super_root()
2552 root->node = NULL; in load_super_root()
2555 if (!extent_buffer_uptodate(root->node)) { in load_super_root()
2556 free_extent_buffer(root->node); in load_super_root()
2557 root->node = NULL; in load_super_root()
2561 btrfs_set_root_node(&root->root_item, root->node); in load_super_root()
2562 root->commit_root = btrfs_root_node(root); in load_super_root()
2563 btrfs_set_root_refs(&root->root_item, 1); in load_super_root()
4172 struct btrfs_root *root) in btrfs_drop_and_free_fs_root() argument
4178 (unsigned long)root->root_key.objectid); in btrfs_drop_and_free_fs_root()
4179 if (test_and_clear_bit(BTRFS_ROOT_IN_RADIX, &root->state)) in btrfs_drop_and_free_fs_root()
4184 ASSERT(root->log_root == NULL); in btrfs_drop_and_free_fs_root()
4185 if (root->reloc_root) { in btrfs_drop_and_free_fs_root()
4186 btrfs_put_root(root->reloc_root); in btrfs_drop_and_free_fs_root()
4187 root->reloc_root = NULL; in btrfs_drop_and_free_fs_root()
4192 btrfs_put_root(root); in btrfs_drop_and_free_fs_root()
4197 struct btrfs_root *root = fs_info->tree_root; in btrfs_commit_super() local
4209 trans = btrfs_join_transaction(root); in btrfs_commit_super()
4548 static void btrfs_destroy_ordered_extents(struct btrfs_root *root) in btrfs_destroy_ordered_extents() argument
4552 spin_lock(&root->ordered_extent_lock); in btrfs_destroy_ordered_extents()
4557 list_for_each_entry(ordered, &root->ordered_extents, in btrfs_destroy_ordered_extents()
4560 spin_unlock(&root->ordered_extent_lock); in btrfs_destroy_ordered_extents()
4565 struct btrfs_root *root; in btrfs_destroy_all_ordered_extents() local
4571 root = list_first_entry(&splice, struct btrfs_root, in btrfs_destroy_all_ordered_extents()
4573 list_move_tail(&root->ordered_root, in btrfs_destroy_all_ordered_extents()
4577 btrfs_destroy_ordered_extents(root); in btrfs_destroy_all_ordered_extents()
4669 static void btrfs_destroy_delalloc_inodes(struct btrfs_root *root) in btrfs_destroy_delalloc_inodes() argument
4674 spin_lock(&root->delalloc_lock); in btrfs_destroy_delalloc_inodes()
4675 list_splice_init(&root->delalloc_inodes, &splice); in btrfs_destroy_delalloc_inodes()
4681 __btrfs_del_delalloc_inode(root, btrfs_inode); in btrfs_destroy_delalloc_inodes()
4682 spin_unlock(&root->delalloc_lock); in btrfs_destroy_delalloc_inodes()
4697 spin_lock(&root->delalloc_lock); in btrfs_destroy_delalloc_inodes()
4699 spin_unlock(&root->delalloc_lock); in btrfs_destroy_delalloc_inodes()
4704 struct btrfs_root *root; in btrfs_destroy_all_delalloc_inodes() local
4710 root = list_first_entry(&splice, struct btrfs_root, in btrfs_destroy_all_delalloc_inodes()
4712 root = btrfs_grab_root(root); in btrfs_destroy_all_delalloc_inodes()
4713 BUG_ON(!root); in btrfs_destroy_all_delalloc_inodes()
4716 btrfs_destroy_delalloc_inodes(root); in btrfs_destroy_all_delalloc_inodes()
4717 btrfs_put_root(root); in btrfs_destroy_all_delalloc_inodes()
4863 struct btrfs_root *root = gang[i]; in btrfs_free_all_qgroup_pertrans() local
4865 btrfs_qgroup_free_meta_all_pertrans(root); in btrfs_free_all_qgroup_pertrans()
4867 (unsigned long)root->root_key.objectid, in btrfs_free_all_qgroup_pertrans()
4961 int btrfs_init_root_free_objectid(struct btrfs_root *root) in btrfs_init_root_free_objectid() argument
4977 ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0); in btrfs_init_root_free_objectid()
4985 root->free_objectid = max_t(u64, found_key.objectid + 1, in btrfs_init_root_free_objectid()
4988 root->free_objectid = BTRFS_FIRST_FREE_OBJECTID; in btrfs_init_root_free_objectid()
4996 int btrfs_get_free_objectid(struct btrfs_root *root, u64 *objectid) in btrfs_get_free_objectid() argument
4999 mutex_lock(&root->objectid_mutex); in btrfs_get_free_objectid()
5001 if (unlikely(root->free_objectid >= BTRFS_LAST_FREE_OBJECTID)) { in btrfs_get_free_objectid()
5002 btrfs_warn(root->fs_info, in btrfs_get_free_objectid()
5004 root->root_key.objectid); in btrfs_get_free_objectid()
5009 *objectid = root->free_objectid++; in btrfs_get_free_objectid()
5012 mutex_unlock(&root->objectid_mutex); in btrfs_get_free_objectid()