Re: [PATCH] bcache: check if verify needed in bch_btree_init_next insteaf of bch_btree_node_write

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

 



On 11/6/18 6:17 PM, Shenghui Wang wrote:
> commit 2a285686c109 ("bcache: btree locking rework") introduced
> bch_btree_init_next and moved sort calling into it.
> 
> But bch_btree_node_write is left checking if verify needed before
> sort run. As no mergesort before checking, do verify will not run
> even if mergesort run in bch_btree_init_next afterwards.
> 
> Move the verify checking to bch_btree_init_next.
> 
> Signed-off-by: Shenghui Wang <shhuiw@xxxxxxxxxxx>

Hi Shenghui,

Do you run into any problem with current code ? I am wondering why it
works well for now.

Thanks.

Coly Li

> ---
>  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 3f4211b5cd33..74d919a58189 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 */
> @@ -483,19 +491,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);
>  }
>  
> 




[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