2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-15 08:44:14 +08:00

nfsd4: get lock checks out of preprocess_seqid_op

We've got some lock-specific code here in nfs4_preprocess_seqid_op which
is only used by nfsd4_lock().  Move it to the caller.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
This commit is contained in:
J. Bruce Fields 2011-08-22 13:13:31 -04:00
parent 9afb978400
commit b34f27aa5d

View File

@ -3396,7 +3396,7 @@ static __be32
nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid, nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid,
stateid_t *stateid, int flags, stateid_t *stateid, int flags,
struct nfs4_stateowner **sopp, struct nfs4_stateowner **sopp,
struct nfs4_stateid **stpp, struct nfsd4_lock *lock) struct nfs4_stateid **stpp)
{ {
struct nfs4_stateid *stp; struct nfs4_stateid *stp;
struct nfs4_stateowner *sop; struct nfs4_stateowner *sop;
@ -3439,27 +3439,6 @@ nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid,
*stpp = stp; *stpp = stp;
*sopp = sop = stp->st_stateowner; *sopp = sop = stp->st_stateowner;
if (lock) {
clientid_t *lockclid = &lock->v.new.clientid;
struct nfs4_client *clp = sop->so_client;
int lkflg = 0;
__be32 status;
lkflg = setlkflg(lock->lk_type);
if (lock->lk_is_new) {
if (!sop->so_is_open_owner)
return nfserr_bad_stateid;
if (!nfsd4_has_session(cstate) &&
!same_clid(&clp->cl_clientid, lockclid))
return nfserr_bad_stateid;
}
/* stp is the open stateid */
status = nfs4_check_openmode(stp, lkflg);
if (status)
return status;
}
if (nfs4_check_fh(current_fh, stp)) { if (nfs4_check_fh(current_fh, stp)) {
dprintk("NFSD: preprocess_seqid_op: fh-stateid mismatch!\n"); dprintk("NFSD: preprocess_seqid_op: fh-stateid mismatch!\n");
return nfserr_bad_stateid; return nfserr_bad_stateid;
@ -3522,7 +3501,7 @@ nfsd4_open_confirm(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
if ((status = nfs4_preprocess_seqid_op(cstate, if ((status = nfs4_preprocess_seqid_op(cstate,
oc->oc_seqid, &oc->oc_req_stateid, oc->oc_seqid, &oc->oc_req_stateid,
CONFIRM | OPEN_STATE, CONFIRM | OPEN_STATE,
&oc->oc_stateowner, &stp, NULL))) &oc->oc_stateowner, &stp)))
goto out; goto out;
sop = oc->oc_stateowner; sop = oc->oc_stateowner;
@ -3585,7 +3564,7 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp,
od->od_seqid, od->od_seqid,
&od->od_stateid, &od->od_stateid,
OPEN_STATE, OPEN_STATE,
&od->od_stateowner, &stp, NULL))) &od->od_stateowner, &stp)))
goto out; goto out;
status = nfserr_inval; status = nfserr_inval;
@ -3635,7 +3614,7 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
close->cl_seqid, close->cl_seqid,
&close->cl_stateid, &close->cl_stateid,
OPEN_STATE | CLOSE_STATE, OPEN_STATE | CLOSE_STATE,
&close->cl_stateowner, &stp, NULL))) &close->cl_stateowner, &stp)))
goto out; goto out;
status = nfs_ok; status = nfs_ok;
update_stateid(&stp->st_stateid); update_stateid(&stp->st_stateid);
@ -3997,6 +3976,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
struct file_lock conflock; struct file_lock conflock;
__be32 status = 0; __be32 status = 0;
unsigned int strhashval; unsigned int strhashval;
int lkflg;
int err; int err;
dprintk("NFSD: nfsd4_lock: start=%Ld length=%Ld\n", dprintk("NFSD: nfsd4_lock: start=%Ld length=%Ld\n",
@ -4032,11 +4012,17 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
lock->lk_new_open_seqid, lock->lk_new_open_seqid,
&lock->lk_new_open_stateid, &lock->lk_new_open_stateid,
OPEN_STATE, OPEN_STATE,
&lock->lk_replay_owner, &open_stp, &lock->lk_replay_owner, &open_stp);
lock);
if (status) if (status)
goto out; goto out;
status = nfserr_bad_stateid;
open_sop = lock->lk_replay_owner; open_sop = lock->lk_replay_owner;
if (!open_sop->so_is_open_owner)
goto out;
if (!nfsd4_has_session(cstate) &&
!same_clid(&open_sop->so_client->cl_clientid,
&lock->v.new.clientid))
goto out;
/* create lockowner and lock stateid */ /* create lockowner and lock stateid */
fp = open_stp->st_file; fp = open_stp->st_file;
strhashval = lock_ownerstr_hashval(fp->fi_inode, strhashval = lock_ownerstr_hashval(fp->fi_inode,
@ -4059,7 +4045,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
lock->lk_old_lock_seqid, lock->lk_old_lock_seqid,
&lock->lk_old_lock_stateid, &lock->lk_old_lock_stateid,
LOCK_STATE, LOCK_STATE,
&lock->lk_replay_owner, &lock_stp, lock); &lock->lk_replay_owner, &lock_stp);
if (status) if (status)
goto out; goto out;
lock_sop = lock->lk_replay_owner; lock_sop = lock->lk_replay_owner;
@ -4067,6 +4053,11 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
} }
/* lock->lk_replay_owner and lock_stp have been created or found */ /* lock->lk_replay_owner and lock_stp have been created or found */
lkflg = setlkflg(lock->lk_type);
status = nfs4_check_openmode(lock_stp, lkflg);
if (status)
goto out;
status = nfserr_grace; status = nfserr_grace;
if (locks_in_grace() && !lock->lk_reclaim) if (locks_in_grace() && !lock->lk_reclaim)
goto out; goto out;
@ -4259,7 +4250,7 @@ nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
locku->lu_seqid, locku->lu_seqid,
&locku->lu_stateid, &locku->lu_stateid,
LOCK_STATE, LOCK_STATE,
&locku->lu_stateowner, &stp, NULL))) &locku->lu_stateowner, &stp)))
goto out; goto out;
filp = find_any_file(stp->st_file); filp = find_any_file(stp->st_file);