Commit efc7d5db authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba

btrfs: stop referencing btrfs_delayed_tree_ref directly

We only ever need to use this to get the level of the tree block ref, so
use the btrfs_delayed_ref_owner() helper, which returns the level for
the given reference.
Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 44cc2e38
...@@ -919,28 +919,29 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info, ...@@ -919,28 +919,29 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info,
switch (node->type) { switch (node->type) {
case BTRFS_TREE_BLOCK_REF_KEY: { case BTRFS_TREE_BLOCK_REF_KEY: {
/* NORMAL INDIRECT METADATA backref */ /* NORMAL INDIRECT METADATA backref */
struct btrfs_delayed_tree_ref *ref;
struct btrfs_key *key_ptr = NULL; struct btrfs_key *key_ptr = NULL;
/* The owner of a tree block ref is the level. */
int level = btrfs_delayed_ref_owner(node);
if (head->extent_op && head->extent_op->update_key) { if (head->extent_op && head->extent_op->update_key) {
btrfs_disk_key_to_cpu(&key, &head->extent_op->key); btrfs_disk_key_to_cpu(&key, &head->extent_op->key);
key_ptr = &key; key_ptr = &key;
} }
ref = btrfs_delayed_node_to_tree_ref(node);
ret = add_indirect_ref(fs_info, preftrees, node->ref_root, ret = add_indirect_ref(fs_info, preftrees, node->ref_root,
key_ptr, ref->level + 1, key_ptr, level + 1, node->bytenr,
node->bytenr, count, sc, count, sc, GFP_ATOMIC);
GFP_ATOMIC);
break; break;
} }
case BTRFS_SHARED_BLOCK_REF_KEY: { case BTRFS_SHARED_BLOCK_REF_KEY: {
/* SHARED DIRECT METADATA backref */ /*
struct btrfs_delayed_tree_ref *ref; * SHARED DIRECT METADATA backref
*
ref = btrfs_delayed_node_to_tree_ref(node); * The owner of a tree block ref is the level.
*/
int level = btrfs_delayed_ref_owner(node);
ret = add_direct_ref(fs_info, preftrees, ref->level + 1, ret = add_direct_ref(fs_info, preftrees, level + 1,
node->parent, node->bytenr, count, node->parent, node->bytenr, count,
sc, GFP_ATOMIC); sc, GFP_ATOMIC);
break; break;
......
...@@ -4865,16 +4865,16 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans, ...@@ -4865,16 +4865,16 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
struct btrfs_extent_inline_ref *iref; struct btrfs_extent_inline_ref *iref;
struct btrfs_path *path; struct btrfs_path *path;
struct extent_buffer *leaf; struct extent_buffer *leaf;
struct btrfs_delayed_tree_ref *ref;
u32 size = sizeof(*extent_item) + sizeof(*iref); u32 size = sizeof(*extent_item) + sizeof(*iref);
u64 flags = extent_op->flags_to_set; u64 flags = extent_op->flags_to_set;
/* The owner of a tree block is the level. */
int level = btrfs_delayed_ref_owner(node);
bool skinny_metadata = btrfs_fs_incompat(fs_info, SKINNY_METADATA); bool skinny_metadata = btrfs_fs_incompat(fs_info, SKINNY_METADATA);
ref = btrfs_delayed_node_to_tree_ref(node);
extent_key.objectid = node->bytenr; extent_key.objectid = node->bytenr;
if (skinny_metadata) { if (skinny_metadata) {
extent_key.offset = ref->level; /* The owner of a tree block is the level. */
extent_key.offset = level;
extent_key.type = BTRFS_METADATA_ITEM_KEY; extent_key.type = BTRFS_METADATA_ITEM_KEY;
} else { } else {
extent_key.offset = node->num_bytes; extent_key.offset = node->num_bytes;
...@@ -4907,7 +4907,7 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans, ...@@ -4907,7 +4907,7 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
} else { } else {
block_info = (struct btrfs_tree_block_info *)(extent_item + 1); block_info = (struct btrfs_tree_block_info *)(extent_item + 1);
btrfs_set_tree_block_key(leaf, block_info, &extent_op->key); btrfs_set_tree_block_key(leaf, block_info, &extent_op->key);
btrfs_set_tree_block_level(leaf, block_info, ref->level); btrfs_set_tree_block_level(leaf, block_info, level);
iref = (struct btrfs_extent_inline_ref *)(block_info + 1); iref = (struct btrfs_extent_inline_ref *)(block_info + 1);
} }
......
...@@ -16,7 +16,6 @@ struct extent_map; ...@@ -16,7 +16,6 @@ struct extent_map;
struct btrfs_file_extent_item; struct btrfs_file_extent_item;
struct btrfs_ordered_extent; struct btrfs_ordered_extent;
struct btrfs_delayed_ref_node; struct btrfs_delayed_ref_node;
struct btrfs_delayed_tree_ref;
struct btrfs_delayed_ref_head; struct btrfs_delayed_ref_head;
struct btrfs_block_group; struct btrfs_block_group;
struct btrfs_free_cluster; struct btrfs_free_cluster;
......
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