Commit b5971afa authored by Kinglong Mee's avatar Kinglong Mee Committed by Jeff Layton

NFSD: New helper nfs4_get_stateowner() for atomic_inc sop reference

v5: same as the first version
Reviewed-by: default avatarJeff Layton <jlayton@primarydata.com>
Signed-off-by: default avatarKinglong Mee <kinglongmee@gmail.com>
Signed-off-by: default avatarJeff Layton <jlayton@primarydata.com>
parent f328296e
...@@ -216,6 +216,13 @@ static void nfsd4_put_session(struct nfsd4_session *ses) ...@@ -216,6 +216,13 @@ static void nfsd4_put_session(struct nfsd4_session *ses)
spin_unlock(&nn->client_lock); spin_unlock(&nn->client_lock);
} }
static inline struct nfs4_stateowner *
nfs4_get_stateowner(struct nfs4_stateowner *sop)
{
atomic_inc(&sop->so_count);
return sop;
}
static int static int
same_owner_str(struct nfs4_stateowner *sop, struct xdr_netobj *owner) same_owner_str(struct nfs4_stateowner *sop, struct xdr_netobj *owner)
{ {
...@@ -235,10 +242,8 @@ find_openstateowner_str_locked(unsigned int hashval, struct nfsd4_open *open, ...@@ -235,10 +242,8 @@ find_openstateowner_str_locked(unsigned int hashval, struct nfsd4_open *open,
so_strhash) { so_strhash) {
if (!so->so_is_open_owner) if (!so->so_is_open_owner)
continue; continue;
if (same_owner_str(so, &open->op_owner)) { if (same_owner_str(so, &open->op_owner))
atomic_inc(&so->so_count); return openowner(nfs4_get_stateowner(so));
return openowner(so);
}
} }
return NULL; return NULL;
} }
...@@ -1651,7 +1656,7 @@ __destroy_client(struct nfs4_client *clp) ...@@ -1651,7 +1656,7 @@ __destroy_client(struct nfs4_client *clp)
} }
while (!list_empty(&clp->cl_openowners)) { while (!list_empty(&clp->cl_openowners)) {
oo = list_entry(clp->cl_openowners.next, struct nfs4_openowner, oo_perclient); oo = list_entry(clp->cl_openowners.next, struct nfs4_openowner, oo_perclient);
atomic_inc(&oo->oo_owner.so_count); nfs4_get_stateowner(&oo->oo_owner);
release_openowner(oo); release_openowner(oo);
} }
nfsd4_shutdown_callback(clp); nfsd4_shutdown_callback(clp);
...@@ -3132,8 +3137,7 @@ static void nfsd4_cstate_assign_replay(struct nfsd4_compound_state *cstate, ...@@ -3132,8 +3137,7 @@ static void nfsd4_cstate_assign_replay(struct nfsd4_compound_state *cstate,
{ {
if (!nfsd4_has_session(cstate)) { if (!nfsd4_has_session(cstate)) {
mutex_lock(&so->so_replay.rp_mutex); mutex_lock(&so->so_replay.rp_mutex);
cstate->replay_owner = so; cstate->replay_owner = nfs4_get_stateowner(so);
atomic_inc(&so->so_count);
} }
} }
...@@ -3232,8 +3236,7 @@ static void init_open_stateid(struct nfs4_ol_stateid *stp, struct nfs4_file *fp, ...@@ -3232,8 +3236,7 @@ static void init_open_stateid(struct nfs4_ol_stateid *stp, struct nfs4_file *fp,
atomic_inc(&stp->st_stid.sc_count); atomic_inc(&stp->st_stid.sc_count);
stp->st_stid.sc_type = NFS4_OPEN_STID; stp->st_stid.sc_type = NFS4_OPEN_STID;
INIT_LIST_HEAD(&stp->st_locks); INIT_LIST_HEAD(&stp->st_locks);
stp->st_stateowner = &oo->oo_owner; stp->st_stateowner = nfs4_get_stateowner(&oo->oo_owner);
atomic_inc(&stp->st_stateowner->so_count);
get_nfs4_file(fp); get_nfs4_file(fp);
stp->st_stid.sc_file = fp; stp->st_stid.sc_file = fp;
stp->st_access_bmap = 0; stp->st_access_bmap = 0;
...@@ -4921,10 +4924,8 @@ find_lockowner_str_locked(clientid_t *clid, struct xdr_netobj *owner, ...@@ -4921,10 +4924,8 @@ find_lockowner_str_locked(clientid_t *clid, struct xdr_netobj *owner,
so_strhash) { so_strhash) {
if (so->so_is_open_owner) if (so->so_is_open_owner)
continue; continue;
if (!same_owner_str(so, owner)) if (same_owner_str(so, owner))
continue; return lockowner(nfs4_get_stateowner(so));
atomic_inc(&so->so_count);
return lockowner(so);
} }
return NULL; return NULL;
} }
...@@ -5003,8 +5004,7 @@ init_lock_stateid(struct nfs4_ol_stateid *stp, struct nfs4_lockowner *lo, ...@@ -5003,8 +5004,7 @@ init_lock_stateid(struct nfs4_ol_stateid *stp, struct nfs4_lockowner *lo,
atomic_inc(&stp->st_stid.sc_count); atomic_inc(&stp->st_stid.sc_count);
stp->st_stid.sc_type = NFS4_LOCK_STID; stp->st_stid.sc_type = NFS4_LOCK_STID;
stp->st_stateowner = &lo->lo_owner; stp->st_stateowner = nfs4_get_stateowner(&lo->lo_owner);
atomic_inc(&lo->lo_owner.so_count);
get_nfs4_file(fp); get_nfs4_file(fp);
stp->st_stid.sc_file = fp; stp->st_stid.sc_file = fp;
stp->st_stid.sc_free = nfs4_free_lock_stateid; stp->st_stid.sc_free = nfs4_free_lock_stateid;
...@@ -5546,7 +5546,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, ...@@ -5546,7 +5546,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp,
} }
} }
atomic_inc(&sop->so_count); nfs4_get_stateowner(sop);
break; break;
} }
spin_unlock(&clp->cl_lock); spin_unlock(&clp->cl_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment