Re: [PATCH] bcache: move verify logic from bch_btree_node_write to bch_btree_init_next

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2019/8/6 8:13 下午, Shenghui Wang wrote:
> commit 2a285686c1098 ("bcache: btree locking rework") introduced
> bch_btree_init_next(), and moved the sort logic into the function.
> Before the commit introduced, __bch_btree_node_write() will do sort
> first, then do possible verify. After the change, the verify will
> run before any sort/change sets of btree node, and no verify will
> run after sort done in bch_btree_init_next().
> 
> Move the verify code into bch_btree_init_next(), right after sort done.
> 

Hi Shenghui,

What is the benefit of this change ?

Thanks.

Coly Li

> Signed-off-by: Shenghui Wang <shhuiw@xxxxxxxxxxx>
> ---
>  drivers/md/bcache/btree.c | 20 +++++++++-----------
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
> index ba434d9ac720..b15878334a29 100644
> --- a/drivers/md/bcache/btree.c
> +++ b/drivers/md/bcache/btree.c
> @@ -167,16 +167,24 @@ static inline struct bset *write_block(struct btree *b)
>  
>  static void bch_btree_init_next(struct btree *b)
>  {
> +	unsigned int nsets = b->keys.nsets;
> +
>  	/* If not a leaf node, always sort */
>  	if (b->level && b->keys.nsets)
>  		bch_btree_sort(&b->keys, &b->c->sort);
>  	else
>  		bch_btree_sort_lazy(&b->keys, &b->c->sort);
>  
> +	/*
> +	 * do verify if there was more than one set initially (i.e. we did a
> +	 * sort) and we sorted down to a single set:
> +	 */
> +	if (nsets && !b->keys.nsets)
> +		bch_btree_verify(b);
> +
>  	if (b->written < btree_blocks(b))
>  		bch_bset_init_next(&b->keys, write_block(b),
>  				   bset_magic(&b->c->sb));
> -
>  }
>  
>  /* Btree key manipulation */
> @@ -489,19 +497,9 @@ void __bch_btree_node_write(struct btree *b, struct closure *parent)
>  
>  void bch_btree_node_write(struct btree *b, struct closure *parent)
>  {
> -	unsigned int nsets = b->keys.nsets;
> -
>  	lockdep_assert_held(&b->lock);
>  
>  	__bch_btree_node_write(b, parent);
> -
> -	/*
> -	 * do verify if there was more than one set initially (i.e. we did a
> -	 * sort) and we sorted down to a single set:
> -	 */
> -	if (nsets && !b->keys.nsets)
> -		bch_btree_verify(b);
> -
>  	bch_btree_init_next(b);
>  }
>  
> 


-- 

Coly Li



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux ARM Kernel]     [Linux Filesystem Development]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux