From fdd4c509d6addf8ea8ac9329f15b9637818df083 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Sat, 31 Jul 2010 14:29:07 -0400 Subject: [PATCH] --- yaml --- r: 206407 b: refs/heads/master c: 988664a0f6bbfc356e6ce55f7a87b8594050012f h: refs/heads/master i: 206405: 7b19500163e6470b5dd70141e58f17a4274683f6 206403: 601e630eb163a1d4edbd7c3cb79a68c1768ea781 206399: 38c7e9fc7f2674c9e8c6693938eb538dddcd4afb v: v3 --- [refs] | 2 +- trunk/include/linux/sunrpc/auth.h | 1 + trunk/net/sunrpc/auth.c | 10 +++++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index 577d73d1495b..c898306ae255 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 5d8d9a4d9ff74c55901642b4e2ac5124830ddafe +refs/heads/master: 988664a0f6bbfc356e6ce55f7a87b8594050012f diff --git a/trunk/include/linux/sunrpc/auth.h b/trunk/include/linux/sunrpc/auth.h index 784e78c73ec5..84d64b6926a9 100644 --- a/trunk/include/linux/sunrpc/auth.h +++ b/trunk/include/linux/sunrpc/auth.h @@ -65,6 +65,7 @@ struct rpc_cred { #define RPC_CREDCACHE_NR (1 << RPC_CREDCACHE_HASHBITS) struct rpc_cred_cache { struct hlist_head hashtable[RPC_CREDCACHE_NR]; + unsigned int hashbits; spinlock_t lock; }; diff --git a/trunk/net/sunrpc/auth.c b/trunk/net/sunrpc/auth.c index db135543d21e..eef76a1f1dd6 100644 --- a/trunk/net/sunrpc/auth.c +++ b/trunk/net/sunrpc/auth.c @@ -145,12 +145,15 @@ int rpcauth_init_credcache(struct rpc_auth *auth) { struct rpc_cred_cache *new; + unsigned int hashsize; int i; new = kmalloc(sizeof(*new), GFP_KERNEL); if (!new) return -ENOMEM; - for (i = 0; i < RPC_CREDCACHE_NR; i++) + new->hashbits = RPC_CREDCACHE_HASHBITS; + hashsize = 1U << new->hashbits; + for (i = 0; i < hashsize; i++) INIT_HLIST_HEAD(&new->hashtable[i]); spin_lock_init(&new->lock); auth->au_credcache = new; @@ -183,11 +186,12 @@ rpcauth_clear_credcache(struct rpc_cred_cache *cache) LIST_HEAD(free); struct hlist_head *head; struct rpc_cred *cred; + unsigned int hashsize = 1U << cache->hashbits; int i; spin_lock(&rpc_credcache_lock); spin_lock(&cache->lock); - for (i = 0; i < RPC_CREDCACHE_NR; i++) { + for (i = 0; i < hashsize; i++) { head = &cache->hashtable[i]; while (!hlist_empty(head)) { 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, *entry, *new; unsigned int nr; - nr = hash_long(acred->uid, RPC_CREDCACHE_HASHBITS); + nr = hash_long(acred->uid, cache->hashbits); rcu_read_lock(); hlist_for_each_entry_rcu(entry, pos, &cache->hashtable[nr], cr_hash) {