diff options
Diffstat (limited to 'lib/rhashtable.c')
-rw-r--r-- | lib/rhashtable.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/rhashtable.c b/lib/rhashtable.c index 3d2b4733f6cb..081be3ba9ea8 100644 --- a/lib/rhashtable.c +++ b/lib/rhashtable.c | |||
@@ -297,7 +297,7 @@ int rhashtable_shrink(struct rhashtable *ht, gfp_t flags) | |||
297 | 297 | ||
298 | ASSERT_RHT_MUTEX(ht); | 298 | ASSERT_RHT_MUTEX(ht); |
299 | 299 | ||
300 | if (tbl->size <= HASH_MIN_SIZE) | 300 | if (ht->shift <= ht->p.min_shift) |
301 | return 0; | 301 | return 0; |
302 | 302 | ||
303 | ntbl = bucket_table_alloc(tbl->size / 2, flags); | 303 | ntbl = bucket_table_alloc(tbl->size / 2, flags); |
@@ -505,9 +505,10 @@ void *rhashtable_lookup_compare(const struct rhashtable *ht, u32 hash, | |||
505 | } | 505 | } |
506 | EXPORT_SYMBOL_GPL(rhashtable_lookup_compare); | 506 | EXPORT_SYMBOL_GPL(rhashtable_lookup_compare); |
507 | 507 | ||
508 | static size_t rounded_hashtable_size(unsigned int nelem) | 508 | static size_t rounded_hashtable_size(struct rhashtable_params *params) |
509 | { | 509 | { |
510 | return max(roundup_pow_of_two(nelem * 4 / 3), HASH_MIN_SIZE); | 510 | return max(roundup_pow_of_two(params->nelem_hint * 4 / 3), |
511 | 1UL << params->min_shift); | ||
511 | } | 512 | } |
512 | 513 | ||
513 | /** | 514 | /** |
@@ -565,8 +566,11 @@ int rhashtable_init(struct rhashtable *ht, struct rhashtable_params *params) | |||
565 | (!params->key_len && !params->obj_hashfn)) | 566 | (!params->key_len && !params->obj_hashfn)) |
566 | return -EINVAL; | 567 | return -EINVAL; |
567 | 568 | ||
569 | params->min_shift = max_t(size_t, params->min_shift, | ||
570 | ilog2(HASH_MIN_SIZE)); | ||
571 | |||
568 | if (params->nelem_hint) | 572 | if (params->nelem_hint) |
569 | size = rounded_hashtable_size(params->nelem_hint); | 573 | size = rounded_hashtable_size(params); |
570 | 574 | ||
571 | tbl = bucket_table_alloc(size, GFP_KERNEL); | 575 | tbl = bucket_table_alloc(size, GFP_KERNEL); |
572 | if (tbl == NULL) | 576 | if (tbl == NULL) |