mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-08 14:23:19 +00:00
btrfs: simplify error handling at btrfs_del_root_ref()
At btrfs_del_root_ref() we are using two return variables, named 'ret' and 'err'. This makes it harder to follow and easier to return the wrong value in case an error happens - the previous patch in the series, which has the subject "btrfs: fix silent failure when deleting root reference", fixed a bug due to confusion created by these two variables. So change the function to use a single variable for tracking the return value of the function, using only 'ret', which is consistent with most of the codebase. Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
48ff70830b
commit
1fdbd03d3d
@ -337,7 +337,6 @@ int btrfs_del_root_ref(struct btrfs_trans_handle *trans, u64 root_id,
|
|||||||
struct extent_buffer *leaf;
|
struct extent_buffer *leaf;
|
||||||
struct btrfs_key key;
|
struct btrfs_key key;
|
||||||
unsigned long ptr;
|
unsigned long ptr;
|
||||||
int err = 0;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
path = btrfs_alloc_path();
|
path = btrfs_alloc_path();
|
||||||
@ -350,7 +349,6 @@ int btrfs_del_root_ref(struct btrfs_trans_handle *trans, u64 root_id,
|
|||||||
again:
|
again:
|
||||||
ret = btrfs_search_slot(trans, tree_root, &key, path, -1, 1);
|
ret = btrfs_search_slot(trans, tree_root, &key, path, -1, 1);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
err = ret;
|
|
||||||
goto out;
|
goto out;
|
||||||
} else if (ret == 0) {
|
} else if (ret == 0) {
|
||||||
leaf = path->nodes[0];
|
leaf = path->nodes[0];
|
||||||
@ -360,18 +358,18 @@ int btrfs_del_root_ref(struct btrfs_trans_handle *trans, u64 root_id,
|
|||||||
if ((btrfs_root_ref_dirid(leaf, ref) != dirid) ||
|
if ((btrfs_root_ref_dirid(leaf, ref) != dirid) ||
|
||||||
(btrfs_root_ref_name_len(leaf, ref) != name_len) ||
|
(btrfs_root_ref_name_len(leaf, ref) != name_len) ||
|
||||||
memcmp_extent_buffer(leaf, name, ptr, name_len)) {
|
memcmp_extent_buffer(leaf, name, ptr, name_len)) {
|
||||||
err = -ENOENT;
|
ret = -ENOENT;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
*sequence = btrfs_root_ref_sequence(leaf, ref);
|
*sequence = btrfs_root_ref_sequence(leaf, ref);
|
||||||
|
|
||||||
ret = btrfs_del_item(trans, tree_root, path);
|
ret = btrfs_del_item(trans, tree_root, path);
|
||||||
if (ret) {
|
if (ret)
|
||||||
err = ret;
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
} else {
|
||||||
} else
|
ret = -ENOENT;
|
||||||
err = -ENOENT;
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
if (key.type == BTRFS_ROOT_BACKREF_KEY) {
|
if (key.type == BTRFS_ROOT_BACKREF_KEY) {
|
||||||
btrfs_release_path(path);
|
btrfs_release_path(path);
|
||||||
@ -383,7 +381,7 @@ int btrfs_del_root_ref(struct btrfs_trans_handle *trans, u64 root_id,
|
|||||||
|
|
||||||
out:
|
out:
|
||||||
btrfs_free_path(path);
|
btrfs_free_path(path);
|
||||||
return err;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user