]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
SUNRPC: Store the hashtable size in struct rpc_cred_cache
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Sat, 31 Jul 2010 18:29:07 +0000 (14:29 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Wed, 4 Aug 2010 12:54:05 +0000 (08:54 -0400)
Cleanup in preparation for allowing the user to determine the maximum hash
table size.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
include/linux/sunrpc/auth.h
net/sunrpc/auth.c

index 784e78c73ec519817f92b4d7b68298e3d3ad954b..84d64b6926a9cdf1abe86899c288054f95361349 100644 (file)
@@ -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;
 };
 
index db135543d21eaf845ad1ae63f49763654d56b040..eef76a1f1dd63c15d1f1c7bac080bc5ae6e7be85 100644 (file)
@@ -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) {