aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nfsd/nfs4layouts.c4
-rw-r--r--fs/nfsd/nfs4state.c24
-rw-r--r--fs/nfsd/state.h3
3 files changed, 16 insertions, 15 deletions
diff --git a/fs/nfsd/nfs4layouts.c b/fs/nfsd/nfs4layouts.c
index e122da696f1b..fed076069dd2 100644
--- a/fs/nfsd/nfs4layouts.c
+++ b/fs/nfsd/nfs4layouts.c
@@ -335,7 +335,7 @@ nfsd4_recall_file_layout(struct nfs4_layout_stateid *ls)
335 335
336 trace_layout_recall(&ls->ls_stid.sc_stateid); 336 trace_layout_recall(&ls->ls_stid.sc_stateid);
337 337
338 atomic_inc(&ls->ls_stid.sc_count); 338 refcount_inc(&ls->ls_stid.sc_count);
339 nfsd4_run_cb(&ls->ls_recall); 339 nfsd4_run_cb(&ls->ls_recall);
340 340
341out_unlock: 341out_unlock:
@@ -440,7 +440,7 @@ nfsd4_insert_layout(struct nfsd4_layoutget *lgp, struct nfs4_layout_stateid *ls)
440 goto done; 440 goto done;
441 } 441 }
442 442
443 atomic_inc(&ls->ls_stid.sc_count); 443 refcount_inc(&ls->ls_stid.sc_count);
444 list_add_tail(&new->lo_perstate, &ls->ls_layouts); 444 list_add_tail(&new->lo_perstate, &ls->ls_layouts);
445 new = NULL; 445 new = NULL;
446done: 446done:
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 251dac7579ec..df2e5b4b222e 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -656,7 +656,7 @@ struct nfs4_stid *nfs4_alloc_stid(struct nfs4_client *cl, struct kmem_cache *sla
656 stid->sc_stateid.si_opaque.so_id = new_id; 656 stid->sc_stateid.si_opaque.so_id = new_id;
657 stid->sc_stateid.si_opaque.so_clid = cl->cl_clientid; 657 stid->sc_stateid.si_opaque.so_clid = cl->cl_clientid;
658 /* Will be incremented before return to client: */ 658 /* Will be incremented before return to client: */
659 atomic_set(&stid->sc_count, 1); 659 refcount_set(&stid->sc_count, 1);
660 spin_lock_init(&stid->sc_lock); 660 spin_lock_init(&stid->sc_lock);
661 661
662 /* 662 /*
@@ -813,7 +813,7 @@ nfs4_put_stid(struct nfs4_stid *s)
813 813
814 might_lock(&clp->cl_lock); 814 might_lock(&clp->cl_lock);
815 815
816 if (!atomic_dec_and_lock(&s->sc_count, &clp->cl_lock)) { 816 if (!refcount_dec_and_lock(&s->sc_count, &clp->cl_lock)) {
817 wake_up_all(&close_wq); 817 wake_up_all(&close_wq);
818 return; 818 return;
819 } 819 }
@@ -913,7 +913,7 @@ hash_delegation_locked(struct nfs4_delegation *dp, struct nfs4_file *fp)
913 if (status) 913 if (status)
914 return status; 914 return status;
915 ++fp->fi_delegees; 915 ++fp->fi_delegees;
916 atomic_inc(&dp->dl_stid.sc_count); 916 refcount_inc(&dp->dl_stid.sc_count);
917 dp->dl_stid.sc_type = NFS4_DELEG_STID; 917 dp->dl_stid.sc_type = NFS4_DELEG_STID;
918 list_add(&dp->dl_perfile, &fp->fi_delegations); 918 list_add(&dp->dl_perfile, &fp->fi_delegations);
919 list_add(&dp->dl_perclnt, &clp->cl_delegations); 919 list_add(&dp->dl_perclnt, &clp->cl_delegations);
@@ -1214,7 +1214,7 @@ static void put_ol_stateid_locked(struct nfs4_ol_stateid *stp,
1214 1214
1215 WARN_ON_ONCE(!list_empty(&stp->st_locks)); 1215 WARN_ON_ONCE(!list_empty(&stp->st_locks));
1216 1216
1217 if (!atomic_dec_and_test(&s->sc_count)) { 1217 if (!refcount_dec_and_test(&s->sc_count)) {
1218 wake_up_all(&close_wq); 1218 wake_up_all(&close_wq);
1219 return; 1219 return;
1220 } 1220 }
@@ -2079,7 +2079,7 @@ find_stateid_by_type(struct nfs4_client *cl, stateid_t *t, char typemask)
2079 s = find_stateid_locked(cl, t); 2079 s = find_stateid_locked(cl, t);
2080 if (s != NULL) { 2080 if (s != NULL) {
2081 if (typemask & s->sc_type) 2081 if (typemask & s->sc_type)
2082 atomic_inc(&s->sc_count); 2082 refcount_inc(&s->sc_count);
2083 else 2083 else
2084 s = NULL; 2084 s = NULL;
2085 } 2085 }
@@ -3564,7 +3564,7 @@ nfsd4_find_existing_open(struct nfs4_file *fp, struct nfsd4_open *open)
3564 continue; 3564 continue;
3565 if (local->st_stateowner == &oo->oo_owner) { 3565 if (local->st_stateowner == &oo->oo_owner) {
3566 ret = local; 3566 ret = local;
3567 atomic_inc(&ret->st_stid.sc_count); 3567 refcount_inc(&ret->st_stid.sc_count);
3568 break; 3568 break;
3569 } 3569 }
3570 } 3570 }
@@ -3623,7 +3623,7 @@ init_open_stateid(struct nfs4_file *fp, struct nfsd4_open *open)
3623 goto out_unlock; 3623 goto out_unlock;
3624 3624
3625 open->op_stp = NULL; 3625 open->op_stp = NULL;
3626 atomic_inc(&stp->st_stid.sc_count); 3626 refcount_inc(&stp->st_stid.sc_count);
3627 stp->st_stid.sc_type = NFS4_OPEN_STID; 3627 stp->st_stid.sc_type = NFS4_OPEN_STID;
3628 INIT_LIST_HEAD(&stp->st_locks); 3628 INIT_LIST_HEAD(&stp->st_locks);
3629 stp->st_stateowner = nfs4_get_stateowner(&oo->oo_owner); 3629 stp->st_stateowner = nfs4_get_stateowner(&oo->oo_owner);
@@ -3671,7 +3671,7 @@ move_to_close_lru(struct nfs4_ol_stateid *s, struct net *net)
3671 * there should be no danger of the refcount going back up again at 3671 * there should be no danger of the refcount going back up again at
3672 * this point. 3672 * this point.
3673 */ 3673 */
3674 wait_event(close_wq, atomic_read(&s->st_stid.sc_count) == 2); 3674 wait_event(close_wq, refcount_read(&s->st_stid.sc_count) == 2);
3675 3675
3676 release_all_access(s); 3676 release_all_access(s);
3677 if (s->st_stid.sc_file) { 3677 if (s->st_stid.sc_file) {
@@ -3833,7 +3833,7 @@ static void nfsd_break_one_deleg(struct nfs4_delegation *dp)
3833 * lock) we know the server hasn't removed the lease yet, we know 3833 * lock) we know the server hasn't removed the lease yet, we know
3834 * it's safe to take a reference. 3834 * it's safe to take a reference.
3835 */ 3835 */
3836 atomic_inc(&dp->dl_stid.sc_count); 3836 refcount_inc(&dp->dl_stid.sc_count);
3837 nfsd4_run_cb(&dp->dl_recall); 3837 nfsd4_run_cb(&dp->dl_recall);
3838} 3838}
3839 3839
@@ -5121,7 +5121,7 @@ nfsd4_free_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
5121 ret = nfserr_locks_held; 5121 ret = nfserr_locks_held;
5122 break; 5122 break;
5123 case NFS4_LOCK_STID: 5123 case NFS4_LOCK_STID:
5124 atomic_inc(&s->sc_count); 5124 refcount_inc(&s->sc_count);
5125 spin_unlock(&cl->cl_lock); 5125 spin_unlock(&cl->cl_lock);
5126 ret = nfsd4_free_lock_stateid(stateid, s); 5126 ret = nfsd4_free_lock_stateid(stateid, s);
5127 goto out; 5127 goto out;
@@ -5628,7 +5628,7 @@ init_lock_stateid(struct nfs4_ol_stateid *stp, struct nfs4_lockowner *lo,
5628 5628
5629 lockdep_assert_held(&clp->cl_lock); 5629 lockdep_assert_held(&clp->cl_lock);
5630 5630
5631 atomic_inc(&stp->st_stid.sc_count); 5631 refcount_inc(&stp->st_stid.sc_count);
5632 stp->st_stid.sc_type = NFS4_LOCK_STID; 5632 stp->st_stid.sc_type = NFS4_LOCK_STID;
5633 stp->st_stateowner = nfs4_get_stateowner(&lo->lo_owner); 5633 stp->st_stateowner = nfs4_get_stateowner(&lo->lo_owner);
5634 get_nfs4_file(fp); 5634 get_nfs4_file(fp);
@@ -5654,7 +5654,7 @@ find_lock_stateid(struct nfs4_lockowner *lo, struct nfs4_file *fp)
5654 5654
5655 list_for_each_entry(lst, &lo->lo_owner.so_stateids, st_perstateowner) { 5655 list_for_each_entry(lst, &lo->lo_owner.so_stateids, st_perstateowner) {
5656 if (lst->st_stid.sc_file == fp) { 5656 if (lst->st_stid.sc_file == fp) {
5657 atomic_inc(&lst->st_stid.sc_count); 5657 refcount_inc(&lst->st_stid.sc_count);
5658 return lst; 5658 return lst;
5659 } 5659 }
5660 } 5660 }
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h
index 86aa92d200e1..c259271c35a4 100644
--- a/fs/nfsd/state.h
+++ b/fs/nfsd/state.h
@@ -36,6 +36,7 @@
36#define _NFSD4_STATE_H 36#define _NFSD4_STATE_H
37 37
38#include <linux/idr.h> 38#include <linux/idr.h>
39#include <linux/refcount.h>
39#include <linux/sunrpc/svc_xprt.h> 40#include <linux/sunrpc/svc_xprt.h>
40#include "nfsfh.h" 41#include "nfsfh.h"
41 42
@@ -83,7 +84,7 @@ struct nfsd4_callback_ops {
83 * fields that are of general use to any stateid. 84 * fields that are of general use to any stateid.
84 */ 85 */
85struct nfs4_stid { 86struct nfs4_stid {
86 atomic_t sc_count; 87 refcount_t sc_count;
87#define NFS4_OPEN_STID 1 88#define NFS4_OPEN_STID 1
88#define NFS4_LOCK_STID 2 89#define NFS4_LOCK_STID 2
89#define NFS4_DELEG_STID 4 90#define NFS4_DELEG_STID 4