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

btrfs: Remove 'objectid' member from struct btrfs_root

There are two members in struct btrfs_root which indicate root's
objectid: objectid and root_key.objectid.

They are both set to the same value in __setup_root():

static void __setup_root(struct btrfs_root *root,
struct btrfs_fs_info *fs_info,
u64 objectid)
{
...
root->objectid = objectid;
...
root->root_key.objectid = objecitd;
...
}

and not changed to other value after initialization.

grep in btrfs directory shows both are used in many places:
$ grep -rI "root->root_key.objectid" | wc -l
133
$ grep -rI "root->objectid" | wc -l
55
(4.17, inc. some noise)

It is confusing to have two similar variable names and it seems
that there is no rule about which should be used in a certain case.

Since ->root_key itself is needed for tree reloc tree, let's remove
'objecitd' member and unify code to use ->root_key.objectid in all places.

Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Misono Tomohiro and committed by
David Sterba
4fd786e6 5a2cb25a

+58 -53
+3 -2
fs/btrfs/backref.c
··· 1468 1468 struct seq_list elem = SEQ_LIST_INIT(elem); 1469 1469 int ret = 0; 1470 1470 struct share_check shared = { 1471 - .root_objectid = root->objectid, 1471 + .root_objectid = root->root_key.objectid, 1472 1472 .inum = inum, 1473 1473 .share_count = 0, 1474 1474 }; ··· 2031 2031 /* path must be released before calling iterate()! */ 2032 2032 btrfs_debug(fs_root->fs_info, 2033 2033 "following ref at offset %u for inode %llu in tree %llu", 2034 - cur, found_key.objectid, fs_root->objectid); 2034 + cur, found_key.objectid, 2035 + fs_root->root_key.objectid); 2035 2036 ret = iterate(parent, name_len, 2036 2037 (unsigned long)(iref + 1), eb, ctx); 2037 2038 if (ret)
+4 -4
fs/btrfs/btrfs_inode.h
··· 206 206 static inline unsigned long btrfs_inode_hash(u64 objectid, 207 207 const struct btrfs_root *root) 208 208 { 209 - u64 h = objectid ^ (root->objectid * GOLDEN_RATIO_PRIME); 209 + u64 h = objectid ^ (root->root_key.objectid * GOLDEN_RATIO_PRIME); 210 210 211 211 #if BITS_PER_LONG == 32 212 212 h = (h >> 32) ^ (h & 0xffffffff); ··· 339 339 struct btrfs_root *root = inode->root; 340 340 341 341 /* Output minus objectid, which is more meaningful */ 342 - if (root->objectid >= BTRFS_LAST_FREE_OBJECTID) 342 + if (root->root_key.objectid >= BTRFS_LAST_FREE_OBJECTID) 343 343 btrfs_warn_rl(root->fs_info, 344 344 "csum failed root %lld ino %lld off %llu csum 0x%08x expected csum 0x%08x mirror %d", 345 - root->objectid, btrfs_ino(inode), 345 + root->root_key.objectid, btrfs_ino(inode), 346 346 logical_start, csum, csum_expected, mirror_num); 347 347 else 348 348 btrfs_warn_rl(root->fs_info, 349 349 "csum failed root %llu ino %llu off %llu csum 0x%08x expected csum 0x%08x mirror %d", 350 - root->objectid, btrfs_ino(inode), 350 + root->root_key.objectid, btrfs_ino(inode), 351 351 logical_start, csum, csum_expected, mirror_num); 352 352 } 353 353
+1 -1
fs/btrfs/ctree.c
··· 207 207 spin_lock(&fs_info->trans_lock); 208 208 if (!test_and_set_bit(BTRFS_ROOT_DIRTY, &root->state)) { 209 209 /* Want the extent tree to be the last on the list */ 210 - if (root->objectid == BTRFS_EXTENT_TREE_OBJECTID) 210 + if (root->root_key.objectid == BTRFS_EXTENT_TREE_OBJECTID) 211 211 list_move_tail(&root->dirty_list, 212 212 &fs_info->dirty_cowonly_roots); 213 213 else
-1
fs/btrfs/ctree.h
··· 1202 1202 int last_log_commit; 1203 1203 pid_t log_start_pid; 1204 1204 1205 - u64 objectid; 1206 1205 u64 last_trans; 1207 1206 1208 1207 u32 type;
+3 -2
fs/btrfs/delayed-inode.c
··· 1462 1462 if (unlikely(ret)) { 1463 1463 btrfs_err(trans->fs_info, 1464 1464 "err add delayed dir index item(name: %.*s) into the insertion tree of the delayed node(root id: %llu, inode id: %llu, errno: %d)", 1465 - name_len, name, delayed_node->root->objectid, 1465 + name_len, name, delayed_node->root->root_key.objectid, 1466 1466 delayed_node->inode_id, ret); 1467 1467 BUG(); 1468 1468 } ··· 1533 1533 if (unlikely(ret)) { 1534 1534 btrfs_err(trans->fs_info, 1535 1535 "err add delayed dir index item(index: %llu) into the deletion tree of the delayed node(root id: %llu, inode id: %llu, errno: %d)", 1536 - index, node->root->objectid, node->inode_id, ret); 1536 + index, node->root->root_key.objectid, 1537 + node->inode_id, ret); 1537 1538 BUG(); 1538 1539 } 1539 1540 mutex_unlock(&node->mutex);
+2 -3
fs/btrfs/disk-io.c
··· 125 125 * Different roots are used for different purposes and may nest inside each 126 126 * other and they require separate keysets. As lockdep keys should be 127 127 * static, assign keysets according to the purpose of the root as indicated 128 - * by btrfs_root->objectid. This ensures that all special purpose roots 129 - * have separate keysets. 128 + * by btrfs_root->root_key.objectid. This ensures that all special purpose 129 + * roots have separate keysets. 130 130 * 131 131 * Lock-nesting across peer nodes is always done with the immediate parent 132 132 * node locked thus preventing deadlock. As lockdep doesn't know this, use ··· 1148 1148 root->state = 0; 1149 1149 root->orphan_cleanup_state = 0; 1150 1150 1151 - root->objectid = objectid; 1152 1151 root->last_trans = 0; 1153 1152 root->highest_objectid = 0; 1154 1153 root->nr_delalloc_inodes = 0;
+2 -2
fs/btrfs/export.c
··· 33 33 type = FILEID_BTRFS_WITHOUT_PARENT; 34 34 35 35 fid->objectid = btrfs_ino(BTRFS_I(inode)); 36 - fid->root_objectid = BTRFS_I(inode)->root->objectid; 36 + fid->root_objectid = BTRFS_I(inode)->root->root_key.objectid; 37 37 fid->gen = inode->i_generation; 38 38 39 39 if (parent) { ··· 41 41 42 42 fid->parent_objectid = BTRFS_I(parent)->location.objectid; 43 43 fid->parent_gen = parent->i_generation; 44 - parent_root_id = BTRFS_I(parent)->root->objectid; 44 + parent_root_id = BTRFS_I(parent)->root->root_key.objectid; 45 45 46 46 if (parent_root_id != fid->root_objectid) { 47 47 fid->parent_root_objectid = parent_root_id;
+1 -1
fs/btrfs/extent-tree.c
··· 8873 8873 int level; 8874 8874 bool root_dropped = false; 8875 8875 8876 - btrfs_debug(fs_info, "Drop subvolume %llu", root->objectid); 8876 + btrfs_debug(fs_info, "Drop subvolume %llu", root->root_key.objectid); 8877 8877 8878 8878 path = btrfs_alloc_path(); 8879 8879 if (!path) {
+1 -1
fs/btrfs/inode.c
··· 6582 6582 int drop_inode = 0; 6583 6583 6584 6584 /* do not allow sys_link's with other subvols of the same device */ 6585 - if (root->objectid != BTRFS_I(inode)->root->objectid) 6585 + if (root->root_key.objectid != BTRFS_I(inode)->root->root_key.objectid) 6586 6586 return -EXDEV; 6587 6587 6588 6588 if (inode->i_nlink >= BTRFS_LINK_MAX)
+1 -1
fs/btrfs/ioctl.c
··· 4392 4392 ret = PTR_ERR(new_root); 4393 4393 goto out; 4394 4394 } 4395 - if (!is_fstree(new_root->objectid)) { 4395 + if (!is_fstree(new_root->root_key.objectid)) { 4396 4396 ret = -ENOENT; 4397 4397 goto out; 4398 4398 }
+12 -11
fs/btrfs/qgroup.c
··· 3004 3004 int ret; 3005 3005 3006 3006 if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &root->fs_info->flags) || 3007 - !is_fstree(root->objectid) || len == 0) 3007 + !is_fstree(root->root_key.objectid) || len == 0) 3008 3008 return 0; 3009 3009 3010 3010 /* @reserved parameter is mandatory for qgroup */ ··· 3090 3090 goto out; 3091 3091 freed += changeset.bytes_changed; 3092 3092 } 3093 - btrfs_qgroup_free_refroot(root->fs_info, root->objectid, freed, 3093 + btrfs_qgroup_free_refroot(root->fs_info, root->root_key.objectid, freed, 3094 3094 BTRFS_QGROUP_RSV_DATA); 3095 3095 ret = freed; 3096 3096 out: ··· 3122 3122 changeset.bytes_changed, trace_op); 3123 3123 if (free) 3124 3124 btrfs_qgroup_free_refroot(BTRFS_I(inode)->root->fs_info, 3125 - BTRFS_I(inode)->root->objectid, 3125 + BTRFS_I(inode)->root->root_key.objectid, 3126 3126 changeset.bytes_changed, BTRFS_QGROUP_RSV_DATA); 3127 3127 ret = changeset.bytes_changed; 3128 3128 out: ··· 3215 3215 int ret; 3216 3216 3217 3217 if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) || 3218 - !is_fstree(root->objectid) || num_bytes == 0) 3218 + !is_fstree(root->root_key.objectid) || num_bytes == 0) 3219 3219 return 0; 3220 3220 3221 3221 BUG_ON(num_bytes != round_down(num_bytes, fs_info->nodesize)); ··· 3240 3240 struct btrfs_fs_info *fs_info = root->fs_info; 3241 3241 3242 3242 if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) || 3243 - !is_fstree(root->objectid)) 3243 + !is_fstree(root->root_key.objectid)) 3244 3244 return; 3245 3245 3246 3246 /* TODO: Update trace point to handle such free */ 3247 3247 trace_qgroup_meta_free_all_pertrans(root); 3248 3248 /* Special value -1 means to free all reserved space */ 3249 - btrfs_qgroup_free_refroot(fs_info, root->objectid, (u64)-1, 3249 + btrfs_qgroup_free_refroot(fs_info, root->root_key.objectid, (u64)-1, 3250 3250 BTRFS_QGROUP_RSV_META_PERTRANS); 3251 3251 } 3252 3252 ··· 3256 3256 struct btrfs_fs_info *fs_info = root->fs_info; 3257 3257 3258 3258 if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) || 3259 - !is_fstree(root->objectid)) 3259 + !is_fstree(root->root_key.objectid)) 3260 3260 return; 3261 3261 3262 3262 /* ··· 3267 3267 num_bytes = sub_root_meta_rsv(root, num_bytes, type); 3268 3268 BUG_ON(num_bytes != round_down(num_bytes, fs_info->nodesize)); 3269 3269 trace_qgroup_meta_reserve(root, type, -(s64)num_bytes); 3270 - btrfs_qgroup_free_refroot(fs_info, root->objectid, num_bytes, type); 3270 + btrfs_qgroup_free_refroot(fs_info, root->root_key.objectid, 3271 + num_bytes, type); 3271 3272 } 3272 3273 3273 3274 static void qgroup_convert_meta(struct btrfs_fs_info *fs_info, u64 ref_root, ··· 3322 3321 struct btrfs_fs_info *fs_info = root->fs_info; 3323 3322 3324 3323 if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) || 3325 - !is_fstree(root->objectid)) 3324 + !is_fstree(root->root_key.objectid)) 3326 3325 return; 3327 3326 /* Same as btrfs_qgroup_free_meta_prealloc() */ 3328 3327 num_bytes = sub_root_meta_rsv(root, num_bytes, 3329 3328 BTRFS_QGROUP_RSV_META_PREALLOC); 3330 3329 trace_qgroup_meta_convert(root, num_bytes); 3331 - qgroup_convert_meta(fs_info, root->objectid, num_bytes); 3330 + qgroup_convert_meta(fs_info, root->root_key.objectid, num_bytes); 3332 3331 } 3333 3332 3334 3333 /* ··· 3355 3354 inode->i_ino, unode->val, unode->aux); 3356 3355 } 3357 3356 btrfs_qgroup_free_refroot(BTRFS_I(inode)->root->fs_info, 3358 - BTRFS_I(inode)->root->objectid, 3357 + BTRFS_I(inode)->root->root_key.objectid, 3359 3358 changeset.bytes_changed, BTRFS_QGROUP_RSV_DATA); 3360 3359 3361 3360 }
+4 -4
fs/btrfs/ref-verify.c
··· 732 732 733 733 INIT_LIST_HEAD(&ra->list); 734 734 ra->action = action; 735 - ra->root = root->objectid; 735 + ra->root = root->root_key.objectid; 736 736 737 737 /* 738 738 * This is an allocation, preallocate the block_entry in case we haven't ··· 787 787 * one we want to lookup below when we modify the 788 788 * re->num_refs. 789 789 */ 790 - ref_root = root->objectid; 791 - re->root_objectid = root->objectid; 790 + ref_root = root->root_key.objectid; 791 + re->root_objectid = root->root_key.objectid; 792 792 re->num_refs = 0; 793 793 } 794 794 ··· 862 862 * didn't thik of some other corner case. 863 863 */ 864 864 btrfs_err(fs_info, "failed to find root %llu for %llu", 865 - root->objectid, be->bytenr); 865 + root->root_key.objectid, be->bytenr); 866 866 dump_block_entry(fs_info, be); 867 867 dump_ref_action(fs_info, ra); 868 868 kfree(ra);
+2 -1
fs/btrfs/relocation.c
··· 884 884 cur->bytenr) { 885 885 btrfs_err(root->fs_info, 886 886 "couldn't find block (%llu) (level %d) in tree (%llu) with key (%llu %u %llu)", 887 - cur->bytenr, level - 1, root->objectid, 887 + cur->bytenr, level - 1, 888 + root->root_key.objectid, 888 889 node_key->objectid, node_key->type, 889 890 node_key->offset); 890 891 err = -ENOENT;
+8 -8
fs/btrfs/send.c
··· 1186 1186 u64 root = (u64)(uintptr_t)key; 1187 1187 struct clone_root *cr = (struct clone_root *)elt; 1188 1188 1189 - if (root < cr->root->objectid) 1189 + if (root < cr->root->root_key.objectid) 1190 1190 return -1; 1191 - if (root > cr->root->objectid) 1191 + if (root > cr->root->root_key.objectid) 1192 1192 return 1; 1193 1193 return 0; 1194 1194 } ··· 1198 1198 struct clone_root *cr1 = (struct clone_root *)e1; 1199 1199 struct clone_root *cr2 = (struct clone_root *)e2; 1200 1200 1201 - if (cr1->root->objectid < cr2->root->objectid) 1201 + if (cr1->root->root_key.objectid < cr2->root->root_key.objectid) 1202 1202 return -1; 1203 - if (cr1->root->objectid > cr2->root->objectid) 1203 + if (cr1->root->root_key.objectid > cr2->root->root_key.objectid) 1204 1204 return 1; 1205 1205 return 0; 1206 1206 } ··· 2346 2346 return -ENOMEM; 2347 2347 } 2348 2348 2349 - key.objectid = send_root->objectid; 2349 + key.objectid = send_root->root_key.objectid; 2350 2350 key.type = BTRFS_ROOT_BACKREF_KEY; 2351 2351 key.offset = 0; 2352 2352 ··· 2362 2362 leaf = path->nodes[0]; 2363 2363 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); 2364 2364 if (key.type != BTRFS_ROOT_BACKREF_KEY || 2365 - key.objectid != send_root->objectid) { 2365 + key.objectid != send_root->root_key.objectid) { 2366 2366 ret = -ENOENT; 2367 2367 goto out; 2368 2368 } ··· 4907 4907 4908 4908 btrfs_debug(sctx->send_root->fs_info, 4909 4909 "send_clone offset=%llu, len=%d, clone_root=%llu, clone_inode=%llu, clone_offset=%llu", 4910 - offset, len, clone_root->root->objectid, clone_root->ino, 4911 - clone_root->offset); 4910 + offset, len, clone_root->root->root_key.objectid, 4911 + clone_root->ino, clone_root->offset); 4912 4912 4913 4913 p = fs_path_alloc(); 4914 4914 if (!p)
+4 -2
fs/btrfs/super.c
··· 2177 2177 buf->f_fsid.val[0] = be32_to_cpu(fsid[0]) ^ be32_to_cpu(fsid[2]); 2178 2178 buf->f_fsid.val[1] = be32_to_cpu(fsid[1]) ^ be32_to_cpu(fsid[3]); 2179 2179 /* Mask in the root object ID too, to disambiguate subvols */ 2180 - buf->f_fsid.val[0] ^= BTRFS_I(d_inode(dentry))->root->objectid >> 32; 2181 - buf->f_fsid.val[1] ^= BTRFS_I(d_inode(dentry))->root->objectid; 2180 + buf->f_fsid.val[0] ^= 2181 + BTRFS_I(d_inode(dentry))->root->root_key.objectid >> 32; 2182 + buf->f_fsid.val[1] ^= 2183 + BTRFS_I(d_inode(dentry))->root->root_key.objectid; 2182 2184 2183 2185 return 0; 2184 2186 }
+2 -2
fs/btrfs/transaction.c
··· 118 118 list_del_init(&root->dirty_list); 119 119 free_extent_buffer(root->commit_root); 120 120 root->commit_root = btrfs_root_node(root); 121 - if (is_fstree(root->objectid)) 121 + if (is_fstree(root->root_key.objectid)) 122 122 btrfs_unpin_free_ino(root); 123 123 clear_btree_io_tree(&root->dirty_log_pages); 124 124 } ··· 2329 2329 list_del_init(&root->root_list); 2330 2330 spin_unlock(&fs_info->trans_lock); 2331 2331 2332 - btrfs_debug(fs_info, "cleaner removing %llu", root->objectid); 2332 + btrfs_debug(fs_info, "cleaner removing %llu", root->root_key.objectid); 2333 2333 2334 2334 btrfs_kill_all_delayed_nodes(root); 2335 2335
+8 -7
include/trace/events/btrfs.h
··· 316 316 ), 317 317 318 318 TP_fast_assign_btrfs(bi->root->fs_info, 319 - __entry->root_obj = bi->root->objectid; 319 + __entry->root_obj = bi->root->root_key.objectid; 320 320 __entry->ino = btrfs_ino(bi); 321 321 __entry->isize = bi->vfs_inode.i_size; 322 322 __entry->disk_isize = bi->disk_i_size; ··· 367 367 368 368 TP_fast_assign_btrfs( 369 369 bi->root->fs_info, 370 - __entry->root_obj = bi->root->objectid; 370 + __entry->root_obj = bi->root->root_key.objectid; 371 371 __entry->ino = btrfs_ino(bi); 372 372 __entry->isize = bi->vfs_inode.i_size; 373 373 __entry->disk_isize = bi->disk_i_size; ··· 1477 1477 ), 1478 1478 1479 1479 TP_fast_assign_btrfs(btrfs_sb(inode->i_sb), 1480 - __entry->rootid = BTRFS_I(inode)->root->objectid; 1480 + __entry->rootid = 1481 + BTRFS_I(inode)->root->root_key.objectid; 1481 1482 __entry->ino = btrfs_ino(BTRFS_I(inode)); 1482 1483 __entry->start = start; 1483 1484 __entry->len = len; ··· 1676 1675 ), 1677 1676 1678 1677 TP_fast_assign_btrfs(root->fs_info, 1679 - __entry->refroot = root->objectid; 1678 + __entry->refroot = root->root_key.objectid; 1680 1679 __entry->diff = diff; 1681 1680 ), 1682 1681 ··· 1698 1697 ), 1699 1698 1700 1699 TP_fast_assign_btrfs(root->fs_info, 1701 - __entry->refroot = root->objectid; 1700 + __entry->refroot = root->root_key.objectid; 1702 1701 __entry->diff = diff; 1703 1702 ), 1704 1703 ··· 1722 1721 ), 1723 1722 1724 1723 TP_fast_assign_btrfs(root->fs_info, 1725 - __entry->refroot = root->objectid; 1724 + __entry->refroot = root->root_key.objectid; 1726 1725 spin_lock(&root->qgroup_meta_rsv_lock); 1727 1726 __entry->diff = -(s64)root->qgroup_meta_rsv_pertrans; 1728 1727 spin_unlock(&root->qgroup_meta_rsv_lock); ··· 1803 1802 ), 1804 1803 1805 1804 TP_fast_assign_btrfs(root->fs_info, 1806 - __entry->root_objectid = root->objectid; 1805 + __entry->root_objectid = root->root_key.objectid; 1807 1806 __entry->ino = ino; 1808 1807 __entry->mod = mod; 1809 1808 ),