diff options
author | Kinglong Mee <kinglongmee@gmail.com> | 2014-08-22 10:18:43 -0400 |
---|---|---|
committer | Jeff Layton <jlayton@primarydata.com> | 2014-09-09 16:01:09 -0400 |
commit | b5971afa0b33361667bc88f3e0eb3fc31f778dc6 (patch) | |
tree | deb8e090da1f112b6fd98ab0bd49cf3f25f77718 /fs/nfsd | |
parent | f328296e27414394f25cebaef4a111a82ce0df32 (diff) |
NFSD: New helper nfs4_get_stateowner() for atomic_inc sop reference
v5: same as the first version
Reviewed-by: Jeff Layton <jlayton@primarydata.com>
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jeff Layton <jlayton@primarydata.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/nfs4state.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index e773036b03d0..2d03a4188671 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -216,6 +216,13 @@ static void nfsd4_put_session(struct nfsd4_session *ses) | |||
216 | spin_unlock(&nn->client_lock); | 216 | spin_unlock(&nn->client_lock); |
217 | } | 217 | } |
218 | 218 | ||
219 | static inline struct nfs4_stateowner * | ||
220 | nfs4_get_stateowner(struct nfs4_stateowner *sop) | ||
221 | { | ||
222 | atomic_inc(&sop->so_count); | ||
223 | return sop; | ||
224 | } | ||
225 | |||
219 | static int | 226 | static int |
220 | same_owner_str(struct nfs4_stateowner *sop, struct xdr_netobj *owner) | 227 | same_owner_str(struct nfs4_stateowner *sop, struct xdr_netobj *owner) |
221 | { | 228 | { |
@@ -235,10 +242,8 @@ find_openstateowner_str_locked(unsigned int hashval, struct nfsd4_open *open, | |||
235 | so_strhash) { | 242 | so_strhash) { |
236 | if (!so->so_is_open_owner) | 243 | if (!so->so_is_open_owner) |
237 | continue; | 244 | continue; |
238 | if (same_owner_str(so, &open->op_owner)) { | 245 | if (same_owner_str(so, &open->op_owner)) |
239 | atomic_inc(&so->so_count); | 246 | return openowner(nfs4_get_stateowner(so)); |
240 | return openowner(so); | ||
241 | } | ||
242 | } | 247 | } |
243 | return NULL; | 248 | return NULL; |
244 | } | 249 | } |
@@ -1651,7 +1656,7 @@ __destroy_client(struct nfs4_client *clp) | |||
1651 | } | 1656 | } |
1652 | while (!list_empty(&clp->cl_openowners)) { | 1657 | while (!list_empty(&clp->cl_openowners)) { |
1653 | oo = list_entry(clp->cl_openowners.next, struct nfs4_openowner, oo_perclient); | 1658 | oo = list_entry(clp->cl_openowners.next, struct nfs4_openowner, oo_perclient); |
1654 | atomic_inc(&oo->oo_owner.so_count); | 1659 | nfs4_get_stateowner(&oo->oo_owner); |
1655 | release_openowner(oo); | 1660 | release_openowner(oo); |
1656 | } | 1661 | } |
1657 | nfsd4_shutdown_callback(clp); | 1662 | nfsd4_shutdown_callback(clp); |
@@ -3132,8 +3137,7 @@ static void nfsd4_cstate_assign_replay(struct nfsd4_compound_state *cstate, | |||
3132 | { | 3137 | { |
3133 | if (!nfsd4_has_session(cstate)) { | 3138 | if (!nfsd4_has_session(cstate)) { |
3134 | mutex_lock(&so->so_replay.rp_mutex); | 3139 | mutex_lock(&so->so_replay.rp_mutex); |
3135 | cstate->replay_owner = so; | 3140 | cstate->replay_owner = nfs4_get_stateowner(so); |
3136 | atomic_inc(&so->so_count); | ||
3137 | } | 3141 | } |
3138 | } | 3142 | } |
3139 | 3143 | ||
@@ -3232,8 +3236,7 @@ static void init_open_stateid(struct nfs4_ol_stateid *stp, struct nfs4_file *fp, | |||
3232 | atomic_inc(&stp->st_stid.sc_count); | 3236 | atomic_inc(&stp->st_stid.sc_count); |
3233 | stp->st_stid.sc_type = NFS4_OPEN_STID; | 3237 | stp->st_stid.sc_type = NFS4_OPEN_STID; |
3234 | INIT_LIST_HEAD(&stp->st_locks); | 3238 | INIT_LIST_HEAD(&stp->st_locks); |
3235 | stp->st_stateowner = &oo->oo_owner; | 3239 | stp->st_stateowner = nfs4_get_stateowner(&oo->oo_owner); |
3236 | atomic_inc(&stp->st_stateowner->so_count); | ||
3237 | get_nfs4_file(fp); | 3240 | get_nfs4_file(fp); |
3238 | stp->st_stid.sc_file = fp; | 3241 | stp->st_stid.sc_file = fp; |
3239 | stp->st_access_bmap = 0; | 3242 | stp->st_access_bmap = 0; |
@@ -4921,10 +4924,8 @@ find_lockowner_str_locked(clientid_t *clid, struct xdr_netobj *owner, | |||
4921 | so_strhash) { | 4924 | so_strhash) { |
4922 | if (so->so_is_open_owner) | 4925 | if (so->so_is_open_owner) |
4923 | continue; | 4926 | continue; |
4924 | if (!same_owner_str(so, owner)) | 4927 | if (same_owner_str(so, owner)) |
4925 | continue; | 4928 | return lockowner(nfs4_get_stateowner(so)); |
4926 | atomic_inc(&so->so_count); | ||
4927 | return lockowner(so); | ||
4928 | } | 4929 | } |
4929 | return NULL; | 4930 | return NULL; |
4930 | } | 4931 | } |
@@ -5003,8 +5004,7 @@ init_lock_stateid(struct nfs4_ol_stateid *stp, struct nfs4_lockowner *lo, | |||
5003 | 5004 | ||
5004 | atomic_inc(&stp->st_stid.sc_count); | 5005 | atomic_inc(&stp->st_stid.sc_count); |
5005 | stp->st_stid.sc_type = NFS4_LOCK_STID; | 5006 | stp->st_stid.sc_type = NFS4_LOCK_STID; |
5006 | stp->st_stateowner = &lo->lo_owner; | 5007 | stp->st_stateowner = nfs4_get_stateowner(&lo->lo_owner); |
5007 | atomic_inc(&lo->lo_owner.so_count); | ||
5008 | get_nfs4_file(fp); | 5008 | get_nfs4_file(fp); |
5009 | stp->st_stid.sc_file = fp; | 5009 | stp->st_stid.sc_file = fp; |
5010 | stp->st_stid.sc_free = nfs4_free_lock_stateid; | 5010 | stp->st_stid.sc_free = nfs4_free_lock_stateid; |
@@ -5546,7 +5546,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, | |||
5546 | } | 5546 | } |
5547 | } | 5547 | } |
5548 | 5548 | ||
5549 | atomic_inc(&sop->so_count); | 5549 | nfs4_get_stateowner(sop); |
5550 | break; | 5550 | break; |
5551 | } | 5551 | } |
5552 | spin_unlock(&clp->cl_lock); | 5552 | spin_unlock(&clp->cl_lock); |