]> err.no Git - linux-2.6/commitdiff
SUNRPC: Protect creds against early garbage collection
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Mon, 14 Apr 2008 22:13:37 +0000 (18:13 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Sat, 19 Apr 2008 20:55:02 +0000 (16:55 -0400)
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
net/sunrpc/auth.c

index 0632cd0a1ad7f926a7ef6032845d0e9dc48afdf7..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) {