mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 20:20:50 +07:00
nfsd: Add reference counting to lock stateids
Ensure that nfsd4_lock() references the lock stateid while it is manipulating it. Not currently necessary, but will be once the client_mutex is removed. Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
This commit is contained in:
parent
1af71cc801
commit
3d0fabd5a4
@ -4729,6 +4729,7 @@ init_lock_stateid(struct nfs4_ol_stateid *stp, struct nfs4_lockowner *lo,
|
|||||||
|
|
||||||
lockdep_assert_held(&clp->cl_lock);
|
lockdep_assert_held(&clp->cl_lock);
|
||||||
|
|
||||||
|
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 = &lo->lo_owner;
|
||||||
get_nfs4_file(fp);
|
get_nfs4_file(fp);
|
||||||
@ -4753,8 +4754,10 @@ find_lock_stateid(struct nfs4_lockowner *lo, struct nfs4_file *fp)
|
|||||||
lockdep_assert_held(&clp->cl_lock);
|
lockdep_assert_held(&clp->cl_lock);
|
||||||
|
|
||||||
list_for_each_entry(lst, &lo->lo_owner.so_stateids, st_perstateowner) {
|
list_for_each_entry(lst, &lo->lo_owner.so_stateids, st_perstateowner) {
|
||||||
if (lst->st_stid.sc_file == fp)
|
if (lst->st_stid.sc_file == fp) {
|
||||||
|
atomic_inc(&lst->st_stid.sc_count);
|
||||||
return lst;
|
return lst;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -4856,7 +4859,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
|||||||
{
|
{
|
||||||
struct nfs4_openowner *open_sop = NULL;
|
struct nfs4_openowner *open_sop = NULL;
|
||||||
struct nfs4_lockowner *lock_sop = NULL;
|
struct nfs4_lockowner *lock_sop = NULL;
|
||||||
struct nfs4_ol_stateid *lock_stp;
|
struct nfs4_ol_stateid *lock_stp = NULL;
|
||||||
struct nfs4_file *fp;
|
struct nfs4_file *fp;
|
||||||
struct file *filp = NULL;
|
struct file *filp = NULL;
|
||||||
struct file_lock *file_lock = NULL;
|
struct file_lock *file_lock = NULL;
|
||||||
@ -4910,11 +4913,15 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
|||||||
goto out;
|
goto out;
|
||||||
status = lookup_or_create_lock_state(cstate, open_stp, lock,
|
status = lookup_or_create_lock_state(cstate, open_stp, lock,
|
||||||
&lock_stp, &new_state);
|
&lock_stp, &new_state);
|
||||||
} else
|
} else {
|
||||||
status = nfs4_preprocess_seqid_op(cstate,
|
status = nfs4_preprocess_seqid_op(cstate,
|
||||||
lock->lk_old_lock_seqid,
|
lock->lk_old_lock_seqid,
|
||||||
&lock->lk_old_lock_stateid,
|
&lock->lk_old_lock_stateid,
|
||||||
NFS4_LOCK_STID, &lock_stp, nn);
|
NFS4_LOCK_STID, &lock_stp, nn);
|
||||||
|
/* FIXME: move into nfs4_preprocess_seqid_op */
|
||||||
|
if (!status)
|
||||||
|
atomic_inc(&lock_stp->st_stid.sc_count);
|
||||||
|
}
|
||||||
if (status)
|
if (status)
|
||||||
goto out;
|
goto out;
|
||||||
lock_sop = lockowner(lock_stp->st_stateowner);
|
lock_sop = lockowner(lock_stp->st_stateowner);
|
||||||
@ -5007,6 +5014,8 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
|
|||||||
out:
|
out:
|
||||||
if (filp)
|
if (filp)
|
||||||
fput(filp);
|
fput(filp);
|
||||||
|
if (lock_stp)
|
||||||
|
nfs4_put_stid(&lock_stp->st_stid);
|
||||||
if (status && new_state)
|
if (status && new_state)
|
||||||
release_lock_stateid(lock_stp);
|
release_lock_stateid(lock_stp);
|
||||||
nfsd4_bump_seqid(cstate, status);
|
nfsd4_bump_seqid(cstate, status);
|
||||||
|
Loading…
Reference in New Issue
Block a user