Commit 01747e92 authored by Edmund Nadolski's avatar Edmund Nadolski Committed by David Sterba

btrfs: clean up extraneous computations in add_delayed_refs

Repeating the same computation in multiple places is not
necessary.
Signed-off-by: default avatarEdmund Nadolski <enadolski@suse.com>
Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 3ec4d323
...@@ -769,7 +769,7 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info, ...@@ -769,7 +769,7 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info,
struct btrfs_key key; struct btrfs_key key;
struct btrfs_key tmp_op_key; struct btrfs_key tmp_op_key;
struct btrfs_key *op_key = NULL; struct btrfs_key *op_key = NULL;
int sgn; int count;
int ret = 0; int ret = 0;
if (extent_op && extent_op->update_key) { if (extent_op && extent_op->update_key) {
...@@ -788,15 +788,15 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info, ...@@ -788,15 +788,15 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info,
WARN_ON(1); WARN_ON(1);
continue; continue;
case BTRFS_ADD_DELAYED_REF: case BTRFS_ADD_DELAYED_REF:
sgn = 1; count = node->ref_mod;
break; break;
case BTRFS_DROP_DELAYED_REF: case BTRFS_DROP_DELAYED_REF:
sgn = -1; count = node->ref_mod * -1;
break; break;
default: default:
BUG_ON(1); BUG_ON(1);
} }
*total_refs += (node->ref_mod * sgn); *total_refs += count;
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 */
...@@ -805,9 +805,8 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info, ...@@ -805,9 +805,8 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info,
ref = btrfs_delayed_node_to_tree_ref(node); ref = btrfs_delayed_node_to_tree_ref(node);
ret = add_indirect_ref(fs_info, preftrees, ref->root, ret = add_indirect_ref(fs_info, preftrees, ref->root,
&tmp_op_key, ref->level + 1, &tmp_op_key, ref->level + 1,
node->bytenr, node->bytenr, count, sc,
node->ref_mod * sgn, GFP_ATOMIC);
sc, GFP_ATOMIC);
break; break;
} }
case BTRFS_SHARED_BLOCK_REF_KEY: { case BTRFS_SHARED_BLOCK_REF_KEY: {
...@@ -816,9 +815,8 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info, ...@@ -816,9 +815,8 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info,
ref = btrfs_delayed_node_to_tree_ref(node); ref = btrfs_delayed_node_to_tree_ref(node);
ret = add_direct_ref(fs_info, preftrees, ret = add_direct_ref(fs_info, preftrees, ref->level + 1,
ref->level + 1, ref->parent, ref->parent, node->bytenr, count,
node->bytenr, node->ref_mod * sgn,
sc, GFP_ATOMIC); sc, GFP_ATOMIC);
break; break;
} }
...@@ -841,9 +839,8 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info, ...@@ -841,9 +839,8 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info,
} }
ret = add_indirect_ref(fs_info, preftrees, ref->root, ret = add_indirect_ref(fs_info, preftrees, ref->root,
&key, 0, node->bytenr, &key, 0, node->bytenr, count, sc,
node->ref_mod * sgn, GFP_ATOMIC);
sc, GFP_ATOMIC);
break; break;
} }
case BTRFS_SHARED_DATA_REF_KEY: { case BTRFS_SHARED_DATA_REF_KEY: {
...@@ -852,10 +849,9 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info, ...@@ -852,10 +849,9 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info,
ref = btrfs_delayed_node_to_data_ref(node); ref = btrfs_delayed_node_to_data_ref(node);
ret = add_direct_ref(fs_info, preftrees, 0, ret = add_direct_ref(fs_info, preftrees, 0, ref->parent,
ref->parent, node->bytenr, node->bytenr, count, sc,
node->ref_mod * sgn, GFP_ATOMIC);
sc, GFP_ATOMIC);
break; break;
} }
default: default:
......
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