Commit d4b20733 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: Streamline shared ref check in alloc_reserved_tree_block

Instead of setting "parent" to ref->parent only when dealing with
a shared ref and subsequently performing another check to see
if (parent > 0), check the "node->type" directly and act accordingly.
This makes the code more streamline. No functional changes.
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 21ebfbe7
...@@ -8143,17 +8143,11 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans, ...@@ -8143,17 +8143,11 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
struct btrfs_delayed_tree_ref *ref; struct btrfs_delayed_tree_ref *ref;
u32 size = sizeof(*extent_item) + sizeof(*iref); u32 size = sizeof(*extent_item) + sizeof(*iref);
u64 num_bytes; u64 num_bytes;
u64 parent;
u64 flags = extent_op->flags_to_set; u64 flags = extent_op->flags_to_set;
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); ref = btrfs_delayed_node_to_tree_ref(node);
if (node->type == BTRFS_SHARED_BLOCK_REF_KEY)
parent = ref->parent;
else
parent = 0;
extent_key.objectid = node->bytenr; extent_key.objectid = node->bytenr;
if (skinny_metadata) { if (skinny_metadata) {
extent_key.offset = ref->level; extent_key.offset = ref->level;
...@@ -8202,11 +8196,11 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans, ...@@ -8202,11 +8196,11 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
iref = (struct btrfs_extent_inline_ref *)(block_info + 1); iref = (struct btrfs_extent_inline_ref *)(block_info + 1);
} }
if (parent > 0) { if (node->type == BTRFS_SHARED_BLOCK_REF_KEY) {
BUG_ON(!(flags & BTRFS_BLOCK_FLAG_FULL_BACKREF)); BUG_ON(!(flags & BTRFS_BLOCK_FLAG_FULL_BACKREF));
btrfs_set_extent_inline_ref_type(leaf, iref, btrfs_set_extent_inline_ref_type(leaf, iref,
BTRFS_SHARED_BLOCK_REF_KEY); BTRFS_SHARED_BLOCK_REF_KEY);
btrfs_set_extent_inline_ref_offset(leaf, iref, parent); btrfs_set_extent_inline_ref_offset(leaf, iref, ref->parent);
} else { } else {
btrfs_set_extent_inline_ref_type(leaf, iref, btrfs_set_extent_inline_ref_type(leaf, iref,
BTRFS_TREE_BLOCK_REF_KEY); BTRFS_TREE_BLOCK_REF_KEY);
......
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