Re: [PATCH v3] rhashtable: detect when object movement between tables might have invalidated a lookup

From: Herbert Xu
Date: Sat Dec 01 2018 - 03:47:44 EST


On Fri, Nov 30, 2018 at 10:26:50AM +1100, NeilBrown wrote:
>
> diff --git a/lib/rhashtable.c b/lib/rhashtable.c
> index 30526afa8343..852ffa5160f1 100644
> --- a/lib/rhashtable.c
> +++ b/lib/rhashtable.c
> @@ -1179,8 +1179,7 @@ struct rhash_head __rcu **rht_bucket_nested(const struct bucket_table *tbl,
> unsigned int hash)
> {
> const unsigned int shift = PAGE_SHIFT - ilog2(sizeof(void *));
> - static struct rhash_head __rcu *rhnull =
> - (struct rhash_head __rcu *)NULLS_MARKER(0);
> + static struct rhash_head __rcu *rhnull;
> unsigned int index = hash & ((1 << tbl->nest) - 1);
> unsigned int size = tbl->size >> tbl->nest;
> unsigned int subhash = hash;
> @@ -1198,8 +1197,11 @@ struct rhash_head __rcu **rht_bucket_nested(const struct bucket_table *tbl,
> subhash >>= shift;
> }
>
> - if (!ntbl)
> + if (!ntbl) {
> + if (!rhnull)
> + INIT_RHT_NULLS_HEAD(rhnull);
> return &rhnull;
> + }

I think you missed my earlier reply beause of bouncing emails.

I think this is unnecessary because

RHT_NULLS_MARKER(RHT_NULLS_MARKER(0)) = RHT_NULLS_MARKER(0)

Thanks,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt