Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

btrfs: track the csum, extent, and free space trees in a rb tree

In the future we are going to have multiple copies of these trees. To
facilitate this we need a way to lookup the different roots we are
looking for. Handle this by adding a global root rb tree that is
indexed on the root->root_key. Then instead of loading the roots at
mount time with individually targeted keys, simply search the tree_root
for anything with the specific objectid we want. This will make it
straightforward to support both old style and new style file systems.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Josef Bacik and committed by
David Sterba
abed4aaa 7fcf8a00

+263 -80
+6 -3
fs/btrfs/ctree.h
··· 623 623 struct btrfs_fs_info { 624 624 u8 chunk_tree_uuid[BTRFS_UUID_SIZE]; 625 625 unsigned long flags; 626 - struct btrfs_root *_extent_root; 627 626 struct btrfs_root *tree_root; 628 627 struct btrfs_root *chunk_root; 629 628 struct btrfs_root *dev_root; 630 629 struct btrfs_root *fs_root; 631 - struct btrfs_root *_csum_root; 632 630 struct btrfs_root *quota_root; 633 631 struct btrfs_root *uuid_root; 634 - struct btrfs_root *_free_space_root; 635 632 struct btrfs_root *data_reloc_root; 636 633 637 634 /* the log root tree is a directory of all the other log roots */ 638 635 struct btrfs_root *log_root_tree; 636 + 637 + /* The tree that holds the global roots (csum, extent, etc) */ 638 + rwlock_t global_root_lock; 639 + struct rb_root global_root_tree; 639 640 640 641 spinlock_t fs_roots_radix_lock; 641 642 struct radix_tree_root fs_roots_radix; ··· 1130 1129 * and for the extent tree extent_root root. 1131 1130 */ 1132 1131 struct btrfs_root { 1132 + struct rb_node rb_node; 1133 + 1133 1134 struct extent_buffer *node; 1134 1135 1135 1136 struct extent_buffer *commit_root;
+218 -58
fs/btrfs/disk-io.c
··· 1149 1149 root->node = NULL; 1150 1150 root->commit_root = NULL; 1151 1151 root->state = 0; 1152 + RB_CLEAR_NODE(&root->rb_node); 1152 1153 1153 1154 root->last_trans = 0; 1154 1155 root->free_objectid = 0; ··· 1242 1241 return root; 1243 1242 } 1244 1243 #endif 1244 + 1245 + static int global_root_cmp(struct rb_node *a_node, const struct rb_node *b_node) 1246 + { 1247 + const struct btrfs_root *a = rb_entry(a_node, struct btrfs_root, rb_node); 1248 + const struct btrfs_root *b = rb_entry(b_node, struct btrfs_root, rb_node); 1249 + 1250 + return btrfs_comp_cpu_keys(&a->root_key, &b->root_key); 1251 + } 1252 + 1253 + static int global_root_key_cmp(const void *k, const struct rb_node *node) 1254 + { 1255 + const struct btrfs_key *key = k; 1256 + const struct btrfs_root *root = rb_entry(node, struct btrfs_root, rb_node); 1257 + 1258 + return btrfs_comp_cpu_keys(key, &root->root_key); 1259 + } 1260 + 1261 + int btrfs_global_root_insert(struct btrfs_root *root) 1262 + { 1263 + struct btrfs_fs_info *fs_info = root->fs_info; 1264 + struct rb_node *tmp; 1265 + 1266 + write_lock(&fs_info->global_root_lock); 1267 + tmp = rb_find_add(&root->rb_node, &fs_info->global_root_tree, global_root_cmp); 1268 + write_unlock(&fs_info->global_root_lock); 1269 + ASSERT(!tmp); 1270 + 1271 + return tmp ? -EEXIST : 0; 1272 + } 1273 + 1274 + void btrfs_global_root_delete(struct btrfs_root *root) 1275 + { 1276 + struct btrfs_fs_info *fs_info = root->fs_info; 1277 + 1278 + write_lock(&fs_info->global_root_lock); 1279 + rb_erase(&root->rb_node, &fs_info->global_root_tree); 1280 + write_unlock(&fs_info->global_root_lock); 1281 + } 1282 + 1283 + struct btrfs_root *btrfs_global_root(struct btrfs_fs_info *fs_info, 1284 + struct btrfs_key *key) 1285 + { 1286 + struct rb_node *node; 1287 + struct btrfs_root *root = NULL; 1288 + 1289 + read_lock(&fs_info->global_root_lock); 1290 + node = rb_find(key, &fs_info->global_root_tree, global_root_key_cmp); 1291 + if (node) 1292 + root = container_of(node, struct btrfs_root, rb_node); 1293 + read_unlock(&fs_info->global_root_lock); 1294 + 1295 + return root; 1296 + } 1297 + 1298 + struct btrfs_root *btrfs_csum_root(struct btrfs_fs_info *fs_info, u64 bytenr) 1299 + { 1300 + struct btrfs_key key = { 1301 + .objectid = BTRFS_CSUM_TREE_OBJECTID, 1302 + .type = BTRFS_ROOT_ITEM_KEY, 1303 + .offset = 0, 1304 + }; 1305 + 1306 + return btrfs_global_root(fs_info, &key); 1307 + } 1308 + 1309 + struct btrfs_root *btrfs_extent_root(struct btrfs_fs_info *fs_info, u64 bytenr) 1310 + { 1311 + struct btrfs_key key = { 1312 + .objectid = BTRFS_EXTENT_TREE_OBJECTID, 1313 + .type = BTRFS_ROOT_ITEM_KEY, 1314 + .offset = 0, 1315 + }; 1316 + 1317 + return btrfs_global_root(fs_info, &key); 1318 + } 1245 1319 1246 1320 struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans, 1247 1321 u64 objectid) ··· 1630 1554 static struct btrfs_root *btrfs_get_global_root(struct btrfs_fs_info *fs_info, 1631 1555 u64 objectid) 1632 1556 { 1557 + struct btrfs_key key = { 1558 + .objectid = objectid, 1559 + .type = BTRFS_ROOT_ITEM_KEY, 1560 + .offset = 0, 1561 + }; 1562 + 1633 1563 if (objectid == BTRFS_ROOT_TREE_OBJECTID) 1634 1564 return btrfs_grab_root(fs_info->tree_root); 1635 1565 if (objectid == BTRFS_EXTENT_TREE_OBJECTID) 1636 - return btrfs_grab_root(fs_info->_extent_root); 1566 + return btrfs_grab_root(btrfs_global_root(fs_info, &key)); 1637 1567 if (objectid == BTRFS_CHUNK_TREE_OBJECTID) 1638 1568 return btrfs_grab_root(fs_info->chunk_root); 1639 1569 if (objectid == BTRFS_DEV_TREE_OBJECTID) 1640 1570 return btrfs_grab_root(fs_info->dev_root); 1641 1571 if (objectid == BTRFS_CSUM_TREE_OBJECTID) 1642 - return btrfs_grab_root(fs_info->_csum_root); 1572 + return btrfs_grab_root(btrfs_global_root(fs_info, &key)); 1643 1573 if (objectid == BTRFS_QUOTA_TREE_OBJECTID) 1644 1574 return btrfs_grab_root(fs_info->quota_root) ? 1645 1575 fs_info->quota_root : ERR_PTR(-ENOENT); 1646 1576 if (objectid == BTRFS_UUID_TREE_OBJECTID) 1647 1577 return btrfs_grab_root(fs_info->uuid_root) ? 1648 1578 fs_info->uuid_root : ERR_PTR(-ENOENT); 1649 - if (objectid == BTRFS_FREE_SPACE_TREE_OBJECTID) 1650 - return btrfs_grab_root(fs_info->_free_space_root) ? 1651 - fs_info->_free_space_root : ERR_PTR(-ENOENT); 1579 + if (objectid == BTRFS_FREE_SPACE_TREE_OBJECTID) { 1580 + struct btrfs_root *root = btrfs_global_root(fs_info, &key); 1581 + 1582 + return btrfs_grab_root(root) ? root : ERR_PTR(-ENOENT); 1583 + } 1652 1584 return NULL; 1653 1585 } 1654 1586 ··· 1703 1619 #endif 1704 1620 } 1705 1621 1622 + static void free_global_roots(struct btrfs_fs_info *fs_info) 1623 + { 1624 + struct btrfs_root *root; 1625 + struct rb_node *node; 1626 + 1627 + while ((node = rb_first_postorder(&fs_info->global_root_tree)) != NULL) { 1628 + root = rb_entry(node, struct btrfs_root, rb_node); 1629 + rb_erase(&root->rb_node, &fs_info->global_root_tree); 1630 + btrfs_put_root(root); 1631 + } 1632 + } 1633 + 1706 1634 void btrfs_free_fs_info(struct btrfs_fs_info *fs_info) 1707 1635 { 1708 1636 percpu_counter_destroy(&fs_info->dirty_metadata_bytes); ··· 1726 1630 btrfs_free_ref_cache(fs_info); 1727 1631 kfree(fs_info->balance_ctl); 1728 1632 kfree(fs_info->delayed_root); 1729 - btrfs_put_root(fs_info->_extent_root); 1633 + free_global_roots(fs_info); 1730 1634 btrfs_put_root(fs_info->tree_root); 1731 1635 btrfs_put_root(fs_info->chunk_root); 1732 1636 btrfs_put_root(fs_info->dev_root); 1733 - btrfs_put_root(fs_info->_csum_root); 1734 1637 btrfs_put_root(fs_info->quota_root); 1735 1638 btrfs_put_root(fs_info->uuid_root); 1736 - btrfs_put_root(fs_info->_free_space_root); 1737 1639 btrfs_put_root(fs_info->fs_root); 1738 1640 btrfs_put_root(fs_info->data_reloc_root); 1739 1641 btrfs_check_leaked_roots(fs_info); ··· 2256 2162 } 2257 2163 } 2258 2164 2165 + static void free_global_root_pointers(struct btrfs_fs_info *fs_info) 2166 + { 2167 + struct btrfs_root *root, *tmp; 2168 + 2169 + rbtree_postorder_for_each_entry_safe(root, tmp, 2170 + &fs_info->global_root_tree, 2171 + rb_node) 2172 + free_root_extent_buffers(root); 2173 + } 2174 + 2259 2175 /* helper to cleanup tree roots */ 2260 2176 static void free_root_pointers(struct btrfs_fs_info *info, bool free_chunk_root) 2261 2177 { 2262 2178 free_root_extent_buffers(info->tree_root); 2263 2179 2180 + free_global_root_pointers(info); 2264 2181 free_root_extent_buffers(info->dev_root); 2265 - free_root_extent_buffers(info->_extent_root); 2266 - free_root_extent_buffers(info->_csum_root); 2267 2182 free_root_extent_buffers(info->quota_root); 2268 2183 free_root_extent_buffers(info->uuid_root); 2269 2184 free_root_extent_buffers(info->fs_root); 2270 2185 free_root_extent_buffers(info->data_reloc_root); 2271 2186 if (free_chunk_root) 2272 2187 free_root_extent_buffers(info->chunk_root); 2273 - free_root_extent_buffers(info->_free_space_root); 2274 2188 } 2275 2189 2276 2190 void btrfs_put_root(struct btrfs_root *root) ··· 2539 2437 return 0; 2540 2438 } 2541 2439 2440 + static int load_global_roots_objectid(struct btrfs_root *tree_root, 2441 + struct btrfs_path *path, u64 objectid, 2442 + const char *name) 2443 + { 2444 + struct btrfs_fs_info *fs_info = tree_root->fs_info; 2445 + struct btrfs_root *root; 2446 + int ret; 2447 + struct btrfs_key key = { 2448 + .objectid = objectid, 2449 + .type = BTRFS_ROOT_ITEM_KEY, 2450 + .offset = 0, 2451 + }; 2452 + bool found = false; 2453 + 2454 + /* If we have IGNOREDATACSUMS skip loading these roots. */ 2455 + if (objectid == BTRFS_CSUM_TREE_OBJECTID && 2456 + btrfs_test_opt(fs_info, IGNOREDATACSUMS)) { 2457 + set_bit(BTRFS_FS_STATE_NO_CSUMS, &fs_info->fs_state); 2458 + return 0; 2459 + } 2460 + 2461 + while (1) { 2462 + ret = btrfs_search_slot(NULL, tree_root, &key, path, 0, 0); 2463 + if (ret < 0) 2464 + break; 2465 + 2466 + if (path->slots[0] >= btrfs_header_nritems(path->nodes[0])) { 2467 + ret = btrfs_next_leaf(tree_root, path); 2468 + if (ret) { 2469 + if (ret > 0) 2470 + ret = 0; 2471 + break; 2472 + } 2473 + } 2474 + ret = 0; 2475 + 2476 + btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]); 2477 + if (key.objectid != objectid) 2478 + break; 2479 + btrfs_release_path(path); 2480 + 2481 + found = true; 2482 + root = read_tree_root_path(tree_root, path, &key); 2483 + if (IS_ERR(root)) { 2484 + if (!btrfs_test_opt(fs_info, IGNOREBADROOTS)) 2485 + ret = PTR_ERR(root); 2486 + break; 2487 + } 2488 + set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); 2489 + ret = btrfs_global_root_insert(root); 2490 + if (ret) { 2491 + btrfs_put_root(root); 2492 + break; 2493 + } 2494 + key.offset++; 2495 + } 2496 + btrfs_release_path(path); 2497 + 2498 + if (!found || ret) { 2499 + if (objectid == BTRFS_CSUM_TREE_OBJECTID) 2500 + set_bit(BTRFS_FS_STATE_NO_CSUMS, &fs_info->fs_state); 2501 + 2502 + if (!btrfs_test_opt(fs_info, IGNOREBADROOTS)) 2503 + ret = ret ? ret : -ENOENT; 2504 + else 2505 + ret = 0; 2506 + btrfs_err(fs_info, "failed to load root %s", name); 2507 + } 2508 + return ret; 2509 + } 2510 + 2511 + static int load_global_roots(struct btrfs_root *tree_root) 2512 + { 2513 + struct btrfs_path *path; 2514 + int ret = 0; 2515 + 2516 + path = btrfs_alloc_path(); 2517 + if (!path) 2518 + return -ENOMEM; 2519 + 2520 + ret = load_global_roots_objectid(tree_root, path, 2521 + BTRFS_EXTENT_TREE_OBJECTID, "extent"); 2522 + if (ret) 2523 + goto out; 2524 + ret = load_global_roots_objectid(tree_root, path, 2525 + BTRFS_CSUM_TREE_OBJECTID, "csum"); 2526 + if (ret) 2527 + goto out; 2528 + if (!btrfs_fs_compat_ro(tree_root->fs_info, FREE_SPACE_TREE)) 2529 + goto out; 2530 + ret = load_global_roots_objectid(tree_root, path, 2531 + BTRFS_FREE_SPACE_TREE_OBJECTID, 2532 + "free space"); 2533 + out: 2534 + btrfs_free_path(path); 2535 + return ret; 2536 + } 2537 + 2542 2538 static int btrfs_read_roots(struct btrfs_fs_info *fs_info) 2543 2539 { 2544 2540 struct btrfs_root *tree_root = fs_info->tree_root; ··· 2646 2446 2647 2447 BUG_ON(!fs_info->tree_root); 2648 2448 2649 - location.objectid = BTRFS_EXTENT_TREE_OBJECTID; 2449 + ret = load_global_roots(tree_root); 2450 + if (ret) 2451 + return ret; 2452 + 2453 + location.objectid = BTRFS_DEV_TREE_OBJECTID; 2650 2454 location.type = BTRFS_ROOT_ITEM_KEY; 2651 2455 location.offset = 0; 2652 2456 2653 - root = btrfs_read_tree_root(tree_root, &location); 2654 - if (IS_ERR(root)) { 2655 - if (!btrfs_test_opt(fs_info, IGNOREBADROOTS)) { 2656 - ret = PTR_ERR(root); 2657 - goto out; 2658 - } 2659 - } else { 2660 - set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); 2661 - fs_info->_extent_root = root; 2662 - } 2663 - 2664 - location.objectid = BTRFS_DEV_TREE_OBJECTID; 2665 2457 root = btrfs_read_tree_root(tree_root, &location); 2666 2458 if (IS_ERR(root)) { 2667 2459 if (!btrfs_test_opt(fs_info, IGNOREBADROOTS)) { ··· 2666 2474 } 2667 2475 /* Initialize fs_info for all devices in any case */ 2668 2476 btrfs_init_devices_late(fs_info); 2669 - 2670 - /* If IGNOREDATACSUMS is set don't bother reading the csum root. */ 2671 - if (!btrfs_test_opt(fs_info, IGNOREDATACSUMS)) { 2672 - location.objectid = BTRFS_CSUM_TREE_OBJECTID; 2673 - root = btrfs_read_tree_root(tree_root, &location); 2674 - if (IS_ERR(root)) { 2675 - if (!btrfs_test_opt(fs_info, IGNOREBADROOTS)) { 2676 - ret = PTR_ERR(root); 2677 - goto out; 2678 - } else { 2679 - set_bit(BTRFS_FS_STATE_NO_CSUMS, 2680 - &fs_info->fs_state); 2681 - } 2682 - } else { 2683 - set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); 2684 - fs_info->_csum_root = root; 2685 - } 2686 - } else { 2687 - set_bit(BTRFS_FS_STATE_NO_CSUMS, &fs_info->fs_state); 2688 - } 2689 2477 2690 2478 /* 2691 2479 * This tree can share blocks with some other fs tree during relocation ··· 2702 2530 } else { 2703 2531 set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); 2704 2532 fs_info->uuid_root = root; 2705 - } 2706 - 2707 - if (btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE)) { 2708 - location.objectid = BTRFS_FREE_SPACE_TREE_OBJECTID; 2709 - root = btrfs_read_tree_root(tree_root, &location); 2710 - if (IS_ERR(root)) { 2711 - if (!btrfs_test_opt(fs_info, IGNOREBADROOTS)) { 2712 - ret = PTR_ERR(root); 2713 - goto out; 2714 - } 2715 - } else { 2716 - set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state); 2717 - fs_info->_free_space_root = root; 2718 - } 2719 2533 } 2720 2534 2721 2535 return 0; ··· 3058 2900 spin_lock_init(&fs_info->zone_active_bgs_lock); 3059 2901 spin_lock_init(&fs_info->relocation_bg_lock); 3060 2902 rwlock_init(&fs_info->tree_mod_log_lock); 2903 + rwlock_init(&fs_info->global_root_lock); 3061 2904 mutex_init(&fs_info->unused_bg_unpin_mutex); 3062 2905 mutex_init(&fs_info->reclaim_bgs_lock); 3063 2906 mutex_init(&fs_info->reloc_mutex); ··· 3093 2934 atomic_set(&fs_info->reada_works_cnt, 0); 3094 2935 atomic_set(&fs_info->nr_delayed_iputs, 0); 3095 2936 atomic64_set(&fs_info->tree_mod_seq, 0); 2937 + fs_info->global_root_tree = RB_ROOT; 3096 2938 fs_info->max_inline = BTRFS_DEFAULT_MAX_INLINE; 3097 2939 fs_info->metadata_ratio = 0; 3098 2940 fs_info->defrag_inodes = RB_ROOT;
+6 -12
fs/btrfs/disk-io.h
··· 71 71 struct btrfs_root *btrfs_get_fs_root_commit_root(struct btrfs_fs_info *fs_info, 72 72 struct btrfs_path *path, 73 73 u64 objectid); 74 + int btrfs_global_root_insert(struct btrfs_root *root); 75 + void btrfs_global_root_delete(struct btrfs_root *root); 76 + struct btrfs_root *btrfs_global_root(struct btrfs_fs_info *fs_info, 77 + struct btrfs_key *key); 78 + struct btrfs_root *btrfs_csum_root(struct btrfs_fs_info *fs_info, u64 bytenr); 79 + struct btrfs_root *btrfs_extent_root(struct btrfs_fs_info *fs_info, u64 bytenr); 74 80 75 81 void btrfs_free_fs_info(struct btrfs_fs_info *fs_info); 76 82 int btrfs_cleanup_fs_roots(struct btrfs_fs_info *fs_info); ··· 107 101 if (refcount_inc_not_zero(&root->refs)) 108 102 return root; 109 103 return NULL; 110 - } 111 - 112 - static inline struct btrfs_root *btrfs_extent_root(struct btrfs_fs_info *fs_info, 113 - u64 bytenr) 114 - { 115 - return fs_info->_extent_root; 116 - } 117 - 118 - static inline struct btrfs_root *btrfs_csum_root(struct btrfs_fs_info *fs_info, 119 - u64 bytenr) 120 - { 121 - return fs_info->_csum_root; 122 104 } 123 105 124 106 static inline struct btrfs_root *btrfs_block_group_root(struct btrfs_fs_info *fs_info)
+1
fs/btrfs/extent-tree.c
··· 2947 2947 bool skinny_metadata = btrfs_fs_incompat(info, SKINNY_METADATA); 2948 2948 2949 2949 extent_root = btrfs_extent_root(info, bytenr); 2950 + ASSERT(extent_root); 2950 2951 2951 2952 path = btrfs_alloc_path(); 2952 2953 if (!path)
+19 -4
fs/btrfs/free-space-tree.c
··· 19 19 static struct btrfs_root *btrfs_free_space_root( 20 20 struct btrfs_block_group *block_group) 21 21 { 22 - return block_group->fs_info->_free_space_root; 22 + struct btrfs_key key = { 23 + .objectid = BTRFS_FREE_SPACE_TREE_OBJECTID, 24 + .type = BTRFS_ROOT_ITEM_KEY, 25 + .offset = 0, 26 + }; 27 + 28 + return btrfs_global_root(block_group->fs_info, &key); 23 29 } 24 30 25 31 void set_free_space_tree_thresholds(struct btrfs_block_group *cache) ··· 1170 1164 ret = PTR_ERR(free_space_root); 1171 1165 goto abort; 1172 1166 } 1173 - fs_info->_free_space_root = free_space_root; 1167 + ret = btrfs_global_root_insert(free_space_root); 1168 + if (ret) { 1169 + btrfs_put_root(free_space_root); 1170 + goto abort; 1171 + } 1174 1172 1175 1173 node = rb_first(&fs_info->block_group_cache_tree); 1176 1174 while (node) { ··· 1249 1239 { 1250 1240 struct btrfs_trans_handle *trans; 1251 1241 struct btrfs_root *tree_root = fs_info->tree_root; 1252 - struct btrfs_root *free_space_root = fs_info->_free_space_root; 1242 + struct btrfs_key key = { 1243 + .objectid = BTRFS_FREE_SPACE_TREE_OBJECTID, 1244 + .type = BTRFS_ROOT_ITEM_KEY, 1245 + .offset = 0, 1246 + }; 1247 + struct btrfs_root *free_space_root = btrfs_global_root(fs_info, &key); 1253 1248 int ret; 1254 1249 1255 1250 trans = btrfs_start_transaction(tree_root, 0); ··· 1263 1248 1264 1249 btrfs_clear_fs_compat_ro(fs_info, FREE_SPACE_TREE); 1265 1250 btrfs_clear_fs_compat_ro(fs_info, FREE_SPACE_TREE_VALID); 1266 - fs_info->_free_space_root = NULL; 1267 1251 1268 1252 ret = clear_free_space_tree(trans, free_space_root); 1269 1253 if (ret) ··· 1272 1258 if (ret) 1273 1259 goto abort; 1274 1260 1261 + btrfs_global_root_delete(free_space_root); 1275 1262 list_del(&free_space_root->dirty_list); 1276 1263 1277 1264 btrfs_tree_lock(free_space_root->node);
+1
fs/btrfs/tests/btrfs-tests.c
··· 204 204 /* Will be freed by btrfs_free_fs_roots */ 205 205 if (WARN_ON(test_bit(BTRFS_ROOT_IN_RADIX, &root->state))) 206 206 return; 207 + btrfs_global_root_delete(root); 207 208 btrfs_put_root(root); 208 209 } 209 210
+4 -1
fs/btrfs/tests/free-space-tests.c
··· 1036 1036 goto out; 1037 1037 } 1038 1038 1039 - root->fs_info->_extent_root = root; 1039 + root->root_key.objectid = BTRFS_EXTENT_TREE_OBJECTID; 1040 + root->root_key.type = BTRFS_ROOT_ITEM_KEY; 1041 + root->root_key.offset = 0; 1042 + btrfs_global_root_insert(root); 1040 1043 1041 1044 ret = test_extents(cache); 1042 1045 if (ret)
+4 -1
fs/btrfs/tests/free-space-tree-tests.c
··· 446 446 447 447 btrfs_set_super_compat_ro_flags(root->fs_info->super_copy, 448 448 BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE); 449 - root->fs_info->_free_space_root = root; 449 + root->root_key.objectid = BTRFS_FREE_SPACE_TREE_OBJECTID; 450 + root->root_key.type = BTRFS_ROOT_ITEM_KEY; 451 + root->root_key.offset = 0; 452 + btrfs_global_root_insert(root); 450 453 root->fs_info->tree_root = root; 451 454 452 455 root->node = alloc_test_extent_buffer(root->fs_info, nodesize);
+4 -1
fs/btrfs/tests/qgroup-tests.c
··· 455 455 } 456 456 457 457 /* We are using this root as our extent root */ 458 - root->fs_info->_extent_root = root; 458 + root->root_key.objectid = BTRFS_EXTENT_TREE_OBJECTID; 459 + root->root_key.type = BTRFS_ROOT_ITEM_KEY; 460 + root->root_key.offset = 0; 461 + btrfs_global_root_insert(root); 459 462 460 463 /* 461 464 * Some of the paths we test assume we have a filled out fs_info, so we