Commit 20fb05a6 authored by Filipe Manana's avatar Filipe Manana Committed by David Sterba

btrfs: use a single variable for return value at run_delayed_extent_op()

Instead of using a 'ret' and an 'err' variable at run_delayed_extent_op()
for tracking the return value, use a single one ('ret'). This simplifies
the code, makes it comply with most of the existing code and it's less
prone for logic errors as time has proven over and over in the btrfs code.
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent e721043a
...@@ -1602,7 +1602,6 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans, ...@@ -1602,7 +1602,6 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans,
struct extent_buffer *leaf; struct extent_buffer *leaf;
u32 item_size; u32 item_size;
int ret; int ret;
int err = 0;
int metadata = 1; int metadata = 1;
if (TRANS_ABORTED(trans)) if (TRANS_ABORTED(trans))
...@@ -1629,10 +1628,8 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans, ...@@ -1629,10 +1628,8 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans,
again: again:
ret = btrfs_search_slot(trans, root, &key, path, 0, 1); ret = btrfs_search_slot(trans, root, &key, path, 0, 1);
if (ret < 0) { if (ret < 0) {
err = ret;
goto out; goto out;
} } else if (ret > 0) {
if (ret > 0) {
if (metadata) { if (metadata) {
if (path->slots[0] > 0) { if (path->slots[0] > 0) {
path->slots[0]--; path->slots[0]--;
...@@ -1653,7 +1650,7 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans, ...@@ -1653,7 +1650,7 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans,
goto again; goto again;
} }
} else { } else {
err = -EUCLEAN; ret = -EUCLEAN;
btrfs_err(fs_info, btrfs_err(fs_info,
"missing extent item for extent %llu num_bytes %llu level %d", "missing extent item for extent %llu num_bytes %llu level %d",
head->bytenr, head->num_bytes, extent_op->level); head->bytenr, head->num_bytes, extent_op->level);
...@@ -1665,11 +1662,11 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans, ...@@ -1665,11 +1662,11 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans,
item_size = btrfs_item_size(leaf, path->slots[0]); item_size = btrfs_item_size(leaf, path->slots[0]);
if (unlikely(item_size < sizeof(*ei))) { if (unlikely(item_size < sizeof(*ei))) {
err = -EUCLEAN; ret = -EUCLEAN;
btrfs_err(fs_info, btrfs_err(fs_info,
"unexpected extent item size, has %u expect >= %zu", "unexpected extent item size, has %u expect >= %zu",
item_size, sizeof(*ei)); item_size, sizeof(*ei));
btrfs_abort_transaction(trans, err); btrfs_abort_transaction(trans, ret);
goto out; goto out;
} }
...@@ -1679,7 +1676,7 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans, ...@@ -1679,7 +1676,7 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans,
btrfs_mark_buffer_dirty(leaf); btrfs_mark_buffer_dirty(leaf);
out: out:
btrfs_free_path(path); btrfs_free_path(path);
return err; return ret;
} }
static int run_delayed_tree_ref(struct btrfs_trans_handle *trans, static int run_delayed_tree_ref(struct btrfs_trans_handle *trans,
......
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