aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/auth.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2007-06-25 10:15:15 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2007-07-10 23:40:35 -0400
commitfc432dd90760a629c57026e57f65ff80a1a31d2f (patch)
tree1df060f199effb8cfd52772e618c0bac7b8d0e9f /net/sunrpc/auth.c
parent696e38df9d1b256e97b077ecde7afb8dd60364fd (diff)
SUNRPC: Enforce atomic updates of rpc_cred->cr_flags
Convert to the use of atomic bitops... Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/auth.c')
-rw-r--r--net/sunrpc/auth.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index 2156327da45b..4d7c78b05d1e 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -190,8 +190,8 @@ rpcauth_prune_expired(struct rpc_auth *auth, struct rpc_cred *cred, struct hlist
190 if (atomic_read(&cred->cr_count) != 1) 190 if (atomic_read(&cred->cr_count) != 1)
191 return; 191 return;
192 if (time_after(jiffies, cred->cr_expire + auth->au_credcache->expire)) 192 if (time_after(jiffies, cred->cr_expire + auth->au_credcache->expire))
193 cred->cr_flags &= ~RPCAUTH_CRED_UPTODATE; 193 clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags);
194 if (!(cred->cr_flags & RPCAUTH_CRED_UPTODATE)) { 194 if (test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) == 0) {
195 __hlist_del(&cred->cr_hash); 195 __hlist_del(&cred->cr_hash);
196 hlist_add_head(&cred->cr_hash, free); 196 hlist_add_head(&cred->cr_hash, free);
197 } 197 }
@@ -267,7 +267,7 @@ retry:
267 if (!IS_ERR(new)) 267 if (!IS_ERR(new))
268 goto retry; 268 goto retry;
269 cred = new; 269 cred = new;
270 } else if ((cred->cr_flags & RPCAUTH_CRED_NEW) 270 } else if (test_bit(RPCAUTH_CRED_NEW, &cred->cr_flags)
271 && cred->cr_ops->cr_init != NULL 271 && cred->cr_ops->cr_init != NULL
272 && !(flags & RPCAUTH_LOOKUP_NEW)) { 272 && !(flags & RPCAUTH_LOOKUP_NEW)) {
273 int res = cred->cr_ops->cr_init(auth, cred); 273 int res = cred->cr_ops->cr_init(auth, cred);
@@ -440,17 +440,19 @@ rpcauth_refreshcred(struct rpc_task *task)
440void 440void
441rpcauth_invalcred(struct rpc_task *task) 441rpcauth_invalcred(struct rpc_task *task)
442{ 442{
443 struct rpc_cred *cred = task->tk_msg.rpc_cred;
444
443 dprintk("RPC: %5u invalidating %s cred %p\n", 445 dprintk("RPC: %5u invalidating %s cred %p\n",
444 task->tk_pid, task->tk_auth->au_ops->au_name, task->tk_msg.rpc_cred); 446 task->tk_pid, task->tk_auth->au_ops->au_name, cred);
445 spin_lock(&rpc_credcache_lock); 447 if (cred)
446 if (task->tk_msg.rpc_cred) 448 clear_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags);
447 task->tk_msg.rpc_cred->cr_flags &= ~RPCAUTH_CRED_UPTODATE;
448 spin_unlock(&rpc_credcache_lock);
449} 449}
450 450
451int 451int
452rpcauth_uptodatecred(struct rpc_task *task) 452rpcauth_uptodatecred(struct rpc_task *task)
453{ 453{
454 return !(task->tk_msg.rpc_cred) || 454 struct rpc_cred *cred = task->tk_msg.rpc_cred;
455 (task->tk_msg.rpc_cred->cr_flags & RPCAUTH_CRED_UPTODATE); 455
456 return cred == NULL ||
457 test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0;
456} 458}