All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Btrfs: remove level==0 check in balance_level
@ 2018-09-11 22:06 Liu Bo
  2018-09-12  6:42 ` Nikolay Borisov
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Liu Bo @ 2018-09-11 22:06 UTC (permalink / raw)
  To: linux-btrfs

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 <bo.liu@linux.alibaba.com>
---
 fs/btrfs/ctree.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 8b31caa60b0a..858085490e23 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -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 &&
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Btrfs: remove level==0 check in balance_level
  2018-09-11 22:06 [PATCH] Btrfs: remove level==0 check in balance_level Liu Bo
@ 2018-09-12  6:42 ` Nikolay Borisov
  2018-09-12 12:52 ` David Sterba
  2018-09-13 17:55 ` [PATCH v2] " Liu Bo
  2 siblings, 0 replies; 6+ messages in thread
From: Nikolay Borisov @ 2018-09-12  6:42 UTC (permalink / raw)
  To: Liu Bo, linux-btrfs



On 12.09.2018 01:06, Liu Bo wrote:
> 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 <bo.liu@linux.alibaba.com>

I concur with the analysis:

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> ---
>  fs/btrfs/ctree.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
> index 8b31caa60b0a..858085490e23 100644
> --- a/fs/btrfs/ctree.c
> +++ b/fs/btrfs/ctree.c
> @@ -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 &&
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Btrfs: remove level==0 check in balance_level
  2018-09-11 22:06 [PATCH] Btrfs: remove level==0 check in balance_level Liu Bo
  2018-09-12  6:42 ` Nikolay Borisov
@ 2018-09-12 12:52 ` David Sterba
  2018-09-12 19:30   ` Liu Bo
  2018-09-13 17:55 ` [PATCH v2] " Liu Bo
  2 siblings, 1 reply; 6+ messages in thread
From: David Sterba @ 2018-09-12 12:52 UTC (permalink / raw)
  To: Liu Bo; +Cc: linux-btrfs

On Wed, Sep 12, 2018 at 06:06:23AM +0800, Liu Bo wrote:
> 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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Btrfs: remove level==0 check in balance_level
  2018-09-12 12:52 ` David Sterba
@ 2018-09-12 19:30   ` Liu Bo
  0 siblings, 0 replies; 6+ messages in thread
From: Liu Bo @ 2018-09-12 19:30 UTC (permalink / raw)
  To: dsterba, linux-btrfs

On Wed, Sep 12, 2018 at 02:52:38PM +0200, David Sterba wrote:
> On Wed, Sep 12, 2018 at 06:06:23AM +0800, Liu Bo wrote:
> > 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] Btrfs: remove level==0 check in balance_level
  2018-09-11 22:06 [PATCH] Btrfs: remove level==0 check in balance_level Liu Bo
  2018-09-12  6:42 ` Nikolay Borisov
  2018-09-12 12:52 ` David Sterba
@ 2018-09-13 17:55 ` Liu Bo
  2018-09-14 12:49   ` David Sterba
  2 siblings, 1 reply; 6+ messages in thread
From: Liu Bo @ 2018-09-13 17:55 UTC (permalink / raw)
  To: linux-btrfs

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 <nborisov@suse.com>
Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
---
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(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 8b31caa60b0a..ada44c786f2e 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -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];
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] Btrfs: remove level==0 check in balance_level
  2018-09-13 17:55 ` [PATCH v2] " Liu Bo
@ 2018-09-14 12:49   ` David Sterba
  0 siblings, 0 replies; 6+ messages in thread
From: David Sterba @ 2018-09-14 12:49 UTC (permalink / raw)
  To: Liu Bo; +Cc: linux-btrfs

On Fri, Sep 14, 2018 at 01:55:59AM +0800, Liu Bo wrote:
> 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 <nborisov@suse.com>
> Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>

Reviewed-by: David Sterba <dsterba@suse.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-09-14 18:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-11 22:06 [PATCH] Btrfs: remove level==0 check in balance_level Liu Bo
2018-09-12  6:42 ` Nikolay Borisov
2018-09-12 12:52 ` David Sterba
2018-09-12 19:30   ` Liu Bo
2018-09-13 17:55 ` [PATCH v2] " Liu Bo
2018-09-14 12:49   ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.