Btrfs: remove level==0 check in balance_level
PATCH 1/1 Btrfs: remove level==0 check in balance_level
btrfs_search_slot()
if (level != 0)
setup_nodes_for_search()
balance_level()
It is just impossible to have level=0 in balance_level.
--- fs/btrfs/ctree.c | 3 --- 1 file changed, 3 deletions(-)
fs/btrfs/ctree.c +0 -3
@@ -1778,9 +1778,6 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,int orig_slot = path->slots[level];u64 orig_ptr; -if (level ==0 ) -return 0 ; - mid = path->nodes[level]; WARN_ON(path->locks[level] != BTRFS_WRITE_LOCK &&
Signature · 1 line
1.8.3.1
Quoted 8 lines · Liu Bo
btrfs_search_slot()
if (level != 0)
setup_nodes_for_search()
balance_level()It is just impossible to have level=0 in
balance_level.Signed-off-by Liu Bo <[email protected]>
I concur with the analysis:
Quoted 19 lines
--- fs/btrfs/ctree.c | 3 --- 1 file changed, 3 deletions(-)fs/btrfs/ctree.c +0
-3@@ -1778,9 +1778,6 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,int orig_slot = path->slots[level];u64 orig_ptr; -if (level ==0 ) -return 0 ; - mid = path->nodes[level]; WARN_ON(path->locks[level] != BTRFS_WRITE_LOCK &&
Quoted 6 lines · Liu Bo
btrfs_search_slot()
if (level != 0)
setup_nodes_for_search()
balance_level()It is just impossible to have level=0 in
balance_level.
While this is true, what do you think about adding ASSERT(level > 0) ? This is to catch accidentally passing level 0.
Quoted 10 lines · David Sterba
Quoted 6 lines · Liu Bo
btrfs_search_slot()
if (level != 0)
setup_nodes_for_search()
balance_level()It is just impossible to have level=0 in
balance_level.While this is true, what do you think about adding ASSERT(level > 0) ? This is to catch accidentally passing level 0.
Sounds good, will update it.
thanks,
-liubo
PATCH v2 1/1 Btrfs: remove level==0 check in balance_level
In reply to Liu Bobtrfs_search_slot()
if (level != 0)
setup_nodes_for_search()
balance_level()
It is just impossible to have level=0 in balance_level.
---
v2: add assertion for level just in case someone breaks the rule in the future.
fs/btrfs/ctree.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/btrfs/ctree.c +1 -2
@@ -1778,8 +1778,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,int orig_slot = path->slots[level];u64 orig_ptr; -if (level ==0 ) -return 0 ; +ASSERT (level >0 ); mid = path->nodes[level];
Signature · 1 line
1.8.3.1
Quoted 9 lines · Liu Bo
btrfs_search_slot()
if (level != 0)
setup_nodes_for_search()
balance_level()It is just impossible to have level=0 in
balance_level.Reviewed-by Nikolay Borisov <[email protected]>Signed-off-by Liu Bo <[email protected]>