Commit 113479d5 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: rename root fields in delayed refs structs

Both data and metadata delayed ref structures have fields named
root/ref_root respectively. Those are somewhat cryptic and don't really
convey the real meaning. In fact those roots are really the original
owners of the respective block (i.e in case of a snapshot a data delayed
ref will contain the original root that owns the given block). Rename
those fields accordingly and adjust comments.
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 0e24f6d8
...@@ -922,7 +922,7 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans, ...@@ -922,7 +922,7 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans,
if (test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) && if (test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) &&
is_fstree(generic_ref->real_root) && is_fstree(generic_ref->real_root) &&
is_fstree(generic_ref->tree_ref.root) && is_fstree(generic_ref->tree_ref.owning_root) &&
!generic_ref->skip_qgroup) { !generic_ref->skip_qgroup) {
record = kzalloc(sizeof(*record), GFP_NOFS); record = kzalloc(sizeof(*record), GFP_NOFS);
if (!record) { if (!record) {
...@@ -938,14 +938,15 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans, ...@@ -938,14 +938,15 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans,
ref_type = BTRFS_TREE_BLOCK_REF_KEY; ref_type = BTRFS_TREE_BLOCK_REF_KEY;
init_delayed_ref_common(fs_info, &ref->node, bytenr, num_bytes, init_delayed_ref_common(fs_info, &ref->node, bytenr, num_bytes,
generic_ref->tree_ref.root, action, ref_type); generic_ref->tree_ref.owning_root, action,
ref->root = generic_ref->tree_ref.root; ref_type);
ref->root = generic_ref->tree_ref.owning_root;
ref->parent = parent; ref->parent = parent;
ref->level = level; ref->level = level;
init_delayed_ref_head(head_ref, record, bytenr, num_bytes, init_delayed_ref_head(head_ref, record, bytenr, num_bytes,
generic_ref->tree_ref.root, 0, action, false, generic_ref->tree_ref.owning_root, 0, action,
is_system); false, is_system);
head_ref->extent_op = extent_op; head_ref->extent_op = extent_op;
delayed_refs = &trans->transaction->delayed_refs; delayed_refs = &trans->transaction->delayed_refs;
...@@ -997,7 +998,7 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans, ...@@ -997,7 +998,7 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans,
u64 bytenr = generic_ref->bytenr; u64 bytenr = generic_ref->bytenr;
u64 num_bytes = generic_ref->len; u64 num_bytes = generic_ref->len;
u64 parent = generic_ref->parent; u64 parent = generic_ref->parent;
u64 ref_root = generic_ref->data_ref.ref_root; u64 ref_root = generic_ref->data_ref.owning_root;
u64 owner = generic_ref->data_ref.ino; u64 owner = generic_ref->data_ref.ino;
u64 offset = generic_ref->data_ref.offset; u64 offset = generic_ref->data_ref.offset;
u8 ref_type; u8 ref_type;
......
...@@ -186,8 +186,8 @@ enum btrfs_ref_type { ...@@ -186,8 +186,8 @@ enum btrfs_ref_type {
struct btrfs_data_ref { struct btrfs_data_ref {
/* For EXTENT_DATA_REF */ /* For EXTENT_DATA_REF */
/* Root which refers to this data extent */ /* Original root this data extent belongs to */
u64 ref_root; u64 owning_root;
/* Inode which refers to this data extent */ /* Inode which refers to this data extent */
u64 ino; u64 ino;
...@@ -210,11 +210,11 @@ struct btrfs_tree_ref { ...@@ -210,11 +210,11 @@ struct btrfs_tree_ref {
int level; int level;
/* /*
* Root which refers to this tree block. * Root which owns this tree block.
* *
* For TREE_BLOCK_REF (skinny metadata, either inline or keyed) * For TREE_BLOCK_REF (skinny metadata, either inline or keyed)
*/ */
u64 root; u64 owning_root;
/* For non-skinny metadata, no special member needed */ /* For non-skinny metadata, no special member needed */
}; };
...@@ -277,7 +277,7 @@ static inline void btrfs_init_tree_ref(struct btrfs_ref *generic_ref, ...@@ -277,7 +277,7 @@ static inline void btrfs_init_tree_ref(struct btrfs_ref *generic_ref,
if (!generic_ref->real_root) if (!generic_ref->real_root)
generic_ref->real_root = root; generic_ref->real_root = root;
generic_ref->tree_ref.level = level; generic_ref->tree_ref.level = level;
generic_ref->tree_ref.root = root; generic_ref->tree_ref.owning_root = root;
generic_ref->type = BTRFS_REF_METADATA; generic_ref->type = BTRFS_REF_METADATA;
} }
...@@ -287,7 +287,7 @@ static inline void btrfs_init_data_ref(struct btrfs_ref *generic_ref, ...@@ -287,7 +287,7 @@ static inline void btrfs_init_data_ref(struct btrfs_ref *generic_ref,
/* If @real_root not set, use @root as fallback */ /* If @real_root not set, use @root as fallback */
if (!generic_ref->real_root) if (!generic_ref->real_root)
generic_ref->real_root = ref_root; generic_ref->real_root = ref_root;
generic_ref->data_ref.ref_root = ref_root; generic_ref->data_ref.owning_root = ref_root;
generic_ref->data_ref.ino = ino; generic_ref->data_ref.ino = ino;
generic_ref->data_ref.offset = offset; generic_ref->data_ref.offset = offset;
generic_ref->type = BTRFS_REF_DATA; generic_ref->type = BTRFS_REF_DATA;
......
...@@ -1396,7 +1396,7 @@ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, ...@@ -1396,7 +1396,7 @@ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
ASSERT(generic_ref->type != BTRFS_REF_NOT_SET && ASSERT(generic_ref->type != BTRFS_REF_NOT_SET &&
generic_ref->action); generic_ref->action);
BUG_ON(generic_ref->type == BTRFS_REF_METADATA && BUG_ON(generic_ref->type == BTRFS_REF_METADATA &&
generic_ref->tree_ref.root == BTRFS_TREE_LOG_OBJECTID); generic_ref->tree_ref.owning_root == BTRFS_TREE_LOG_OBJECTID);
if (generic_ref->type == BTRFS_REF_METADATA) if (generic_ref->type == BTRFS_REF_METADATA)
ret = btrfs_add_delayed_tree_ref(trans, generic_ref, NULL); ret = btrfs_add_delayed_tree_ref(trans, generic_ref, NULL);
...@@ -3372,9 +3372,9 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_ref *ref) ...@@ -3372,9 +3372,9 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_ref *ref)
* tree, just update pinning info and exit early. * tree, just update pinning info and exit early.
*/ */
if ((ref->type == BTRFS_REF_METADATA && if ((ref->type == BTRFS_REF_METADATA &&
ref->tree_ref.root == BTRFS_TREE_LOG_OBJECTID) || ref->tree_ref.owning_root == BTRFS_TREE_LOG_OBJECTID) ||
(ref->type == BTRFS_REF_DATA && (ref->type == BTRFS_REF_DATA &&
ref->data_ref.ref_root == BTRFS_TREE_LOG_OBJECTID)) { ref->data_ref.owning_root == BTRFS_TREE_LOG_OBJECTID)) {
/* unlocks the pinned mutex */ /* unlocks the pinned mutex */
btrfs_pin_extent(trans, ref->bytenr, ref->len, 1); btrfs_pin_extent(trans, ref->bytenr, ref->len, 1);
ret = 0; ret = 0;
...@@ -3385,9 +3385,9 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_ref *ref) ...@@ -3385,9 +3385,9 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_ref *ref)
} }
if (!((ref->type == BTRFS_REF_METADATA && if (!((ref->type == BTRFS_REF_METADATA &&
ref->tree_ref.root == BTRFS_TREE_LOG_OBJECTID) || ref->tree_ref.owning_root == BTRFS_TREE_LOG_OBJECTID) ||
(ref->type == BTRFS_REF_DATA && (ref->type == BTRFS_REF_DATA &&
ref->data_ref.ref_root == BTRFS_TREE_LOG_OBJECTID))) ref->data_ref.owning_root == BTRFS_TREE_LOG_OBJECTID)))
btrfs_ref_tree_mod(fs_info, ref); btrfs_ref_tree_mod(fs_info, ref);
return ret; return ret;
......
...@@ -678,10 +678,10 @@ int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info, ...@@ -678,10 +678,10 @@ int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info,
if (generic_ref->type == BTRFS_REF_METADATA) { if (generic_ref->type == BTRFS_REF_METADATA) {
if (!parent) if (!parent)
ref_root = generic_ref->tree_ref.root; ref_root = generic_ref->tree_ref.owning_root;
owner = generic_ref->tree_ref.level; owner = generic_ref->tree_ref.level;
} else if (!parent) { } else if (!parent) {
ref_root = generic_ref->data_ref.ref_root; ref_root = generic_ref->data_ref.owning_root;
owner = generic_ref->data_ref.ino; owner = generic_ref->data_ref.ino;
offset = generic_ref->data_ref.offset; offset = generic_ref->data_ref.offset;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment