diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-07-31 14:29:07 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-08-04 08:54:05 -0400 |
commit | 988664a0f6bbfc356e6ce55f7a87b8594050012f (patch) | |
tree | c6c6450c8559c13ca9d53c8959ffa4276f3eddf1 /net | |
parent | 5d8d9a4d9ff74c55901642b4e2ac5124830ddafe (diff) |
SUNRPC: Store the hashtable size in struct rpc_cred_cache
Cleanup in preparation for allowing the user to determine the maximum hash
table size.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/sunrpc/auth.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c index db135543d21e..eef76a1f1dd6 100644 --- a/net/sunrpc/auth.c +++ b/net/sunrpc/auth.c | |||
@@ -145,12 +145,15 @@ int | |||
145 | rpcauth_init_credcache(struct rpc_auth *auth) | 145 | rpcauth_init_credcache(struct rpc_auth *auth) |
146 | { | 146 | { |
147 | struct rpc_cred_cache *new; | 147 | struct rpc_cred_cache *new; |
148 | unsigned int hashsize; | ||
148 | int i; | 149 | int i; |
149 | 150 | ||
150 | new = kmalloc(sizeof(*new), GFP_KERNEL); | 151 | new = kmalloc(sizeof(*new), GFP_KERNEL); |
151 | if (!new) | 152 | if (!new) |
152 | return -ENOMEM; | 153 | return -ENOMEM; |
153 | for (i = 0; i < RPC_CREDCACHE_NR; i++) | 154 | new->hashbits = RPC_CREDCACHE_HASHBITS; |
155 | hashsize = 1U << new->hashbits; | ||
156 | for (i = 0; i < hashsize; i++) | ||
154 | INIT_HLIST_HEAD(&new->hashtable[i]); | 157 | INIT_HLIST_HEAD(&new->hashtable[i]); |
155 | spin_lock_init(&new->lock); | 158 | spin_lock_init(&new->lock); |
156 | auth->au_credcache = new; | 159 | auth->au_credcache = new; |
@@ -183,11 +186,12 @@ rpcauth_clear_credcache(struct rpc_cred_cache *cache) | |||
183 | LIST_HEAD(free); | 186 | LIST_HEAD(free); |
184 | struct hlist_head *head; | 187 | struct hlist_head *head; |
185 | struct rpc_cred *cred; | 188 | struct rpc_cred *cred; |
189 | unsigned int hashsize = 1U << cache->hashbits; | ||
186 | int i; | 190 | int i; |
187 | 191 | ||
188 | spin_lock(&rpc_credcache_lock); | 192 | spin_lock(&rpc_credcache_lock); |
189 | spin_lock(&cache->lock); | 193 | spin_lock(&cache->lock); |
190 | for (i = 0; i < RPC_CREDCACHE_NR; i++) { | 194 | for (i = 0; i < hashsize; i++) { |
191 | head = &cache->hashtable[i]; | 195 | head = &cache->hashtable[i]; |
192 | while (!hlist_empty(head)) { | 196 | while (!hlist_empty(head)) { |
193 | cred = hlist_entry(head->first, struct rpc_cred, cr_hash); | 197 | cred = hlist_entry(head->first, struct rpc_cred, cr_hash); |
@@ -297,7 +301,7 @@ rpcauth_lookup_credcache(struct rpc_auth *auth, struct auth_cred * acred, | |||
297 | *entry, *new; | 301 | *entry, *new; |
298 | unsigned int nr; | 302 | unsigned int nr; |
299 | 303 | ||
300 | nr = hash_long(acred->uid, RPC_CREDCACHE_HASHBITS); | 304 | nr = hash_long(acred->uid, cache->hashbits); |
301 | 305 | ||
302 | rcu_read_lock(); | 306 | rcu_read_lock(); |
303 | hlist_for_each_entry_rcu(entry, pos, &cache->hashtable[nr], cr_hash) { | 307 | hlist_for_each_entry_rcu(entry, pos, &cache->hashtable[nr], cr_hash) { |