]> err.no Git - linux-2.6/blobdiff - net/sunrpc/auth.c
Merge branch 'irq-fix' of git://www.modarm9.com/gitsrc/pub/people/ukleinek/linux...
[linux-2.6] / net / sunrpc / auth.c
index b0f2b2ee7cc089f7d62c9d55ca0d5ba72e653dc1..6bfea9ed6869f4142d356b468a70493817b233b7 100644 (file)
@@ -220,6 +220,9 @@ rpcauth_destroy_credcache(struct rpc_auth *auth)
 }
 EXPORT_SYMBOL_GPL(rpcauth_destroy_credcache);
 
+
+#define RPC_AUTH_EXPIRY_MORATORIUM (60 * HZ)
+
 /*
  * Remove stale credentials. Avoid sleeping inside the loop.
  */
@@ -228,6 +231,7 @@ rpcauth_prune_expired(struct list_head *free, int nr_to_scan)
 {
        spinlock_t *cache_lock;
        struct rpc_cred *cred;
+       unsigned long expired = jiffies - RPC_AUTH_EXPIRY_MORATORIUM;
 
        while (!list_empty(&cred_unused)) {
                cred = list_entry(cred_unused.next, struct rpc_cred, cr_lru);
@@ -235,6 +239,10 @@ rpcauth_prune_expired(struct list_head *free, int nr_to_scan)
                number_cred_unused--;
                if (atomic_read(&cred->cr_count) != 0)
                        continue;
+               /* Enforce a 5 second garbage collection moratorium */
+               if (time_in_range(cred->cr_expire, expired, jiffies) &&
+                   test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0)
+                       continue;
                cache_lock = &cred->cr_auth->au_credcache->lock;
                spin_lock(cache_lock);
                if (atomic_read(&cred->cr_count) == 0) {
@@ -356,7 +364,6 @@ rpcauth_lookupcred(struct rpc_auth *auth, int flags)
        put_group_info(acred.group_info);
        return ret;
 }
-EXPORT_SYMBOL_GPL(rpcauth_lookupcred);
 
 void
 rpcauth_init_cred(struct rpc_cred *cred, const struct auth_cred *acred,
@@ -376,6 +383,15 @@ rpcauth_init_cred(struct rpc_cred *cred, const struct auth_cred *acred,
 EXPORT_SYMBOL_GPL(rpcauth_init_cred);
 
 void
+rpcauth_generic_bind_cred(struct rpc_task *task, struct rpc_cred *cred)
+{
+       task->tk_msg.rpc_cred = get_rpccred(cred);
+       dprintk("RPC: %5u holding %s cred %p\n", task->tk_pid,
+                       cred->cr_auth->au_ops->au_name, cred);
+}
+EXPORT_SYMBOL_GPL(rpcauth_generic_bind_cred);
+
+static void
 rpcauth_bind_root_cred(struct rpc_task *task)
 {
        struct rpc_auth *auth = task->tk_client->cl_auth;
@@ -394,8 +410,8 @@ rpcauth_bind_root_cred(struct rpc_task *task)
                task->tk_status = PTR_ERR(ret);
 }
 
-void
-rpcauth_bindcred(struct rpc_task *task)
+static void
+rpcauth_bind_new_cred(struct rpc_task *task)
 {
        struct rpc_auth *auth = task->tk_client->cl_auth;
        struct rpc_cred *ret;
@@ -410,14 +426,14 @@ rpcauth_bindcred(struct rpc_task *task)
 }
 
 void
-rpcauth_holdcred(struct rpc_task *task)
+rpcauth_bindcred(struct rpc_task *task, struct rpc_cred *cred, int flags)
 {
-       struct rpc_cred *cred = task->tk_msg.rpc_cred;
-       if (cred != NULL) {
-               get_rpccred(cred);
-               dprintk("RPC: %5u holding %s cred %p\n", task->tk_pid,
-                               cred->cr_auth->au_ops->au_name, cred);
-       }
+       if (cred != NULL)
+               cred->cr_ops->crbind(task, cred);
+       else if (flags & RPC_TASK_ROOTCREDS)
+               rpcauth_bind_root_cred(task);
+       else
+               rpcauth_bind_new_cred(task);
 }
 
 void
@@ -558,6 +574,7 @@ static struct shrinker rpc_cred_shrinker = {
 void __init rpcauth_init_module(void)
 {
        rpc_init_authunix();
+       rpc_init_generic_auth();
        register_shrinker(&rpc_cred_shrinker);
 }