diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2015-03-20 06:56:59 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-20 16:16:24 -0400 |
commit | 488fb86ee91d3b1182c2e30a9f9b45da14eda46f (patch) | |
tree | bcee7b730a66a4d7853310f8677778ccfb9484e3 | |
parent | 0b8c707ddf37171413fe67350263e5b6ffeedf7c (diff) |
rhashtable: Make rhashtable_init params argument const
This patch marks the rhashtable_init params argument const as
there is no reason to modify it since we will always make a copy
of it in the rhashtable.
This patch also fixes a bug where we don't actually round up the
value of min_size unless it is less than HASH_MIN_SIZE.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/rhashtable.h | 3 | ||||
-rw-r--r-- | lib/rhashtable.c | 7 |
2 files changed, 6 insertions, 4 deletions
diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h index 99425f2be708..c85363c45fc0 100644 --- a/include/linux/rhashtable.h +++ b/include/linux/rhashtable.h | |||
@@ -181,7 +181,8 @@ static inline int lockdep_rht_bucket_is_held(const struct bucket_table *tbl, | |||
181 | } | 181 | } |
182 | #endif /* CONFIG_PROVE_LOCKING */ | 182 | #endif /* CONFIG_PROVE_LOCKING */ |
183 | 183 | ||
184 | int rhashtable_init(struct rhashtable *ht, struct rhashtable_params *params); | 184 | int rhashtable_init(struct rhashtable *ht, |
185 | const struct rhashtable_params *params); | ||
185 | 186 | ||
186 | void rhashtable_insert(struct rhashtable *ht, struct rhash_head *node); | 187 | void rhashtable_insert(struct rhashtable *ht, struct rhash_head *node); |
187 | bool rhashtable_remove(struct rhashtable *ht, struct rhash_head *node); | 188 | bool rhashtable_remove(struct rhashtable *ht, struct rhash_head *node); |
diff --git a/lib/rhashtable.c b/lib/rhashtable.c index e75c48d9d82f..e0a9d59f80d6 100644 --- a/lib/rhashtable.c +++ b/lib/rhashtable.c | |||
@@ -870,7 +870,7 @@ out: | |||
870 | } | 870 | } |
871 | EXPORT_SYMBOL_GPL(rhashtable_walk_stop); | 871 | EXPORT_SYMBOL_GPL(rhashtable_walk_stop); |
872 | 872 | ||
873 | static size_t rounded_hashtable_size(struct rhashtable_params *params) | 873 | static size_t rounded_hashtable_size(const struct rhashtable_params *params) |
874 | { | 874 | { |
875 | return max(roundup_pow_of_two(params->nelem_hint * 4 / 3), | 875 | return max(roundup_pow_of_two(params->nelem_hint * 4 / 3), |
876 | (unsigned long)params->min_size); | 876 | (unsigned long)params->min_size); |
@@ -919,7 +919,8 @@ static size_t rounded_hashtable_size(struct rhashtable_params *params) | |||
919 | * .obj_hashfn = my_hash_fn, | 919 | * .obj_hashfn = my_hash_fn, |
920 | * }; | 920 | * }; |
921 | */ | 921 | */ |
922 | int rhashtable_init(struct rhashtable *ht, struct rhashtable_params *params) | 922 | int rhashtable_init(struct rhashtable *ht, |
923 | const struct rhashtable_params *params) | ||
923 | { | 924 | { |
924 | struct bucket_table *tbl; | 925 | struct bucket_table *tbl; |
925 | size_t size; | 926 | size_t size; |
@@ -946,7 +947,7 @@ int rhashtable_init(struct rhashtable *ht, struct rhashtable_params *params) | |||
946 | if (params->max_size) | 947 | if (params->max_size) |
947 | ht->p.max_size = rounddown_pow_of_two(params->max_size); | 948 | ht->p.max_size = rounddown_pow_of_two(params->max_size); |
948 | 949 | ||
949 | ht->p.min_size = max(params->min_size, HASH_MIN_SIZE); | 950 | ht->p.min_size = max(ht->p.min_size, HASH_MIN_SIZE); |
950 | 951 | ||
951 | if (params->locks_mul) | 952 | if (params->locks_mul) |
952 | ht->p.locks_mul = roundup_pow_of_two(params->locks_mul); | 953 | ht->p.locks_mul = roundup_pow_of_two(params->locks_mul); |