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>
This commit is contained in:

committed by
David Sterba

parent
5a2cb25ab9
commit
4fd786e6c3
@@ -1186,9 +1186,9 @@ static int __clone_root_cmp_bsearch(const void *key, const void *elt)
|
||||
u64 root = (u64)(uintptr_t)key;
|
||||
struct clone_root *cr = (struct clone_root *)elt;
|
||||
|
||||
if (root < cr->root->objectid)
|
||||
if (root < cr->root->root_key.objectid)
|
||||
return -1;
|
||||
if (root > cr->root->objectid)
|
||||
if (root > cr->root->root_key.objectid)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -1198,9 +1198,9 @@ static int __clone_root_cmp_sort(const void *e1, const void *e2)
|
||||
struct clone_root *cr1 = (struct clone_root *)e1;
|
||||
struct clone_root *cr2 = (struct clone_root *)e2;
|
||||
|
||||
if (cr1->root->objectid < cr2->root->objectid)
|
||||
if (cr1->root->root_key.objectid < cr2->root->root_key.objectid)
|
||||
return -1;
|
||||
if (cr1->root->objectid > cr2->root->objectid)
|
||||
if (cr1->root->root_key.objectid > cr2->root->root_key.objectid)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
@@ -2346,7 +2346,7 @@ static int send_subvol_begin(struct send_ctx *sctx)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
key.objectid = send_root->objectid;
|
||||
key.objectid = send_root->root_key.objectid;
|
||||
key.type = BTRFS_ROOT_BACKREF_KEY;
|
||||
key.offset = 0;
|
||||
|
||||
@@ -2362,7 +2362,7 @@ static int send_subvol_begin(struct send_ctx *sctx)
|
||||
leaf = path->nodes[0];
|
||||
btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
|
||||
if (key.type != BTRFS_ROOT_BACKREF_KEY ||
|
||||
key.objectid != send_root->objectid) {
|
||||
key.objectid != send_root->root_key.objectid) {
|
||||
ret = -ENOENT;
|
||||
goto out;
|
||||
}
|
||||
@@ -4907,8 +4907,8 @@ static int send_clone(struct send_ctx *sctx,
|
||||
|
||||
btrfs_debug(sctx->send_root->fs_info,
|
||||
"send_clone offset=%llu, len=%d, clone_root=%llu, clone_inode=%llu, clone_offset=%llu",
|
||||
offset, len, clone_root->root->objectid, clone_root->ino,
|
||||
clone_root->offset);
|
||||
offset, len, clone_root->root->root_key.objectid,
|
||||
clone_root->ino, clone_root->offset);
|
||||
|
||||
p = fs_path_alloc();
|
||||
if (!p)
|
||||
|
Reference in New Issue
Block a user