Skip to content

Commit 6d347e7

Browse files
asjkdave
authored andcommitted
btrfs: rename err to ret in btrfs_drop_snapshot()
Drop the variable 'err', reuse the variable 'ret' by reinitializing it to zero where necessary. Signed-off-by: Anand Jain <anand.jain@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 2c924db commit 6d347e7

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

fs/btrfs/extent-tree.c

+26-25
Original file line numberDiff line numberDiff line change
@@ -5834,8 +5834,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
58345834
struct walk_control *wc;
58355835
struct btrfs_key key;
58365836
const u64 rootid = btrfs_root_id(root);
5837-
int err = 0;
5838-
int ret;
5837+
int ret = 0;
58395838
int level;
58405839
bool root_dropped = false;
58415840
bool unfinished_drop = false;
@@ -5844,14 +5843,14 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
58445843

58455844
path = btrfs_alloc_path();
58465845
if (!path) {
5847-
err = -ENOMEM;
5846+
ret = -ENOMEM;
58485847
goto out;
58495848
}
58505849

58515850
wc = kzalloc(sizeof(*wc), GFP_NOFS);
58525851
if (!wc) {
58535852
btrfs_free_path(path);
5854-
err = -ENOMEM;
5853+
ret = -ENOMEM;
58555854
goto out;
58565855
}
58575856

@@ -5864,12 +5863,12 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
58645863
else
58655864
trans = btrfs_start_transaction(tree_root, 0);
58665865
if (IS_ERR(trans)) {
5867-
err = PTR_ERR(trans);
5866+
ret = PTR_ERR(trans);
58685867
goto out_free;
58695868
}
58705869

5871-
err = btrfs_run_delayed_items(trans);
5872-
if (err)
5870+
ret = btrfs_run_delayed_items(trans);
5871+
if (ret)
58735872
goto out_end_trans;
58745873

58755874
/*
@@ -5900,11 +5899,11 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
59005899
path->lowest_level = level;
59015900
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
59025901
path->lowest_level = 0;
5903-
if (ret < 0) {
5904-
err = ret;
5902+
if (ret < 0)
59055903
goto out_end_trans;
5906-
}
5904+
59075905
WARN_ON(ret > 0);
5906+
ret = 0;
59085907

59095908
/*
59105909
* unlock our path, this is safe because only this
@@ -5917,14 +5916,17 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
59175916
btrfs_tree_lock(path->nodes[level]);
59185917
path->locks[level] = BTRFS_WRITE_LOCK;
59195918

5919+
/*
5920+
* btrfs_lookup_extent_info() returns 0 for success,
5921+
* or < 0 for error.
5922+
*/
59205923
ret = btrfs_lookup_extent_info(trans, fs_info,
59215924
path->nodes[level]->start,
59225925
level, 1, &wc->refs[level],
59235926
&wc->flags[level], NULL);
5924-
if (ret < 0) {
5925-
err = ret;
5927+
if (ret < 0)
59265928
goto out_end_trans;
5927-
}
5929+
59285930
BUG_ON(wc->refs[level] == 0);
59295931

59305932
if (level == btrfs_root_drop_level(root_item))
@@ -5950,19 +5952,18 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
59505952
ret = walk_down_tree(trans, root, path, wc);
59515953
if (ret < 0) {
59525954
btrfs_abort_transaction(trans, ret);
5953-
err = ret;
59545955
break;
59555956
}
59565957

59575958
ret = walk_up_tree(trans, root, path, wc, BTRFS_MAX_LEVEL);
59585959
if (ret < 0) {
59595960
btrfs_abort_transaction(trans, ret);
5960-
err = ret;
59615961
break;
59625962
}
59635963

59645964
if (ret > 0) {
59655965
BUG_ON(wc->stage != DROP_REFERENCE);
5966+
ret = 0;
59665967
break;
59675968
}
59685969

@@ -5984,7 +5985,6 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
59845985
root_item);
59855986
if (ret) {
59865987
btrfs_abort_transaction(trans, ret);
5987-
err = ret;
59885988
goto out_end_trans;
59895989
}
59905990

@@ -5995,7 +5995,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
59955995
if (!for_reloc && btrfs_need_cleaner_sleep(fs_info)) {
59965996
btrfs_debug(fs_info,
59975997
"drop snapshot early exit");
5998-
err = -EAGAIN;
5998+
ret = -EAGAIN;
59995999
goto out_free;
60006000
}
60016001

@@ -6009,19 +6009,18 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
60096009
else
60106010
trans = btrfs_start_transaction(tree_root, 0);
60116011
if (IS_ERR(trans)) {
6012-
err = PTR_ERR(trans);
6012+
ret = PTR_ERR(trans);
60136013
goto out_free;
60146014
}
60156015
}
60166016
}
60176017
btrfs_release_path(path);
6018-
if (err)
6018+
if (ret)
60196019
goto out_end_trans;
60206020

60216021
ret = btrfs_del_root(trans, &root->root_key);
60226022
if (ret) {
60236023
btrfs_abort_transaction(trans, ret);
6024-
err = ret;
60256024
goto out_end_trans;
60266025
}
60276026

@@ -6030,10 +6029,11 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
60306029
NULL, NULL);
60316030
if (ret < 0) {
60326031
btrfs_abort_transaction(trans, ret);
6033-
err = ret;
60346032
goto out_end_trans;
60356033
} else if (ret > 0) {
6036-
/* if we fail to delete the orphan item this time
6034+
ret = 0;
6035+
/*
6036+
* If we fail to delete the orphan item this time
60376037
* around, it'll get picked up the next time.
60386038
*
60396039
* The most common failure here is just -ENOENT.
@@ -6064,18 +6064,19 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
60646064
kfree(wc);
60656065
btrfs_free_path(path);
60666066
out:
6067-
if (!err && root_dropped) {
6067+
if (!ret && root_dropped) {
60686068
ret = btrfs_qgroup_cleanup_dropped_subvolume(fs_info, rootid);
60696069
if (ret < 0)
60706070
btrfs_warn_rl(fs_info,
60716071
"failed to cleanup qgroup 0/%llu: %d",
60726072
rootid, ret);
6073+
ret = 0;
60736074
}
60746075
/*
60756076
* We were an unfinished drop root, check to see if there are any
60766077
* pending, and if not clear and wake up any waiters.
60776078
*/
6078-
if (!err && unfinished_drop)
6079+
if (!ret && unfinished_drop)
60796080
btrfs_maybe_wake_unfinished_drop(fs_info);
60806081

60816082
/*
@@ -6087,7 +6088,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref, int for_reloc)
60876088
*/
60886089
if (!for_reloc && !root_dropped)
60896090
btrfs_add_dead_root(root);
6090-
return err;
6091+
return ret;
60916092
}
60926093

60936094
/*

0 commit comments

Comments
 (0)