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

btrfs: change root->root_key.objectid to btrfs_root_id()

A comment from Filipe on one of my previous cleanups brought my
attention to a new helper we have for getting the root id of a root,
which makes it easier to read in the code.

The changes where made with the following Coccinelle semantic patch:

// <smpl>
@@
expression E,E1;
@@
(
E->root_key.objectid = E1
|
- E->root_key.objectid
+ btrfs_root_id(E)
)
// </smpl>

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
[ minor style fixups ]
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Josef Bacik and committed by
David Sterba
e094f480 53e24158

+218 -241
+4 -4
fs/btrfs/backref.c
··· 261 261 else if (oldcount < 1 && newcount > 0) 262 262 sc->share_count++; 263 263 264 - if (newref->root_id == sc->root->root_key.objectid && 264 + if (newref->root_id == btrfs_root_id(sc->root) && 265 265 newref->wanted_disk_byte == sc->data_bytenr && 266 266 newref->key_for_search.objectid == sc->inum) 267 267 sc->self_ref_count += newref->count; ··· 769 769 continue; 770 770 } 771 771 772 - if (sc && ref->root_id != sc->root->root_key.objectid) { 772 + if (sc && ref->root_id != btrfs_root_id(sc->root)) { 773 773 free_pref(ref); 774 774 ret = BACKREF_FOUND_SHARED; 775 775 goto out; ··· 2623 2623 btrfs_debug(fs_root->fs_info, 2624 2624 "following ref at offset %u for inode %llu in tree %llu", 2625 2625 cur, found_key.objectid, 2626 - fs_root->root_key.objectid); 2626 + btrfs_root_id(fs_root)); 2627 2627 ret = inode_to_path(parent, name_len, 2628 2628 (unsigned long)(iref + 1), eb, ipath); 2629 2629 if (ret) ··· 3355 3355 if (btrfs_node_blockptr(eb, path->slots[level]) != cur->bytenr) { 3356 3356 btrfs_err(fs_info, 3357 3357 "couldn't find block (%llu) (level %d) in tree (%llu) with key (%llu %u %llu)", 3358 - cur->bytenr, level - 1, root->root_key.objectid, 3358 + cur->bytenr, level - 1, btrfs_root_id(root), 3359 3359 tree_key->objectid, tree_key->type, tree_key->offset); 3360 3360 btrfs_put_root(root); 3361 3361 ret = -ENOENT;
+5 -6
fs/btrfs/block-rsv.c
··· 341 341 read_lock(&fs_info->global_root_lock); 342 342 rbtree_postorder_for_each_entry_safe(root, tmp, &fs_info->global_root_tree, 343 343 rb_node) { 344 - if (root->root_key.objectid == BTRFS_EXTENT_TREE_OBJECTID || 345 - root->root_key.objectid == BTRFS_CSUM_TREE_OBJECTID || 346 - root->root_key.objectid == BTRFS_FREE_SPACE_TREE_OBJECTID) { 344 + if (btrfs_root_id(root) == BTRFS_EXTENT_TREE_OBJECTID || 345 + btrfs_root_id(root) == BTRFS_CSUM_TREE_OBJECTID || 346 + btrfs_root_id(root) == BTRFS_FREE_SPACE_TREE_OBJECTID) { 347 347 num_bytes += btrfs_root_used(&root->root_item); 348 348 min_items++; 349 349 } ··· 406 406 { 407 407 struct btrfs_fs_info *fs_info = root->fs_info; 408 408 409 - switch (root->root_key.objectid) { 409 + switch (btrfs_root_id(root)) { 410 410 case BTRFS_CSUM_TREE_OBJECTID: 411 411 case BTRFS_EXTENT_TREE_OBJECTID: 412 412 case BTRFS_FREE_SPACE_TREE_OBJECTID: ··· 468 468 469 469 if (test_bit(BTRFS_ROOT_SHAREABLE, &root->state) || 470 470 (root == fs_info->uuid_root) || 471 - (trans->adding_csums && 472 - root->root_key.objectid == BTRFS_CSUM_TREE_OBJECTID)) 471 + (trans->adding_csums && btrfs_root_id(root) == BTRFS_CSUM_TREE_OBJECTID)) 473 472 block_rsv = trans->block_rsv; 474 473 475 474 if (!block_rsv)
+1 -1
fs/btrfs/compression.c
··· 992 992 993 993 btrfs_crit(inode->root->fs_info, 994 994 "failed to get page cache, root %lld ino %llu file offset %llu", 995 - inode->root->root_key.objectid, btrfs_ino(inode), start); 995 + btrfs_root_id(inode->root), btrfs_ino(inode), start); 996 996 return -ENOENT; 997 997 } 998 998 *in_folio_ret = in_folio;
+18 -21
fs/btrfs/ctree.c
··· 291 291 spin_lock(&fs_info->trans_lock); 292 292 if (!test_and_set_bit(BTRFS_ROOT_DIRTY, &root->state)) { 293 293 /* Want the extent tree to be the last on the list */ 294 - if (root->root_key.objectid == BTRFS_EXTENT_TREE_OBJECTID) 294 + if (btrfs_root_id(root) == BTRFS_EXTENT_TREE_OBJECTID) 295 295 list_move_tail(&root->dirty_list, 296 296 &fs_info->dirty_cowonly_roots); 297 297 else ··· 454 454 } 455 455 } else { 456 456 refs = 1; 457 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID || 457 + if (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID || 458 458 btrfs_header_backref_rev(buf) < BTRFS_MIXED_BACKREF_REV) 459 459 flags = BTRFS_BLOCK_FLAG_FULL_BACKREF; 460 460 else ··· 466 466 !(flags & BTRFS_BLOCK_FLAG_FULL_BACKREF)); 467 467 468 468 if (refs > 1) { 469 - if ((owner == root->root_key.objectid || 470 - root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) && 469 + if ((owner == btrfs_root_id(root) || 470 + btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID) && 471 471 !(flags & BTRFS_BLOCK_FLAG_FULL_BACKREF)) { 472 472 ret = btrfs_inc_ref(trans, root, buf, 1); 473 473 if (ret) 474 474 return ret; 475 475 476 - if (root->root_key.objectid == 477 - BTRFS_TREE_RELOC_OBJECTID) { 476 + if (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID) { 478 477 ret = btrfs_dec_ref(trans, root, buf, 0); 479 478 if (ret) 480 479 return ret; ··· 484 485 new_flags |= BTRFS_BLOCK_FLAG_FULL_BACKREF; 485 486 } else { 486 487 487 - if (root->root_key.objectid == 488 - BTRFS_TREE_RELOC_OBJECTID) 488 + if (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID) 489 489 ret = btrfs_inc_ref(trans, root, cow, 1); 490 490 else 491 491 ret = btrfs_inc_ref(trans, root, cow, 0); ··· 498 500 } 499 501 } else { 500 502 if (flags & BTRFS_BLOCK_FLAG_FULL_BACKREF) { 501 - if (root->root_key.objectid == 502 - BTRFS_TREE_RELOC_OBJECTID) 503 + if (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID) 503 504 ret = btrfs_inc_ref(trans, root, cow, 1); 504 505 else 505 506 ret = btrfs_inc_ref(trans, root, cow, 0); ··· 560 563 else 561 564 btrfs_node_key(buf, &disk_key, 0); 562 565 563 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) { 566 + if (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID) { 564 567 if (parent) 565 568 parent_start = parent->start; 566 569 reloc_src_root = btrfs_header_owner(buf); 567 570 } 568 571 cow = btrfs_alloc_tree_block(trans, root, parent_start, 569 - root->root_key.objectid, &disk_key, level, 572 + btrfs_root_id(root), &disk_key, level, 570 573 search_start, empty_size, reloc_src_root, nest); 571 574 if (IS_ERR(cow)) 572 575 return PTR_ERR(cow); ··· 579 582 btrfs_set_header_backref_rev(cow, BTRFS_MIXED_BACKREF_REV); 580 583 btrfs_clear_header_flag(cow, BTRFS_HEADER_FLAG_WRITTEN | 581 584 BTRFS_HEADER_FLAG_RELOC); 582 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) 585 + if (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID) 583 586 btrfs_set_header_flag(cow, BTRFS_HEADER_FLAG_RELOC); 584 587 else 585 - btrfs_set_header_owner(cow, root->root_key.objectid); 588 + btrfs_set_header_owner(cow, btrfs_root_id(root)); 586 589 587 590 write_extent_buffer_fsid(cow, fs_info->fs_devices->metadata_uuid); 588 591 ··· 606 609 607 610 if (buf == root->node) { 608 611 WARN_ON(parent && parent != buf); 609 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID || 612 + if (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID || 610 613 btrfs_header_backref_rev(buf) < BTRFS_MIXED_BACKREF_REV) 611 614 parent_start = buf->start; 612 615 ··· 682 685 */ 683 686 if (btrfs_header_generation(buf) == trans->transid && 684 687 !btrfs_header_flag(buf, BTRFS_HEADER_FLAG_WRITTEN) && 685 - !(root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID && 688 + !(btrfs_root_id(root) != BTRFS_TREE_RELOC_OBJECTID && 686 689 btrfs_header_flag(buf, BTRFS_HEADER_FLAG_RELOC)) && 687 690 !test_bit(BTRFS_ROOT_FORCE_COW, &root->state)) 688 691 return 0; ··· 1508 1511 check.has_first_key = true; 1509 1512 check.level = parent_level - 1; 1510 1513 check.transid = gen; 1511 - check.owner_root = root->root_key.objectid; 1514 + check.owner_root = btrfs_root_id(root); 1512 1515 1513 1516 /* 1514 1517 * If we need to read an extent buffer from disk and we are holding locks ··· 1553 1556 btrfs_release_path(p); 1554 1557 return -EIO; 1555 1558 } 1556 - if (btrfs_check_eb_owner(tmp, root->root_key.objectid)) { 1559 + if (btrfs_check_eb_owner(tmp, btrfs_root_id(root))) { 1557 1560 free_extent_buffer(tmp); 1558 1561 btrfs_release_path(p); 1559 1562 return -EUCLEAN; ··· 2862 2865 else 2863 2866 btrfs_node_key(lower, &lower_key, 0); 2864 2867 2865 - c = btrfs_alloc_tree_block(trans, root, 0, root->root_key.objectid, 2868 + c = btrfs_alloc_tree_block(trans, root, 0, btrfs_root_id(root), 2866 2869 &lower_key, level, root->node->start, 0, 2867 2870 0, BTRFS_NESTING_NEW_ROOT); 2868 2871 if (IS_ERR(c)) ··· 3006 3009 mid = (c_nritems + 1) / 2; 3007 3010 btrfs_node_key(c, &disk_key, mid); 3008 3011 3009 - split = btrfs_alloc_tree_block(trans, root, 0, root->root_key.objectid, 3012 + split = btrfs_alloc_tree_block(trans, root, 0, btrfs_root_id(root), 3010 3013 &disk_key, level, c->start, 0, 3011 3014 0, BTRFS_NESTING_SPLIT); 3012 3015 if (IS_ERR(split)) ··· 3758 3761 * BTRFS_NESTING_SPLIT_THE_SPLITTENING if we need to, but for now just 3759 3762 * use BTRFS_NESTING_NEW_ROOT. 3760 3763 */ 3761 - right = btrfs_alloc_tree_block(trans, root, 0, root->root_key.objectid, 3764 + right = btrfs_alloc_tree_block(trans, root, 0, btrfs_root_id(root), 3762 3765 &disk_key, 0, l->start, 0, 0, 3763 3766 num_doubles ? BTRFS_NESTING_NEW_ROOT : 3764 3767 BTRFS_NESTING_SPLIT);
+1 -1
fs/btrfs/defrag.c
··· 147 147 148 148 defrag->ino = btrfs_ino(inode); 149 149 defrag->transid = transid; 150 - defrag->root = root->root_key.objectid; 150 + defrag->root = btrfs_root_id(root); 151 151 defrag->extent_thresh = extent_thresh; 152 152 153 153 spin_lock(&fs_info->defrag_inodes_lock);
+1 -1
fs/btrfs/delayed-inode.c
··· 1651 1651 if (unlikely(ret)) { 1652 1652 btrfs_err(trans->fs_info, 1653 1653 "err add delayed dir index item(index: %llu) into the deletion tree of the delayed node(root id: %llu, inode id: %llu, errno: %d)", 1654 - index, node->root->root_key.objectid, 1654 + index, btrfs_root_id(node->root), 1655 1655 node->inode_id, ret); 1656 1656 btrfs_delayed_item_release_metadata(dir->root, item); 1657 1657 btrfs_release_delayed_item(item);
+18 -18
fs/btrfs/disk-io.c
··· 776 776 if (tmp) { 777 777 ret = -EEXIST; 778 778 btrfs_warn(fs_info, "global root %llu %llu already exists", 779 - root->root_key.objectid, root->root_key.offset); 779 + btrfs_root_id(root), root->root_key.offset); 780 780 } 781 781 return ret; 782 782 } ··· 1012 1012 } 1013 1013 1014 1014 log_root->last_trans = trans->transid; 1015 - log_root->root_key.offset = root->root_key.objectid; 1015 + log_root->root_key.offset = btrfs_root_id(root); 1016 1016 1017 1017 inode_item = &log_root->root_item.inode; 1018 1018 btrfs_set_stack_inode_generation(inode_item, 1); ··· 1077 1077 * match its root node owner 1078 1078 */ 1079 1079 if (!test_bit(BTRFS_FS_STATE_DUMMY_FS_INFO, &fs_info->fs_state) && 1080 - root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID && 1081 - root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID && 1082 - root->root_key.objectid != btrfs_header_owner(root->node)) { 1080 + btrfs_root_id(root) != BTRFS_TREE_LOG_OBJECTID && 1081 + btrfs_root_id(root) != BTRFS_TREE_RELOC_OBJECTID && 1082 + btrfs_root_id(root) != btrfs_header_owner(root->node)) { 1083 1083 btrfs_crit(fs_info, 1084 1084 "root=%llu block=%llu, tree root owner mismatch, have %llu expect %llu", 1085 - root->root_key.objectid, root->node->start, 1085 + btrfs_root_id(root), root->node->start, 1086 1086 btrfs_header_owner(root->node), 1087 - root->root_key.objectid); 1087 + btrfs_root_id(root)); 1088 1088 ret = -EUCLEAN; 1089 1089 goto fail; 1090 1090 } ··· 1121 1121 1122 1122 btrfs_drew_lock_init(&root->snapshot_lock); 1123 1123 1124 - if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID && 1124 + if (btrfs_root_id(root) != BTRFS_TREE_LOG_OBJECTID && 1125 1125 !btrfs_is_data_reloc_root(root) && 1126 - is_fstree(root->root_key.objectid)) { 1126 + is_fstree(btrfs_root_id(root))) { 1127 1127 set_bit(BTRFS_ROOT_SHAREABLE, &root->state); 1128 1128 btrfs_check_and_init_root_item(&root->root_item); 1129 1129 } ··· 1132 1132 * Don't assign anonymous block device to roots that are not exposed to 1133 1133 * userspace, the id pool is limited to 1M 1134 1134 */ 1135 - if (is_fstree(root->root_key.objectid) && 1135 + if (is_fstree(btrfs_root_id(root)) && 1136 1136 btrfs_root_refs(&root->root_item) > 0) { 1137 1137 if (!anon_dev) { 1138 1138 ret = get_anon_bdev(&root->anon_dev); ··· 1219 1219 1220 1220 spin_lock(&fs_info->fs_roots_radix_lock); 1221 1221 ret = radix_tree_insert(&fs_info->fs_roots_radix, 1222 - (unsigned long)root->root_key.objectid, 1222 + (unsigned long)btrfs_root_id(root), 1223 1223 root); 1224 1224 if (ret == 0) { 1225 1225 btrfs_grab_root(root); ··· 2584 2584 struct btrfs_tree_parent_check check = { 2585 2585 .level = level, 2586 2586 .transid = gen, 2587 - .owner_root = root->root_key.objectid 2587 + .owner_root = btrfs_root_id(root) 2588 2588 }; 2589 2589 int ret = 0; 2590 2590 ··· 2930 2930 spin_unlock(&fs_info->fs_roots_radix_lock); 2931 2931 break; 2932 2932 } 2933 - root_objectid = gang[ret - 1]->root_key.objectid + 1; 2933 + root_objectid = btrfs_root_id(gang[ret - 1]) + 1; 2934 2934 2935 2935 for (i = 0; i < ret; i++) { 2936 2936 /* Avoid to grab roots in dead_roots. */ ··· 2946 2946 for (i = 0; i < ret; i++) { 2947 2947 if (!gang[i]) 2948 2948 continue; 2949 - root_objectid = gang[i]->root_key.objectid; 2949 + root_objectid = btrfs_root_id(gang[i]); 2950 2950 err = btrfs_orphan_cleanup(gang[i]); 2951 2951 if (err) 2952 2952 goto out; ··· 4139 4139 4140 4140 spin_lock(&fs_info->fs_roots_radix_lock); 4141 4141 radix_tree_delete(&fs_info->fs_roots_radix, 4142 - (unsigned long)root->root_key.objectid); 4142 + (unsigned long)btrfs_root_id(root)); 4143 4143 if (test_and_clear_bit(BTRFS_ROOT_IN_RADIX, &root->state)) 4144 4144 drop_ref = true; 4145 4145 spin_unlock(&fs_info->fs_roots_radix_lock); ··· 4481 4481 for (i = 0; i < ret; i++) { 4482 4482 if (!gang[i]) 4483 4483 continue; 4484 - root_objectid = gang[i]->root_key.objectid; 4484 + root_objectid = btrfs_root_id(gang[i]); 4485 4485 btrfs_free_log(NULL, gang[i]); 4486 4486 btrfs_put_root(gang[i]); 4487 4487 } ··· 4812 4812 4813 4813 btrfs_qgroup_free_meta_all_pertrans(root); 4814 4814 radix_tree_tag_clear(&fs_info->fs_roots_radix, 4815 - (unsigned long)root->root_key.objectid, 4815 + (unsigned long)btrfs_root_id(root), 4816 4816 BTRFS_ROOT_TRANS_TAG); 4817 4817 } 4818 4818 } ··· 4953 4953 if (unlikely(root->free_objectid >= BTRFS_LAST_FREE_OBJECTID)) { 4954 4954 btrfs_warn(root->fs_info, 4955 4955 "the objectid of root %llu reaches its highest value", 4956 - root->root_key.objectid); 4956 + btrfs_root_id(root)); 4957 4957 ret = -ENOSPC; 4958 4958 goto out; 4959 4959 }
+4 -4
fs/btrfs/export.c
··· 34 34 type = FILEID_BTRFS_WITHOUT_PARENT; 35 35 36 36 fid->objectid = btrfs_ino(BTRFS_I(inode)); 37 - fid->root_objectid = BTRFS_I(inode)->root->root_key.objectid; 37 + fid->root_objectid = btrfs_root_id(BTRFS_I(inode)->root); 38 38 fid->gen = inode->i_generation; 39 39 40 40 if (parent) { ··· 42 42 43 43 fid->parent_objectid = BTRFS_I(parent)->location.objectid; 44 44 fid->parent_gen = parent->i_generation; 45 - parent_root_id = BTRFS_I(parent)->root->root_key.objectid; 45 + parent_root_id = btrfs_root_id(BTRFS_I(parent)->root); 46 46 47 47 if (parent_root_id != fid->root_objectid) { 48 48 fid->parent_root_objectid = parent_root_id; ··· 160 160 return ERR_PTR(-ENOMEM); 161 161 162 162 if (btrfs_ino(BTRFS_I(dir)) == BTRFS_FIRST_FREE_OBJECTID) { 163 - key.objectid = root->root_key.objectid; 163 + key.objectid = btrfs_root_id(root); 164 164 key.type = BTRFS_ROOT_BACKREF_KEY; 165 165 key.offset = (u64)-1; 166 166 root = fs_info->tree_root; ··· 243 243 return -ENOMEM; 244 244 245 245 if (ino == BTRFS_FIRST_FREE_OBJECTID) { 246 - key.objectid = BTRFS_I(inode)->root->root_key.objectid; 246 + key.objectid = btrfs_root_id(BTRFS_I(inode)->root); 247 247 key.type = BTRFS_ROOT_BACKREF_KEY; 248 248 key.offset = (u64)-1; 249 249 root = fs_info->tree_root;
+25 -31
fs/btrfs/extent-tree.c
··· 2328 2328 * If our ref doesn't match the one we're currently looking at 2329 2329 * then we have a cross reference. 2330 2330 */ 2331 - if (ref->ref_root != root->root_key.objectid || 2331 + if (ref->ref_root != btrfs_root_id(root) || 2332 2332 ref_owner != objectid || ref_offset != offset) { 2333 2333 ret = 1; 2334 2334 break; ··· 2422 2422 ref = (struct btrfs_extent_data_ref *)(&iref->offset); 2423 2423 if (btrfs_extent_refs(leaf, ei) != 2424 2424 btrfs_extent_data_ref_count(leaf, ref) || 2425 - btrfs_extent_data_ref_root(leaf, ref) != 2426 - root->root_key.objectid || 2425 + btrfs_extent_data_ref_root(leaf, ref) != btrfs_root_id(root) || 2427 2426 btrfs_extent_data_ref_objectid(leaf, ref) != objectid || 2428 2427 btrfs_extent_data_ref_offset(leaf, ref) != offset) 2429 2428 goto out; ··· 2514 2515 2515 2516 key.offset -= btrfs_file_extent_offset(buf, fi); 2516 2517 btrfs_init_data_ref(&ref, key.objectid, key.offset, 2517 - root->root_key.objectid, for_reloc); 2518 + btrfs_root_id(root), for_reloc); 2518 2519 if (inc) 2519 2520 ret = btrfs_inc_extent_ref(trans, &ref); 2520 2521 else ··· 2527 2528 ref.num_bytes = fs_info->nodesize; 2528 2529 2529 2530 btrfs_init_tree_ref(&ref, level - 1, 2530 - root->root_key.objectid, for_reloc); 2531 + btrfs_root_id(root), for_reloc); 2531 2532 if (inc) 2532 2533 ret = btrfs_inc_extent_ref(trans, &ref); 2533 2534 else ··· 4670 4671 bool final_tried = num_bytes == min_alloc_size; 4671 4672 u64 flags; 4672 4673 int ret; 4673 - bool for_treelog = (root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID); 4674 + bool for_treelog = (btrfs_root_id(root) == BTRFS_TREE_LOG_OBJECTID); 4674 4675 bool for_data_reloc = (btrfs_is_data_reloc_root(root) && is_data); 4675 4676 4676 4677 flags = get_alloc_profile_by_root(root, is_data); ··· 4935 4936 .action = BTRFS_ADD_DELAYED_EXTENT, 4936 4937 .bytenr = ins->objectid, 4937 4938 .num_bytes = ins->offset, 4938 - .owning_root = root->root_key.objectid, 4939 - .ref_root = root->root_key.objectid, 4939 + .owning_root = btrfs_root_id(root), 4940 + .ref_root = btrfs_root_id(root), 4940 4941 }; 4941 4942 4942 4943 ASSERT(generic_ref.ref_root != BTRFS_TREE_LOG_OBJECTID); ··· 5082 5083 btrfs_set_header_owner(buf, owner); 5083 5084 write_extent_buffer_fsid(buf, fs_info->fs_devices->metadata_uuid); 5084 5085 write_extent_buffer_chunk_tree_uuid(buf, fs_info->chunk_tree_uuid); 5085 - if (root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID) { 5086 + if (btrfs_root_id(root) == BTRFS_TREE_LOG_OBJECTID) { 5086 5087 buf->log_index = root->log_transid % 2; 5087 5088 /* 5088 5089 * we allow two log transactions at a time, use different ··· 5187 5188 extent_op->update_flags = true; 5188 5189 extent_op->level = level; 5189 5190 5190 - btrfs_init_tree_ref(&generic_ref, level, 5191 - root->root_key.objectid, false); 5191 + btrfs_init_tree_ref(&generic_ref, level, btrfs_root_id(root), false); 5192 5192 btrfs_ref_tree_mod(fs_info, &generic_ref); 5193 5193 ret = btrfs_add_delayed_tree_ref(trans, &generic_ref, extent_op); 5194 5194 if (ret) ··· 5325 5327 u64 flag = BTRFS_BLOCK_FLAG_FULL_BACKREF; 5326 5328 int ret; 5327 5329 5328 - if (wc->stage == UPDATE_BACKREF && 5329 - btrfs_header_owner(eb) != root->root_key.objectid) 5330 + if (wc->stage == UPDATE_BACKREF && btrfs_header_owner(eb) != btrfs_root_id(root)) 5330 5331 return 1; 5331 5332 5332 5333 /* ··· 5399 5402 5400 5403 ret = lookup_extent_backref(trans, path, &iref, bytenr, 5401 5404 root->fs_info->nodesize, parent, 5402 - root->root_key.objectid, level, 0); 5405 + btrfs_root_id(root), level, 0); 5403 5406 btrfs_free_path(path); 5404 5407 if (ret == -ENOENT) 5405 5408 return 0; ··· 5455 5458 5456 5459 check.level = level - 1; 5457 5460 check.transid = generation; 5458 - check.owner_root = root->root_key.objectid; 5461 + check.owner_root = btrfs_root_id(root); 5459 5462 check.has_first_key = true; 5460 5463 btrfs_node_key_to_cpu(path->nodes[level], &check.first_key, 5461 5464 path->slots[level]); ··· 5463 5466 next = find_extent_buffer(fs_info, bytenr); 5464 5467 if (!next) { 5465 5468 next = btrfs_find_create_tree_block(fs_info, bytenr, 5466 - root->root_key.objectid, level - 1); 5469 + btrfs_root_id(root), level - 1); 5467 5470 if (IS_ERR(next)) 5468 5471 return PTR_ERR(next); 5469 5472 reada = 1; ··· 5553 5556 .bytenr = bytenr, 5554 5557 .num_bytes = fs_info->nodesize, 5555 5558 .owning_root = owner_root, 5556 - .ref_root = root->root_key.objectid, 5559 + .ref_root = btrfs_root_id(root), 5557 5560 }; 5558 5561 if (wc->flags[level] & BTRFS_BLOCK_FLAG_FULL_BACKREF) { 5559 5562 ref.parent = path->nodes[level]->start; 5560 5563 } else { 5561 - ASSERT(root->root_key.objectid == 5564 + ASSERT(btrfs_root_id(root) == 5562 5565 btrfs_header_owner(path->nodes[level])); 5563 - if (root->root_key.objectid != 5566 + if (btrfs_root_id(root) != 5564 5567 btrfs_header_owner(path->nodes[level])) { 5565 5568 btrfs_err(root->fs_info, 5566 5569 "mismatched block owner"); ··· 5591 5594 * already accounted them at merge time (replace_path), 5592 5595 * thus we could skip expensive subtree trace here. 5593 5596 */ 5594 - if (root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID && 5595 - need_account) { 5597 + if (btrfs_root_id(root) != BTRFS_TREE_RELOC_OBJECTID && need_account) { 5596 5598 ret = btrfs_qgroup_trace_subtree(trans, next, 5597 5599 generation, level - 1); 5598 5600 if (ret) { ··· 5701 5705 else 5702 5706 ret = btrfs_dec_ref(trans, root, eb, 0); 5703 5707 BUG_ON(ret); /* -ENOMEM */ 5704 - if (is_fstree(root->root_key.objectid)) { 5708 + if (is_fstree(btrfs_root_id(root))) { 5705 5709 ret = btrfs_qgroup_trace_leaf_items(trans, eb); 5706 5710 if (ret) { 5707 5711 btrfs_err_rl(fs_info, ··· 5721 5725 if (eb == root->node) { 5722 5726 if (wc->flags[level] & BTRFS_BLOCK_FLAG_FULL_BACKREF) 5723 5727 parent = eb->start; 5724 - else if (root->root_key.objectid != btrfs_header_owner(eb)) 5728 + else if (btrfs_root_id(root) != btrfs_header_owner(eb)) 5725 5729 goto owner_mismatch; 5726 5730 } else { 5727 5731 if (wc->flags[level + 1] & BTRFS_BLOCK_FLAG_FULL_BACKREF) 5728 5732 parent = path->nodes[level + 1]->start; 5729 - else if (root->root_key.objectid != 5733 + else if (btrfs_root_id(root) != 5730 5734 btrfs_header_owner(path->nodes[level + 1])) 5731 5735 goto owner_mismatch; 5732 5736 } ··· 5740 5744 5741 5745 owner_mismatch: 5742 5746 btrfs_err_rl(fs_info, "unexpected tree owner, have %llu expect %llu", 5743 - btrfs_header_owner(eb), root->root_key.objectid); 5747 + btrfs_header_owner(eb), btrfs_root_id(root)); 5744 5748 return -EUCLEAN; 5745 5749 } 5746 5750 ··· 5826 5830 */ 5827 5831 int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc) 5828 5832 { 5829 - const bool is_reloc_root = (root->root_key.objectid == 5830 - BTRFS_TREE_RELOC_OBJECTID); 5833 + const bool is_reloc_root = (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID); 5831 5834 struct btrfs_fs_info *fs_info = root->fs_info; 5832 5835 struct btrfs_path *path; 5833 5836 struct btrfs_trans_handle *trans; ··· 5840 5845 bool root_dropped = false; 5841 5846 bool unfinished_drop = false; 5842 5847 5843 - btrfs_debug(fs_info, "Drop subvolume %llu", root->root_key.objectid); 5848 + btrfs_debug(fs_info, "Drop subvolume %llu", btrfs_root_id(root)); 5844 5849 5845 5850 path = btrfs_alloc_path(); 5846 5851 if (!path) { ··· 6038 6043 * 6039 6044 * The most common failure here is just -ENOENT. 6040 6045 */ 6041 - btrfs_del_orphan_item(trans, tree_root, 6042 - root->root_key.objectid); 6046 + btrfs_del_orphan_item(trans, tree_root, btrfs_root_id(root)); 6043 6047 } 6044 6048 } 6045 6049 ··· 6102 6108 int ret = 0; 6103 6109 int wret; 6104 6110 6105 - BUG_ON(root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID); 6111 + BUG_ON(btrfs_root_id(root) != BTRFS_TREE_RELOC_OBJECTID); 6106 6112 6107 6113 path = btrfs_alloc_path(); 6108 6114 if (!path)
+5 -6
fs/btrfs/file-item.c
··· 430 430 memset(csum_dst, 0, csum_size); 431 431 count = 1; 432 432 433 - if (inode->root->root_key.objectid == 434 - BTRFS_DATA_RELOC_TREE_OBJECTID) { 433 + if (btrfs_root_id(inode->root) == BTRFS_DATA_RELOC_TREE_OBJECTID) { 435 434 u64 file_offset = bbio->file_offset + bio_offset; 436 435 437 436 set_extent_bit(&inode->io_tree, file_offset, ··· 884 885 const u32 csum_size = fs_info->csum_size; 885 886 u32 blocksize_bits = fs_info->sectorsize_bits; 886 887 887 - ASSERT(root->root_key.objectid == BTRFS_CSUM_TREE_OBJECTID || 888 - root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID); 888 + ASSERT(btrfs_root_id(root) == BTRFS_CSUM_TREE_OBJECTID || 889 + btrfs_root_id(root) == BTRFS_TREE_LOG_OBJECTID); 889 890 890 891 path = btrfs_alloc_path(); 891 892 if (!path) ··· 1185 1186 * search, etc, because log trees are temporary anyway and it 1186 1187 * would only save a few bytes of leaf space. 1187 1188 */ 1188 - if (root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID) { 1189 + if (btrfs_root_id(root) == BTRFS_TREE_LOG_OBJECTID) { 1189 1190 if (path->slots[0] + 1 >= 1190 1191 btrfs_header_nritems(path->nodes[0])) { 1191 1192 ret = find_next_csum_offset(root, path, &next_offset); ··· 1327 1328 btrfs_err(fs_info, 1328 1329 "unknown file extent item type %d, inode %llu, offset %llu, " 1329 1330 "root %llu", type, btrfs_ino(inode), extent_start, 1330 - root->root_key.objectid); 1331 + btrfs_root_id(root)); 1331 1332 } 1332 1333 } 1333 1334
+11 -11
fs/btrfs/file.c
··· 245 245 if (args->start >= inode->disk_i_size && !args->replace_extent) 246 246 modify_tree = 0; 247 247 248 - update_refs = (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID); 248 + update_refs = (btrfs_root_id(root) != BTRFS_TREE_LOG_OBJECTID); 249 249 while (1) { 250 250 recow = 0; 251 251 ret = btrfs_lookup_file_extent(trans, root, path, ino, ··· 377 377 .bytenr = disk_bytenr, 378 378 .num_bytes = num_bytes, 379 379 .parent = 0, 380 - .owning_root = root->root_key.objectid, 381 - .ref_root = root->root_key.objectid, 380 + .owning_root = btrfs_root_id(root), 381 + .ref_root = btrfs_root_id(root), 382 382 }; 383 383 btrfs_init_data_ref(&ref, new_key.objectid, 384 384 args->start - extent_offset, ··· 470 470 .bytenr = disk_bytenr, 471 471 .num_bytes = num_bytes, 472 472 .parent = 0, 473 - .owning_root = root->root_key.objectid, 474 - .ref_root = root->root_key.objectid, 473 + .owning_root = btrfs_root_id(root), 474 + .ref_root = btrfs_root_id(root), 475 475 }; 476 476 btrfs_init_data_ref(&ref, key.objectid, 477 477 key.offset - extent_offset, ··· 755 755 ref.bytenr = bytenr; 756 756 ref.num_bytes = num_bytes; 757 757 ref.parent = 0; 758 - ref.owning_root = root->root_key.objectid; 759 - ref.ref_root = root->root_key.objectid; 758 + ref.owning_root = btrfs_root_id(root); 759 + ref.ref_root = btrfs_root_id(root); 760 760 btrfs_init_data_ref(&ref, ino, orig_offset, 0, false); 761 761 ret = btrfs_inc_extent_ref(trans, &ref); 762 762 if (ret) { ··· 785 785 ref.bytenr = bytenr; 786 786 ref.num_bytes = num_bytes; 787 787 ref.parent = 0; 788 - ref.owning_root = root->root_key.objectid; 789 - ref.ref_root = root->root_key.objectid; 788 + ref.owning_root = btrfs_root_id(root); 789 + ref.ref_root = btrfs_root_id(root); 790 790 btrfs_init_data_ref(&ref, ino, orig_offset, 0, false); 791 791 if (extent_mergeable(leaf, path->slots[0] + 1, 792 792 ino, bytenr, orig_offset, ··· 2493 2493 .action = BTRFS_ADD_DELAYED_REF, 2494 2494 .bytenr = extent_info->disk_offset, 2495 2495 .num_bytes = extent_info->disk_len, 2496 - .owning_root = root->root_key.objectid, 2497 - .ref_root = root->root_key.objectid, 2496 + .owning_root = btrfs_root_id(root), 2497 + .ref_root = btrfs_root_id(root), 2498 2498 }; 2499 2499 u64 ref_offset; 2500 2500
+2 -2
fs/btrfs/inode-item.c
··· 674 674 .action = BTRFS_DROP_DELAYED_REF, 675 675 .bytenr = extent_start, 676 676 .num_bytes = extent_num_bytes, 677 - .owning_root = root->root_key.objectid, 677 + .owning_root = btrfs_root_id(root), 678 678 .ref_root = btrfs_header_owner(leaf), 679 679 }; 680 680 681 681 bytes_deleted += extent_num_bytes; 682 682 683 683 btrfs_init_data_ref(&ref, control->ino, extent_offset, 684 - root->root_key.objectid, false); 684 + btrfs_root_id(root), false); 685 685 ret = btrfs_free_extent(trans, &ref); 686 686 if (ret) { 687 687 btrfs_abort_transaction(trans, ret);
+29 -32
fs/btrfs/inode.c
··· 254 254 btrfs_warn_rl(fs_info, "has data reloc tree but no running relocation"); 255 255 btrfs_warn_rl(fs_info, 256 256 "csum failed root %lld ino %llu off %llu csum " CSUM_FMT " expected csum " CSUM_FMT " mirror %d", 257 - inode->root->root_key.objectid, btrfs_ino(inode), file_off, 257 + btrfs_root_id(inode->root), btrfs_ino(inode), file_off, 258 258 CSUM_FMT_VALUE(csum_size, csum), 259 259 CSUM_FMT_VALUE(csum_size, csum_expected), 260 260 mirror_num); ··· 264 264 logical += file_off; 265 265 btrfs_warn_rl(fs_info, 266 266 "csum failed root %lld ino %llu off %llu logical %llu csum " CSUM_FMT " expected csum " CSUM_FMT " mirror %d", 267 - inode->root->root_key.objectid, 267 + btrfs_root_id(inode->root), 268 268 btrfs_ino(inode), file_off, logical, 269 269 CSUM_FMT_VALUE(csum_size, csum), 270 270 CSUM_FMT_VALUE(csum_size, csum_expected), ··· 331 331 const u32 csum_size = root->fs_info->csum_size; 332 332 333 333 /* For data reloc tree, it's better to do a backref lookup instead. */ 334 - if (root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID) 334 + if (btrfs_root_id(root) == BTRFS_DATA_RELOC_TREE_OBJECTID) 335 335 return print_data_reloc_error(inode, logical_start, csum, 336 336 csum_expected, mirror_num); 337 337 338 338 /* Output without objectid, which is more meaningful */ 339 - if (root->root_key.objectid >= BTRFS_LAST_FREE_OBJECTID) { 339 + if (btrfs_root_id(root) >= BTRFS_LAST_FREE_OBJECTID) { 340 340 btrfs_warn_rl(root->fs_info, 341 341 "csum failed root %lld ino %lld off %llu csum " CSUM_FMT " expected csum " CSUM_FMT " mirror %d", 342 - root->root_key.objectid, btrfs_ino(inode), 342 + btrfs_root_id(root), btrfs_ino(inode), 343 343 logical_start, 344 344 CSUM_FMT_VALUE(csum_size, csum), 345 345 CSUM_FMT_VALUE(csum_size, csum_expected), ··· 347 347 } else { 348 348 btrfs_warn_rl(root->fs_info, 349 349 "csum failed root %llu ino %llu off %llu csum " CSUM_FMT " expected csum " CSUM_FMT " mirror %d", 350 - root->root_key.objectid, btrfs_ino(inode), 350 + btrfs_root_id(root), btrfs_ino(inode), 351 351 logical_start, 352 352 CSUM_FMT_VALUE(csum_size, csum), 353 353 CSUM_FMT_VALUE(csum_size, csum_expected), ··· 1218 1218 kthread_associate_blkcg(NULL); 1219 1219 btrfs_debug(fs_info, 1220 1220 "async extent submission failed root=%lld inode=%llu start=%llu len=%llu ret=%d", 1221 - root->root_key.objectid, btrfs_ino(inode), start, 1221 + btrfs_root_id(root), btrfs_ino(inode), start, 1222 1222 async_extent->ram_size, ret); 1223 1223 kfree(async_extent); 1224 1224 } ··· 3239 3239 * Actually free the qgroup rsv which was released when 3240 3240 * the ordered extent was created. 3241 3241 */ 3242 - btrfs_qgroup_free_refroot(fs_info, inode->root->root_key.objectid, 3242 + btrfs_qgroup_free_refroot(fs_info, btrfs_root_id(inode->root), 3243 3243 ordered_extent->qgroup_rsv, 3244 3244 BTRFS_QGROUP_RSV_DATA); 3245 3245 } ··· 3906 3906 btrfs_err(fs_info, 3907 3907 "error loading props for ino %llu (root %llu): %d", 3908 3908 btrfs_ino(BTRFS_I(inode)), 3909 - root->root_key.objectid, ret); 3909 + btrfs_root_id(root), ret); 3910 3910 } 3911 3911 if (path != in_path) 3912 3912 btrfs_free_path(path); ··· 4265 4265 /* This needs to handle no-key deletions later on */ 4266 4266 4267 4267 if (btrfs_ino(inode) == BTRFS_FIRST_FREE_OBJECTID) { 4268 - objectid = inode->root->root_key.objectid; 4268 + objectid = btrfs_root_id(inode->root); 4269 4269 } else if (btrfs_ino(inode) == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID) { 4270 4270 objectid = inode->location.objectid; 4271 4271 } else { ··· 4323 4323 btrfs_release_path(path); 4324 4324 } else { 4325 4325 ret = btrfs_del_root_ref(trans, objectid, 4326 - root->root_key.objectid, dir_ino, 4326 + btrfs_root_id(root), dir_ino, 4327 4327 &index, &fname.disk_name); 4328 4328 if (ret) { 4329 4329 btrfs_abort_transaction(trans, ret); ··· 4373 4373 dir_id, &name, 0); 4374 4374 if (di && !IS_ERR(di)) { 4375 4375 btrfs_dir_item_key_to_cpu(path->nodes[0], di, &key); 4376 - if (key.objectid == root->root_key.objectid) { 4376 + if (key.objectid == btrfs_root_id(root)) { 4377 4377 ret = -EPERM; 4378 4378 btrfs_err(fs_info, 4379 4379 "deleting default subvolume %llu is not allowed", ··· 4383 4383 btrfs_release_path(path); 4384 4384 } 4385 4385 4386 - key.objectid = root->root_key.objectid; 4386 + key.objectid = btrfs_root_id(root); 4387 4387 key.type = BTRFS_ROOT_REF_KEY; 4388 4388 key.offset = (u64)-1; 4389 4389 ··· 4403 4403 if (path->slots[0] > 0) { 4404 4404 path->slots[0]--; 4405 4405 btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]); 4406 - if (key.objectid == root->root_key.objectid && 4407 - key.type == BTRFS_ROOT_REF_KEY) 4406 + if (key.objectid == btrfs_root_id(root) && key.type == BTRFS_ROOT_REF_KEY) 4408 4407 ret = -ENOTEMPTY; 4409 4408 } 4410 4409 out: ··· 4461 4462 spin_unlock(&dest->root_item_lock); 4462 4463 btrfs_warn(fs_info, 4463 4464 "attempt to delete subvolume %llu during send", 4464 - dest->root_key.objectid); 4465 + btrfs_root_id(dest)); 4465 4466 ret = -EPERM; 4466 4467 goto out_up_write; 4467 4468 } ··· 4469 4470 spin_unlock(&dest->root_item_lock); 4470 4471 btrfs_warn(fs_info, 4471 4472 "attempt to delete subvolume %llu with active swapfile", 4472 - root->root_key.objectid); 4473 + btrfs_root_id(root)); 4473 4474 ret = -EPERM; 4474 4475 goto out_up_write; 4475 4476 } ··· 4530 4531 if (!test_and_set_bit(BTRFS_ROOT_ORPHAN_ITEM_INSERTED, &dest->state)) { 4531 4532 ret = btrfs_insert_orphan_item(trans, 4532 4533 fs_info->tree_root, 4533 - dest->root_key.objectid); 4534 + btrfs_root_id(dest)); 4534 4535 if (ret) { 4535 4536 btrfs_abort_transaction(trans, ret); 4536 4537 goto out_end_trans; ··· 4538 4539 } 4539 4540 4540 4541 ret = btrfs_uuid_tree_remove(trans, dest->root_item.uuid, 4541 - BTRFS_UUID_KEY_SUBVOL, 4542 - dest->root_key.objectid); 4542 + BTRFS_UUID_KEY_SUBVOL, btrfs_root_id(dest)); 4543 4543 if (ret && ret != -ENOENT) { 4544 4544 btrfs_abort_transaction(trans, ret); 4545 4545 goto out_end_trans; ··· 4547 4549 ret = btrfs_uuid_tree_remove(trans, 4548 4550 dest->root_item.received_uuid, 4549 4551 BTRFS_UUID_KEY_RECEIVED_SUBVOL, 4550 - dest->root_key.objectid); 4552 + btrfs_root_id(dest)); 4551 4553 if (ret && ret != -ENOENT) { 4552 4554 btrfs_abort_transaction(trans, ret); 4553 4555 goto out_end_trans; ··· 5227 5229 5228 5230 if (inode->i_nlink && 5229 5231 ((btrfs_root_refs(&root->root_item) != 0 && 5230 - root->root_key.objectid != BTRFS_ROOT_TREE_OBJECTID) || 5232 + btrfs_root_id(root) != BTRFS_ROOT_TREE_OBJECTID) || 5231 5233 btrfs_is_free_space_inode(BTRFS_I(inode)))) 5232 5234 goto out; 5233 5235 ··· 5239 5241 5240 5242 if (inode->i_nlink > 0) { 5241 5243 BUG_ON(btrfs_root_refs(&root->root_item) != 0 && 5242 - root->root_key.objectid != BTRFS_ROOT_TREE_OBJECTID); 5244 + btrfs_root_id(root) != BTRFS_ROOT_TREE_OBJECTID); 5243 5245 goto out; 5244 5246 } 5245 5247 ··· 5411 5413 } 5412 5414 5413 5415 err = -ENOENT; 5414 - key.objectid = dir->root->root_key.objectid; 5416 + key.objectid = btrfs_root_id(dir->root); 5415 5417 key.type = BTRFS_ROOT_REF_KEY; 5416 5418 key.offset = location->objectid; 5417 5419 ··· 6370 6372 if (ret) { 6371 6373 btrfs_err(fs_info, 6372 6374 "error inheriting props for ino %llu (root %llu): %d", 6373 - btrfs_ino(BTRFS_I(inode)), root->root_key.objectid, 6374 - ret); 6375 + btrfs_ino(BTRFS_I(inode)), btrfs_root_id(root), ret); 6375 6376 } 6376 6377 6377 6378 /* ··· 6443 6446 6444 6447 if (unlikely(ino == BTRFS_FIRST_FREE_OBJECTID)) { 6445 6448 ret = btrfs_add_root_ref(trans, key.objectid, 6446 - root->root_key.objectid, parent_ino, 6449 + btrfs_root_id(root), parent_ino, 6447 6450 index, name); 6448 6451 } else if (add_backref) { 6449 6452 ret = btrfs_insert_inode_ref(trans, root, name, ··· 6486 6489 u64 local_index; 6487 6490 int err; 6488 6491 err = btrfs_del_root_ref(trans, key.objectid, 6489 - root->root_key.objectid, parent_ino, 6492 + btrfs_root_id(root), parent_ino, 6490 6493 &local_index, name); 6491 6494 if (err) 6492 6495 btrfs_abort_transaction(trans, err); ··· 6584 6587 int drop_inode = 0; 6585 6588 6586 6589 /* do not allow sys_link's with other subvols of the same device */ 6587 - if (root->root_key.objectid != BTRFS_I(inode)->root->root_key.objectid) 6590 + if (btrfs_root_id(root) != btrfs_root_id(BTRFS_I(inode)->root)) 6588 6591 return -EXDEV; 6589 6592 6590 6593 if (inode->i_nlink >= BTRFS_LINK_MAX) ··· 9430 9433 * or we leak qgroup data reservation. 9431 9434 */ 9432 9435 btrfs_qgroup_free_refroot(inode->root->fs_info, 9433 - inode->root->root_key.objectid, qgroup_released, 9436 + btrfs_root_id(inode->root), qgroup_released, 9434 9437 BTRFS_QGROUP_RSV_DATA); 9435 9438 return ERR_PTR(ret); 9436 9439 } ··· 10531 10534 btrfs_exclop_finish(fs_info); 10532 10535 btrfs_warn(fs_info, 10533 10536 "cannot activate swapfile because subvolume %llu is being deleted", 10534 - root->root_key.objectid); 10537 + btrfs_root_id(root)); 10535 10538 return -EPERM; 10536 10539 } 10537 10540 atomic_inc(&root->nr_swapfiles); ··· 10757 10760 if (ordered) { 10758 10761 btrfs_err(root->fs_info, 10759 10762 "found unexpected ordered extent in file range [%llu, %llu] for inode %llu root %llu (ordered range [%llu, %llu])", 10760 - start, end, btrfs_ino(inode), root->root_key.objectid, 10763 + start, end, btrfs_ino(inode), btrfs_root_id(root), 10761 10764 ordered->file_offset, 10762 10765 ordered->file_offset + ordered->num_bytes - 1); 10763 10766 btrfs_put_ordered_extent(ordered);
+10 -10
fs/btrfs/ioctl.c
··· 668 668 /* Tree log can't currently deal with an inode which is a new root. */ 669 669 btrfs_set_log_full_commit(trans); 670 670 671 - ret = btrfs_qgroup_inherit(trans, 0, objectid, root->root_key.objectid, inherit); 671 + ret = btrfs_qgroup_inherit(trans, 0, objectid, btrfs_root_id(root), inherit); 672 672 if (ret) 673 673 goto out; 674 674 ··· 1510 1510 spin_unlock(&root->root_item_lock); 1511 1511 btrfs_warn(fs_info, 1512 1512 "Attempt to set subvolume %llu read-write during send", 1513 - root->root_key.objectid); 1513 + btrfs_root_id(root)); 1514 1514 ret = -EPERM; 1515 1515 goto out_drop_sem; 1516 1516 } ··· 1919 1919 struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info; 1920 1920 struct super_block *sb = inode->i_sb; 1921 1921 struct btrfs_key upper_limit = BTRFS_I(inode)->location; 1922 - u64 treeid = BTRFS_I(inode)->root->root_key.objectid; 1922 + u64 treeid = btrfs_root_id(BTRFS_I(inode)->root); 1923 1923 u64 dirid = args->dirid; 1924 1924 unsigned long item_off; 1925 1925 unsigned long item_len; ··· 2091 2091 * path is reset so it's consistent with btrfs_search_path_in_tree. 2092 2092 */ 2093 2093 if (args->treeid == 0) 2094 - args->treeid = root->root_key.objectid; 2094 + args->treeid = btrfs_root_id(root); 2095 2095 2096 2096 if (args->objectid == BTRFS_FIRST_FREE_OBJECTID) { 2097 2097 args->name[0] = 0; ··· 2187 2187 fs_info = BTRFS_I(inode)->root->fs_info; 2188 2188 2189 2189 /* Get root_item of inode's subvolume */ 2190 - key.objectid = BTRFS_I(inode)->root->root_key.objectid; 2190 + key.objectid = btrfs_root_id(BTRFS_I(inode)->root); 2191 2191 root = btrfs_get_fs_root(fs_info, key.objectid, true); 2192 2192 if (IS_ERR(root)) { 2193 2193 ret = PTR_ERR(root); ··· 2302 2302 return PTR_ERR(rootrefs); 2303 2303 } 2304 2304 2305 - objectid = root->root_key.objectid; 2305 + objectid = btrfs_root_id(root); 2306 2306 key.objectid = objectid; 2307 2307 key.type = BTRFS_ROOT_REF_KEY; 2308 2308 key.offset = rootrefs->min_treeid; ··· 2981 2981 ret = PTR_ERR(new_root); 2982 2982 goto out; 2983 2983 } 2984 - if (!is_fstree(new_root->root_key.objectid)) { 2984 + if (!is_fstree(btrfs_root_id(new_root))) { 2985 2985 ret = -ENOENT; 2986 2986 goto out_free; 2987 2987 } ··· 3947 3947 qgroupid = sa->qgroupid; 3948 3948 if (!qgroupid) { 3949 3949 /* take the current subvol as qgroup */ 3950 - qgroupid = root->root_key.objectid; 3950 + qgroupid = btrfs_root_id(root); 3951 3951 } 3952 3952 3953 3953 ret = btrfs_limit_qgroup(trans, qgroupid, &sa->lim); ··· 4078 4078 !btrfs_is_empty_uuid(root_item->received_uuid)) { 4079 4079 ret = btrfs_uuid_tree_remove(trans, root_item->received_uuid, 4080 4080 BTRFS_UUID_KEY_RECEIVED_SUBVOL, 4081 - root->root_key.objectid); 4081 + btrfs_root_id(root)); 4082 4082 if (ret && ret != -ENOENT) { 4083 4083 btrfs_abort_transaction(trans, ret); 4084 4084 btrfs_end_transaction(trans); ··· 4102 4102 if (received_uuid_changed && !btrfs_is_empty_uuid(sa->uuid)) { 4103 4103 ret = btrfs_uuid_tree_add(trans, sa->uuid, 4104 4104 BTRFS_UUID_KEY_RECEIVED_SUBVOL, 4105 - root->root_key.objectid); 4105 + btrfs_root_id(root)); 4106 4106 if (ret < 0 && ret != -EEXIST) { 4107 4107 btrfs_abort_transaction(trans, ret); 4108 4108 btrfs_end_transaction(trans);
+1 -1
fs/btrfs/locking.c
··· 97 97 void btrfs_maybe_reset_lockdep_class(struct btrfs_root *root, struct extent_buffer *eb) 98 98 { 99 99 if (test_bit(BTRFS_ROOT_RESET_LOCKDEP_CLASS, &root->state)) 100 - btrfs_set_buffer_lockdep_class(root->root_key.objectid, 100 + btrfs_set_buffer_lockdep_class(btrfs_root_id(root), 101 101 eb, btrfs_header_level(eb)); 102 102 } 103 103
+1 -1
fs/btrfs/ordered-data.c
··· 332 332 if (WARN_ON_ONCE(len > ordered->bytes_left)) { 333 333 btrfs_crit(fs_info, 334 334 "bad ordered extent accounting, root=%llu ino=%llu OE offset=%llu OE len=%llu to_dec=%llu left=%llu", 335 - inode->root->root_key.objectid, btrfs_ino(inode), 335 + btrfs_root_id(inode->root), btrfs_ino(inode), 336 336 ordered->file_offset, ordered->num_bytes, 337 337 len, ordered->bytes_left); 338 338 ordered->bytes_left = 0;
+1 -1
fs/btrfs/props.c
··· 268 268 btrfs_warn(root->fs_info, 269 269 "error applying prop %s to ino %llu (root %llu): %d", 270 270 handler->xattr_name, btrfs_ino(BTRFS_I(inode)), 271 - root->root_key.objectid, ret); 271 + btrfs_root_id(root), ret); 272 272 else 273 273 set_bit(BTRFS_INODE_HAS_PROPS, &BTRFS_I(inode)->runtime_flags); 274 274 }
+13 -14
fs/btrfs/qgroup.c
··· 3468 3468 { 3469 3469 struct btrfs_qgroup *qgroup; 3470 3470 struct btrfs_fs_info *fs_info = root->fs_info; 3471 - u64 ref_root = root->root_key.objectid; 3471 + u64 ref_root = btrfs_root_id(root); 3472 3472 int ret = 0; 3473 3473 LIST_HEAD(qgroup_list); 3474 3474 ··· 4109 4109 int ret; 4110 4110 4111 4111 if (btrfs_qgroup_mode(root->fs_info) == BTRFS_QGROUP_MODE_DISABLED || 4112 - !is_fstree(root->root_key.objectid) || len == 0) 4112 + !is_fstree(btrfs_root_id(root)) || len == 0) 4113 4113 return 0; 4114 4114 4115 4115 /* @reserved parameter is mandatory for qgroup */ ··· 4225 4225 goto out; 4226 4226 freed += changeset.bytes_changed; 4227 4227 } 4228 - btrfs_qgroup_free_refroot(root->fs_info, root->root_key.objectid, freed, 4228 + btrfs_qgroup_free_refroot(root->fs_info, btrfs_root_id(root), freed, 4229 4229 BTRFS_QGROUP_RSV_DATA); 4230 4230 if (freed_ret) 4231 4231 *freed_ret = freed; ··· 4266 4266 changeset.bytes_changed, trace_op); 4267 4267 if (free) 4268 4268 btrfs_qgroup_free_refroot(inode->root->fs_info, 4269 - inode->root->root_key.objectid, 4269 + btrfs_root_id(inode->root), 4270 4270 changeset.bytes_changed, BTRFS_QGROUP_RSV_DATA); 4271 4271 if (released) 4272 4272 *released = changeset.bytes_changed; ··· 4361 4361 int ret; 4362 4362 4363 4363 if (btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_DISABLED || 4364 - !is_fstree(root->root_key.objectid) || num_bytes == 0) 4364 + !is_fstree(btrfs_root_id(root)) || num_bytes == 0) 4365 4365 return 0; 4366 4366 4367 4367 BUG_ON(num_bytes != round_down(num_bytes, fs_info->nodesize)); ··· 4406 4406 struct btrfs_fs_info *fs_info = root->fs_info; 4407 4407 4408 4408 if (btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_DISABLED || 4409 - !is_fstree(root->root_key.objectid)) 4409 + !is_fstree(btrfs_root_id(root))) 4410 4410 return; 4411 4411 4412 4412 /* TODO: Update trace point to handle such free */ 4413 4413 trace_qgroup_meta_free_all_pertrans(root); 4414 4414 /* Special value -1 means to free all reserved space */ 4415 - btrfs_qgroup_free_refroot(fs_info, root->root_key.objectid, (u64)-1, 4415 + btrfs_qgroup_free_refroot(fs_info, btrfs_root_id(root), (u64)-1, 4416 4416 BTRFS_QGROUP_RSV_META_PERTRANS); 4417 4417 } 4418 4418 ··· 4422 4422 struct btrfs_fs_info *fs_info = root->fs_info; 4423 4423 4424 4424 if (btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_DISABLED || 4425 - !is_fstree(root->root_key.objectid)) 4425 + !is_fstree(btrfs_root_id(root))) 4426 4426 return; 4427 4427 4428 4428 /* ··· 4433 4433 num_bytes = sub_root_meta_rsv(root, num_bytes, type); 4434 4434 BUG_ON(num_bytes != round_down(num_bytes, fs_info->nodesize)); 4435 4435 trace_qgroup_meta_reserve(root, -(s64)num_bytes, type); 4436 - btrfs_qgroup_free_refroot(fs_info, root->root_key.objectid, 4437 - num_bytes, type); 4436 + btrfs_qgroup_free_refroot(fs_info, btrfs_root_id(root), num_bytes, type); 4438 4437 } 4439 4438 4440 4439 static void qgroup_convert_meta(struct btrfs_fs_info *fs_info, u64 ref_root, ··· 4481 4482 struct btrfs_fs_info *fs_info = root->fs_info; 4482 4483 4483 4484 if (btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_DISABLED || 4484 - !is_fstree(root->root_key.objectid)) 4485 + !is_fstree(btrfs_root_id(root))) 4485 4486 return; 4486 4487 /* Same as btrfs_qgroup_free_meta_prealloc() */ 4487 4488 num_bytes = sub_root_meta_rsv(root, num_bytes, 4488 4489 BTRFS_QGROUP_RSV_META_PREALLOC); 4489 4490 trace_qgroup_meta_convert(root, num_bytes); 4490 - qgroup_convert_meta(fs_info, root->root_key.objectid, num_bytes); 4491 + qgroup_convert_meta(fs_info, btrfs_root_id(root), num_bytes); 4491 4492 if (!sb_rdonly(fs_info->sb)) 4492 4493 add_root_meta_rsv(root, num_bytes, BTRFS_QGROUP_RSV_META_PERTRANS); 4493 4494 } ··· 4516 4517 btrfs_ino(inode), unode->val, unode->aux); 4517 4518 } 4518 4519 btrfs_qgroup_free_refroot(inode->root->fs_info, 4519 - inode->root->root_key.objectid, 4520 + btrfs_root_id(inode->root), 4520 4521 changeset.bytes_changed, BTRFS_QGROUP_RSV_DATA); 4521 4522 4522 4523 } ··· 4702 4703 4703 4704 if (!btrfs_qgroup_full_accounting(fs_info)) 4704 4705 return 0; 4705 - if (!is_fstree(root->root_key.objectid) || !root->reloc_root) 4706 + if (!is_fstree(btrfs_root_id(root)) || !root->reloc_root) 4706 4707 return 0; 4707 4708 4708 4709 spin_lock(&blocks->lock);
+1 -1
fs/btrfs/reflink.c
··· 665 665 if (root_dst->send_in_progress) { 666 666 btrfs_warn_rl(root_dst->fs_info, 667 667 "cannot deduplicate to root %llu while send operations are using it (%d in progress)", 668 - root_dst->root_key.objectid, 668 + btrfs_root_id(root_dst), 669 669 root_dst->send_in_progress); 670 670 spin_unlock(&root_dst->root_item_lock); 671 671 return -EAGAIN;
+30 -33
fs/btrfs/relocation.c
··· 754 754 root_key.type = BTRFS_ROOT_ITEM_KEY; 755 755 root_key.offset = objectid; 756 756 757 - if (root->root_key.objectid == objectid) { 757 + if (btrfs_root_id(root) == objectid) { 758 758 u64 commit_root_gen; 759 759 760 760 /* called by btrfs_init_reloc_root */ ··· 798 798 btrfs_set_root_level(root_item, btrfs_header_level(eb)); 799 799 btrfs_set_root_generation(root_item, trans->transid); 800 800 801 - if (root->root_key.objectid == objectid) { 801 + if (btrfs_root_id(root) == objectid) { 802 802 btrfs_set_root_refs(root_item, 0); 803 803 memset(&root_item->drop_progress, 0, 804 804 sizeof(struct btrfs_disk_key)); ··· 876 876 * We are merging reloc roots, we do not need new reloc trees. Also 877 877 * reloc trees never need their own reloc tree. 878 878 */ 879 - if (!rc->create_reloc_tree || 880 - root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) 879 + if (!rc->create_reloc_tree || btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID) 881 880 return 0; 882 881 883 882 if (!trans->reloc_reserved) { ··· 884 885 trans->block_rsv = rc->block_rsv; 885 886 clear_rsv = 1; 886 887 } 887 - reloc_root = create_reloc_root(trans, root, root->root_key.objectid); 888 + reloc_root = create_reloc_root(trans, root, btrfs_root_id(root)); 888 889 if (clear_rsv) 889 890 trans->block_rsv = rsv; 890 891 if (IS_ERR(reloc_root)) ··· 1026 1027 return 0; 1027 1028 1028 1029 /* reloc trees always use full backref */ 1029 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) 1030 + if (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID) 1030 1031 parent = leaf->start; 1031 1032 else 1032 1033 parent = 0; ··· 1055 1056 * if we are modifying block in fs tree, wait for read_folio 1056 1057 * to complete and drop the extent cache 1057 1058 */ 1058 - if (root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID) { 1059 + if (btrfs_root_id(root) != BTRFS_TREE_RELOC_OBJECTID) { 1059 1060 if (first) { 1060 1061 inode = btrfs_find_first_inode(root, key.objectid); 1061 1062 first = 0; ··· 1107 1108 ref.bytenr = new_bytenr; 1108 1109 ref.num_bytes = num_bytes; 1109 1110 ref.parent = parent; 1110 - ref.owning_root = root->root_key.objectid; 1111 + ref.owning_root = btrfs_root_id(root); 1111 1112 ref.ref_root = btrfs_header_owner(leaf); 1112 1113 btrfs_init_data_ref(&ref, key.objectid, key.offset, 1113 - root->root_key.objectid, false); 1114 + btrfs_root_id(root), false); 1114 1115 ret = btrfs_inc_extent_ref(trans, &ref); 1115 1116 if (ret) { 1116 1117 btrfs_abort_transaction(trans, ret); ··· 1121 1122 ref.bytenr = bytenr; 1122 1123 ref.num_bytes = num_bytes; 1123 1124 ref.parent = parent; 1124 - ref.owning_root = root->root_key.objectid; 1125 + ref.owning_root = btrfs_root_id(root); 1125 1126 ref.ref_root = btrfs_header_owner(leaf); 1126 1127 btrfs_init_data_ref(&ref, key.objectid, key.offset, 1127 - root->root_key.objectid, false); 1128 + btrfs_root_id(root), false); 1128 1129 ret = btrfs_free_extent(trans, &ref); 1129 1130 if (ret) { 1130 1131 btrfs_abort_transaction(trans, ret); ··· 1180 1181 int ret; 1181 1182 int slot; 1182 1183 1183 - ASSERT(src->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID); 1184 - ASSERT(dest->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID); 1184 + ASSERT(btrfs_root_id(src) == BTRFS_TREE_RELOC_OBJECTID); 1185 + ASSERT(btrfs_root_id(dest) != BTRFS_TREE_RELOC_OBJECTID); 1185 1186 1186 1187 last_snapshot = btrfs_root_last_snapshot(&src->root_item); 1187 1188 again: ··· 1337 1338 ref.bytenr = old_bytenr; 1338 1339 ref.num_bytes = blocksize; 1339 1340 ref.parent = path->nodes[level]->start; 1340 - ref.owning_root = src->root_key.objectid; 1341 - ref.ref_root = src->root_key.objectid; 1341 + ref.owning_root = btrfs_root_id(src); 1342 + ref.ref_root = btrfs_root_id(src); 1342 1343 btrfs_init_tree_ref(&ref, level - 1, 0, true); 1343 1344 ret = btrfs_inc_extent_ref(trans, &ref); 1344 1345 if (ret) { ··· 1350 1351 ref.bytenr = new_bytenr; 1351 1352 ref.num_bytes = blocksize; 1352 1353 ref.parent = 0; 1353 - ref.owning_root = dest->root_key.objectid; 1354 - ref.ref_root = dest->root_key.objectid; 1354 + ref.owning_root = btrfs_root_id(dest); 1355 + ref.ref_root = btrfs_root_id(dest); 1355 1356 btrfs_init_tree_ref(&ref, level - 1, 0, true); 1356 1357 ret = btrfs_inc_extent_ref(trans, &ref); 1357 1358 if (ret) { ··· 1365 1366 ref.num_bytes = blocksize; 1366 1367 ref.parent = path->nodes[level]->start; 1367 1368 ref.owning_root = 0; 1368 - ref.ref_root = src->root_key.objectid; 1369 + ref.ref_root = btrfs_root_id(src); 1369 1370 btrfs_init_tree_ref(&ref, level - 1, 0, true); 1370 1371 ret = btrfs_free_extent(trans, &ref); 1371 1372 if (ret) { ··· 1379 1380 ref.num_bytes = blocksize; 1380 1381 ref.parent = 0; 1381 1382 ref.owning_root = 0; 1382 - ref.ref_root = dest->root_key.objectid; 1383 + ref.ref_root = btrfs_root_id(dest); 1383 1384 btrfs_init_tree_ref(&ref, level - 1, 0, true); 1384 1385 ret = btrfs_free_extent(trans, &ref); 1385 1386 if (ret) { ··· 1585 1586 int ret; 1586 1587 1587 1588 /* @root must be a subvolume tree root with a valid reloc tree */ 1588 - ASSERT(root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID); 1589 + ASSERT(btrfs_root_id(root) != BTRFS_TREE_RELOC_OBJECTID); 1589 1590 ASSERT(reloc_root); 1590 1591 1591 1592 reloc_root_item = &reloc_root->root_item; ··· 1614 1615 1615 1616 list_for_each_entry_safe(root, next, &rc->dirty_subvol_roots, 1616 1617 reloc_dirty_list) { 1617 - if (root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID) { 1618 + if (btrfs_root_id(root) != BTRFS_TREE_RELOC_OBJECTID) { 1618 1619 /* Merged subvolume, cleanup its reloc root */ 1619 1620 struct btrfs_root *reloc_root = root->reloc_root; 1620 1621 ··· 1889 1890 if (root->reloc_root) { 1890 1891 btrfs_err(fs_info, 1891 1892 "reloc tree mismatch, root %lld has reloc root key (%lld %u %llu) gen %llu, expect reloc root key (%lld %u %llu) gen %llu", 1892 - root->root_key.objectid, 1893 - root->reloc_root->root_key.objectid, 1893 + btrfs_root_id(root), 1894 + btrfs_root_id(root->reloc_root), 1894 1895 root->reloc_root->root_key.type, 1895 1896 root->reloc_root->root_key.offset, 1896 1897 btrfs_root_generation( 1897 1898 &root->reloc_root->root_item), 1898 - reloc_root->root_key.objectid, 1899 + btrfs_root_id(reloc_root), 1899 1900 reloc_root->root_key.type, 1900 1901 reloc_root->root_key.offset, 1901 1902 btrfs_root_generation( ··· 1903 1904 } else { 1904 1905 btrfs_err(fs_info, 1905 1906 "reloc tree mismatch, root %lld has no reloc root, expect reloc root key (%lld %u %llu) gen %llu", 1906 - root->root_key.objectid, 1907 - reloc_root->root_key.objectid, 1907 + btrfs_root_id(root), 1908 + btrfs_root_id(reloc_root), 1908 1909 reloc_root->root_key.type, 1909 1910 reloc_root->root_key.offset, 1910 1911 btrfs_root_generation( ··· 2161 2162 return ERR_PTR(-EUCLEAN); 2162 2163 } 2163 2164 2164 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) { 2165 + if (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID) { 2165 2166 ret = record_reloc_root_in_trans(trans, root); 2166 2167 if (ret) 2167 2168 return ERR_PTR(ret); ··· 2268 2269 if (!test_bit(BTRFS_ROOT_SHAREABLE, &root->state)) 2269 2270 return root; 2270 2271 2271 - if (root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID) 2272 + if (btrfs_root_id(root) != BTRFS_TREE_RELOC_OBJECTID) 2272 2273 fs_root = root; 2273 2274 2274 2275 if (next != node) ··· 2494 2495 btrfs_mark_buffer_dirty(trans, upper->eb); 2495 2496 2496 2497 btrfs_init_tree_ref(&ref, node->level, 2497 - root->root_key.objectid, false); 2498 + btrfs_root_id(root), false); 2498 2499 ret = btrfs_inc_extent_ref(trans, &ref); 2499 2500 if (!ret) 2500 2501 ret = btrfs_drop_subtree(trans, root, eb, ··· 4462 4463 btrfs_root_last_snapshot(&root->root_item)) 4463 4464 first_cow = 1; 4464 4465 4465 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID && 4466 - rc->create_reloc_tree) { 4466 + if (btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID && rc->create_reloc_tree) { 4467 4467 WARN_ON(!first_cow && level == 0); 4468 4468 4469 4469 node = rc->backref_cache.path[level]; ··· 4555 4557 } 4556 4558 4557 4559 new_root = pending->snap; 4558 - reloc_root = create_reloc_root(trans, root->reloc_root, 4559 - new_root->root_key.objectid); 4560 + reloc_root = create_reloc_root(trans, root->reloc_root, btrfs_root_id(new_root)); 4560 4561 if (IS_ERR(reloc_root)) 4561 4562 return PTR_ERR(reloc_root); 4562 4563
+1 -2
fs/btrfs/root-tree.c
··· 148 148 if (ret > 0) { 149 149 btrfs_crit(fs_info, 150 150 "unable to find root key (%llu %u %llu) in tree %llu", 151 - key->objectid, key->type, key->offset, 152 - root->root_key.objectid); 151 + key->objectid, key->type, key->offset, btrfs_root_id(root)); 153 152 ret = -EUCLEAN; 154 153 btrfs_abort_transaction(trans, ret); 155 154 goto out;
+14 -15
fs/btrfs/send.c
··· 392 392 btrfs_err(sctx->send_root->fs_info, 393 393 "Send: inconsistent snapshot, found %s %s for inode %llu without updated inode item, send root is %llu, parent root is %llu", 394 394 result_string, what, sctx->cmp_key->objectid, 395 - sctx->send_root->root_key.objectid, 396 - (sctx->parent_root ? 397 - sctx->parent_root->root_key.objectid : 0)); 395 + btrfs_root_id(sctx->send_root), 396 + (sctx->parent_root ? btrfs_root_id(sctx->parent_root) : 0)); 398 397 } 399 398 400 399 __maybe_unused ··· 1315 1316 u64 root = (u64)(uintptr_t)key; 1316 1317 const struct clone_root *cr = elt; 1317 1318 1318 - if (root < cr->root->root_key.objectid) 1319 + if (root < btrfs_root_id(cr->root)) 1319 1320 return -1; 1320 - if (root > cr->root->root_key.objectid) 1321 + if (root > btrfs_root_id(cr->root)) 1321 1322 return 1; 1322 1323 return 0; 1323 1324 } ··· 1327 1328 const struct clone_root *cr1 = e1; 1328 1329 const struct clone_root *cr2 = e2; 1329 1330 1330 - if (cr1->root->root_key.objectid < cr2->root->root_key.objectid) 1331 + if (btrfs_root_id(cr1->root) < btrfs_root_id(cr2->root)) 1331 1332 return -1; 1332 - if (cr1->root->root_key.objectid > cr2->root->root_key.objectid) 1333 + if (btrfs_root_id(cr1->root) > btrfs_root_id(cr2->root)) 1333 1334 return 1; 1334 1335 return 0; 1335 1336 } ··· 1777 1778 */ 1778 1779 btrfs_err(root->fs_info, 1779 1780 "Found empty symlink inode %llu at root %llu", 1780 - ino, root->root_key.objectid); 1781 + ino, btrfs_root_id(root)); 1781 1782 ret = -EIO; 1782 1783 goto out; 1783 1784 } ··· 2531 2532 return -ENOMEM; 2532 2533 } 2533 2534 2534 - key.objectid = send_root->root_key.objectid; 2535 + key.objectid = btrfs_root_id(send_root); 2535 2536 key.type = BTRFS_ROOT_BACKREF_KEY; 2536 2537 key.offset = 0; 2537 2538 ··· 2547 2548 leaf = path->nodes[0]; 2548 2549 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); 2549 2550 if (key.type != BTRFS_ROOT_BACKREF_KEY || 2550 - key.objectid != send_root->root_key.objectid) { 2551 + key.objectid != btrfs_root_id(send_root)) { 2551 2552 ret = -ENOENT; 2552 2553 goto out; 2553 2554 } ··· 5317 5318 btrfs_err(fs_info, 5318 5319 "send: IO error at offset %llu for inode %llu root %llu", 5319 5320 folio_pos(folio), sctx->cur_ino, 5320 - sctx->send_root->root_key.objectid); 5321 + btrfs_root_id(sctx->send_root)); 5321 5322 folio_put(folio); 5322 5323 ret = -EIO; 5323 5324 break; ··· 5388 5389 5389 5390 btrfs_debug(sctx->send_root->fs_info, 5390 5391 "send_clone offset=%llu, len=%d, clone_root=%llu, clone_inode=%llu, clone_offset=%llu", 5391 - offset, len, clone_root->root->root_key.objectid, 5392 + offset, len, btrfs_root_id(clone_root->root), 5392 5393 clone_root->ino, clone_root->offset); 5393 5394 5394 5395 p = fs_path_alloc(); ··· 7337 7338 "send: key (%llu %u %llu) not found in %s root %llu, lowest_level %d, slot %d", 7338 7339 key->objectid, key->type, key->offset, 7339 7340 (root == sctx->parent_root ? "parent" : "send"), 7340 - root->root_key.objectid, path->lowest_level, 7341 + btrfs_root_id(root), path->lowest_level, 7341 7342 path->slots[path->lowest_level]); 7342 7343 return -EUCLEAN; 7343 7344 } ··· 8071 8072 if (root->send_in_progress < 0) 8072 8073 btrfs_err(root->fs_info, 8073 8074 "send_in_progress unbalanced %d root %llu", 8074 - root->send_in_progress, root->root_key.objectid); 8075 + root->send_in_progress, btrfs_root_id(root)); 8075 8076 spin_unlock(&root->root_item_lock); 8076 8077 } 8077 8078 ··· 8079 8080 { 8080 8081 btrfs_warn_rl(root->fs_info, 8081 8082 "cannot use root %llu for send while deduplications on it are in progress (%d in progress)", 8082 - root->root_key.objectid, root->dedupe_in_progress); 8083 + btrfs_root_id(root), root->dedupe_in_progress); 8083 8084 } 8084 8085 8085 8086 long btrfs_ioctl_send(struct inode *inode, struct btrfs_ioctl_send_args *arg)
+5 -8
fs/btrfs/super.c
··· 1097 1097 #endif 1098 1098 if (btrfs_test_opt(info, REF_VERIFY)) 1099 1099 seq_puts(seq, ",ref_verify"); 1100 - seq_printf(seq, ",subvolid=%llu", 1101 - BTRFS_I(d_inode(dentry))->root->root_key.objectid); 1100 + seq_printf(seq, ",subvolid=%llu", btrfs_root_id(BTRFS_I(d_inode(dentry))->root)); 1102 1101 subvol_name = btrfs_get_subvol_name_from_objectid(info, 1103 - BTRFS_I(d_inode(dentry))->root->root_key.objectid); 1102 + btrfs_root_id(BTRFS_I(d_inode(dentry))->root)); 1104 1103 if (!IS_ERR(subvol_name)) { 1105 1104 seq_puts(seq, ",subvol="); 1106 1105 seq_escape(seq, subvol_name, " \t\n\\"); ··· 1151 1152 struct super_block *s = root->d_sb; 1152 1153 struct btrfs_fs_info *fs_info = btrfs_sb(s); 1153 1154 struct inode *root_inode = d_inode(root); 1154 - u64 root_objectid = BTRFS_I(root_inode)->root->root_key.objectid; 1155 + u64 root_objectid = btrfs_root_id(BTRFS_I(root_inode)->root); 1155 1156 1156 1157 ret = 0; 1157 1158 if (!is_subvolume_inode(root_inode)) { ··· 1773 1774 buf->f_fsid.val[0] = be32_to_cpu(fsid[0]) ^ be32_to_cpu(fsid[2]); 1774 1775 buf->f_fsid.val[1] = be32_to_cpu(fsid[1]) ^ be32_to_cpu(fsid[3]); 1775 1776 /* Mask in the root object ID too, to disambiguate subvols */ 1776 - buf->f_fsid.val[0] ^= 1777 - BTRFS_I(d_inode(dentry))->root->root_key.objectid >> 32; 1778 - buf->f_fsid.val[1] ^= 1779 - BTRFS_I(d_inode(dentry))->root->root_key.objectid; 1777 + buf->f_fsid.val[0] ^= btrfs_root_id(BTRFS_I(d_inode(dentry))->root) >> 32; 1778 + buf->f_fsid.val[1] ^= btrfs_root_id(BTRFS_I(d_inode(dentry))->root); 1780 1779 1781 1780 return 0; 1782 1781 }
+11 -11
fs/btrfs/transaction.c
··· 426 426 return 0; 427 427 } 428 428 radix_tree_tag_set(&fs_info->fs_roots_radix, 429 - (unsigned long)root->root_key.objectid, 429 + (unsigned long)btrfs_root_id(root), 430 430 BTRFS_ROOT_TRANS_TAG); 431 431 spin_unlock(&fs_info->fs_roots_radix_lock); 432 432 root->last_trans = trans->transid; ··· 472 472 /* Make sure we don't try to update the root at commit time */ 473 473 spin_lock(&fs_info->fs_roots_radix_lock); 474 474 radix_tree_tag_clear(&fs_info->fs_roots_radix, 475 - (unsigned long)root->root_key.objectid, 475 + (unsigned long)btrfs_root_id(root), 476 476 BTRFS_ROOT_TRANS_TAG); 477 477 spin_unlock(&fs_info->fs_roots_radix_lock); 478 478 } ··· 550 550 551 551 if (!fs_info->reloc_ctl || 552 552 !test_bit(BTRFS_ROOT_SHAREABLE, &root->state) || 553 - root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID || 553 + btrfs_root_id(root) == BTRFS_TREE_RELOC_OBJECTID || 554 554 root->reloc_root) 555 555 return false; 556 556 ··· 1229 1229 bool errors = false; 1230 1230 int err; 1231 1231 1232 - ASSERT(log_root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID); 1232 + ASSERT(btrfs_root_id(log_root) == BTRFS_TREE_LOG_OBJECTID); 1233 1233 1234 1234 err = __btrfs_wait_marked_extents(fs_info, dirty_pages); 1235 1235 if ((mark & EXTENT_DIRTY) && ··· 1492 1492 ASSERT(atomic_read(&root->log_commit[1]) == 0); 1493 1493 1494 1494 radix_tree_tag_clear(&fs_info->fs_roots_radix, 1495 - (unsigned long)root->root_key.objectid, 1495 + (unsigned long)btrfs_root_id(root), 1496 1496 BTRFS_ROOT_TRANS_TAG); 1497 1497 btrfs_qgroup_free_meta_all_pertrans(root); 1498 1498 spin_unlock(&fs_info->fs_roots_radix_lock); ··· 1583 1583 goto out; 1584 1584 1585 1585 /* Now qgroup are all updated, we can inherit it to new qgroups */ 1586 - ret = btrfs_qgroup_inherit(trans, src->root_key.objectid, dst_objectid, 1587 - parent->root_key.objectid, inherit); 1586 + ret = btrfs_qgroup_inherit(trans, btrfs_root_id(src), dst_objectid, 1587 + btrfs_root_id(parent), inherit); 1588 1588 if (ret < 0) 1589 1589 goto out; 1590 1590 ··· 1822 1822 * insert root back/forward references 1823 1823 */ 1824 1824 ret = btrfs_add_root_ref(trans, objectid, 1825 - parent_root->root_key.objectid, 1825 + btrfs_root_id(parent_root), 1826 1826 btrfs_ino(BTRFS_I(parent_inode)), index, 1827 1827 &fname.disk_name); 1828 1828 if (ret) { ··· 1855 1855 ret = qgroup_account_snapshot(trans, root, parent_root, 1856 1856 pending->inherit, objectid); 1857 1857 else if (btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_SIMPLE) 1858 - ret = btrfs_qgroup_inherit(trans, root->root_key.objectid, objectid, 1859 - parent_root->root_key.objectid, pending->inherit); 1858 + ret = btrfs_qgroup_inherit(trans, btrfs_root_id(root), objectid, 1859 + btrfs_root_id(parent_root), pending->inherit); 1860 1860 if (ret < 0) 1861 1861 goto fail; 1862 1862 ··· 2623 2623 list_del_init(&root->root_list); 2624 2624 spin_unlock(&fs_info->trans_lock); 2625 2625 2626 - btrfs_debug(fs_info, "cleaner removing %llu", root->root_key.objectid); 2626 + btrfs_debug(fs_info, "cleaner removing %llu", btrfs_root_id(root)); 2627 2627 2628 2628 btrfs_kill_all_delayed_nodes(root); 2629 2629
+5 -5
fs/btrfs/tree-log.c
··· 391 391 * the leaf before writing into the log tree. See the comments at 392 392 * copy_items() for more details. 393 393 */ 394 - ASSERT(root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID); 394 + ASSERT(btrfs_root_id(root) != BTRFS_TREE_LOG_OBJECTID); 395 395 396 396 item_size = btrfs_item_size(eb, slot); 397 397 src_ptr = btrfs_item_ptr_offset(eb, slot); ··· 765 765 .action = BTRFS_ADD_DELAYED_REF, 766 766 .bytenr = ins.objectid, 767 767 .num_bytes = ins.offset, 768 - .owning_root = root->root_key.objectid, 769 - .ref_root = root->root_key.objectid, 768 + .owning_root = btrfs_root_id(root), 769 + .ref_root = btrfs_root_id(root), 770 770 }; 771 771 btrfs_init_data_ref(&ref, key->objectid, offset, 772 772 0, false); ··· 779 779 * allocation tree 780 780 */ 781 781 ret = btrfs_alloc_logged_file_extent(trans, 782 - root->root_key.objectid, 782 + btrfs_root_id(root), 783 783 key->objectid, offset, &ins); 784 784 if (ret) 785 785 goto out; ··· 3047 3047 if (ret != -ENOSPC) 3048 3048 btrfs_err(fs_info, 3049 3049 "failed to update log for root %llu ret %d", 3050 - root->root_key.objectid, ret); 3050 + btrfs_root_id(root), ret); 3051 3051 btrfs_wait_tree_log_extents(log, mark); 3052 3052 mutex_unlock(&log_root_tree->log_mutex); 3053 3053 goto out;
+1 -1
fs/btrfs/tree-mod-log.c
··· 1004 1004 free_extent_buffer(eb_root); 1005 1005 1006 1006 check.level = level; 1007 - check.owner_root = root->root_key.objectid; 1007 + check.owner_root = btrfs_root_id(root); 1008 1008 1009 1009 old = read_tree_block(fs_info, logical, &check); 1010 1010 if (WARN_ON(IS_ERR(old) || !extent_buffer_uptodate(old))) {