aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@hammerspace.com>2018-10-14 10:34:31 -0400
committerTrond Myklebust <trond.myklebust@hammerspace.com>2018-10-23 12:24:33 -0400
commit79b181810285a6b9b7a1aed25c365c9e1782e22a (patch)
tree9227dcdd771223ab11d6893ece6678d529782019 /net
parent07d02a67b7faae56e184f6c35f78de47f06da37f (diff)
SUNRPC: Convert auth creds to use refcount_t
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Diffstat (limited to 'net')
-rw-r--r--net/sunrpc/auth.c14
-rw-r--r--net/sunrpc/auth_null.c2
2 files changed, 8 insertions, 8 deletions
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index 77748e572686..4903eda5dd61 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -495,7 +495,7 @@ rpcauth_prune_expired(struct list_head *free, int nr_to_scan)
495 495
496 if (nr_to_scan-- == 0) 496 if (nr_to_scan-- == 0)
497 break; 497 break;
498 if (atomic_read(&cred->cr_count) > 1) { 498 if (refcount_read(&cred->cr_count) > 1) {
499 rpcauth_lru_remove_locked(cred); 499 rpcauth_lru_remove_locked(cred);
500 continue; 500 continue;
501 } 501 }
@@ -589,7 +589,7 @@ rpcauth_lookup_credcache(struct rpc_auth *auth, struct auth_cred * acred,
589 continue; 589 continue;
590 if (flags & RPCAUTH_LOOKUP_RCU) { 590 if (flags & RPCAUTH_LOOKUP_RCU) {
591 if (test_bit(RPCAUTH_CRED_NEW, &entry->cr_flags) || 591 if (test_bit(RPCAUTH_CRED_NEW, &entry->cr_flags) ||
592 atomic_read(&entry->cr_count) == 0) 592 refcount_read(&entry->cr_count) == 0)
593 continue; 593 continue;
594 cred = entry; 594 cred = entry;
595 break; 595 break;
@@ -623,7 +623,7 @@ rpcauth_lookup_credcache(struct rpc_auth *auth, struct auth_cred * acred,
623 if (cred == NULL) { 623 if (cred == NULL) {
624 cred = new; 624 cred = new;
625 set_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags); 625 set_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags);
626 atomic_inc(&cred->cr_count); 626 refcount_inc(&cred->cr_count);
627 hlist_add_head_rcu(&cred->cr_hash, &cache->hashtable[nr]); 627 hlist_add_head_rcu(&cred->cr_hash, &cache->hashtable[nr]);
628 } else 628 } else
629 list_add_tail(&new->cr_lru, &free); 629 list_add_tail(&new->cr_lru, &free);
@@ -670,7 +670,7 @@ rpcauth_init_cred(struct rpc_cred *cred, const struct auth_cred *acred,
670{ 670{
671 INIT_HLIST_NODE(&cred->cr_hash); 671 INIT_HLIST_NODE(&cred->cr_hash);
672 INIT_LIST_HEAD(&cred->cr_lru); 672 INIT_LIST_HEAD(&cred->cr_lru);
673 atomic_set(&cred->cr_count, 1); 673 refcount_set(&cred->cr_count, 1);
674 cred->cr_auth = auth; 674 cred->cr_auth = auth;
675 cred->cr_ops = ops; 675 cred->cr_ops = ops;
676 cred->cr_expire = jiffies; 676 cred->cr_expire = jiffies;
@@ -739,9 +739,9 @@ put_rpccred(struct rpc_cred *cred)
739 if (cred == NULL) 739 if (cred == NULL)
740 return; 740 return;
741 rcu_read_lock(); 741 rcu_read_lock();
742 if (atomic_dec_and_test(&cred->cr_count)) 742 if (refcount_dec_and_test(&cred->cr_count))
743 goto destroy; 743 goto destroy;
744 if (atomic_read(&cred->cr_count) != 1 || 744 if (refcount_read(&cred->cr_count) != 1 ||
745 !test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags)) 745 !test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags))
746 goto out; 746 goto out;
747 if (test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0) { 747 if (test_bit(RPCAUTH_CRED_UPTODATE, &cred->cr_flags) != 0) {
@@ -752,7 +752,7 @@ put_rpccred(struct rpc_cred *cred)
752 rpcauth_lru_remove(cred); 752 rpcauth_lru_remove(cred);
753 } else if (rpcauth_unhash_cred(cred)) { 753 } else if (rpcauth_unhash_cred(cred)) {
754 rpcauth_lru_remove(cred); 754 rpcauth_lru_remove(cred);
755 if (atomic_dec_and_test(&cred->cr_count)) 755 if (refcount_dec_and_test(&cred->cr_count))
756 goto destroy; 756 goto destroy;
757 } 757 }
758out: 758out:
diff --git a/net/sunrpc/auth_null.c b/net/sunrpc/auth_null.c
index a7c00b4959f3..ea816d7000a4 100644
--- a/net/sunrpc/auth_null.c
+++ b/net/sunrpc/auth_null.c
@@ -138,6 +138,6 @@ struct rpc_cred null_cred = {
138 .cr_lru = LIST_HEAD_INIT(null_cred.cr_lru), 138 .cr_lru = LIST_HEAD_INIT(null_cred.cr_lru),
139 .cr_auth = &null_auth, 139 .cr_auth = &null_auth,
140 .cr_ops = &null_credops, 140 .cr_ops = &null_credops,
141 .cr_count = ATOMIC_INIT(2), 141 .cr_count = REFCOUNT_INIT(2),
142 .cr_flags = 1UL << RPCAUTH_CRED_UPTODATE, 142 .cr_flags = 1UL << RPCAUTH_CRED_UPTODATE,
143}; 143};