aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2011-08-22 13:13:31 -0400
committerJ. Bruce Fields <bfields@redhat.com>2011-08-27 14:21:28 -0400
commitb34f27aa5da75b0b6c054e76bb4b92aea7aac04b (patch)
tree8a60d74b5bd0ece4e6995f98b9e7a9cf26cf8892 /fs/nfsd
parent9afb978400e65ea6a3200b3e163606ce86e13c25 (diff)
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>
Diffstat (limited to 'fs/nfsd')
-rw-r--r--fs/nfsd/nfs4state.c49
1 files changed, 20 insertions, 29 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index aafc41a0a8d0..d2bf80d8d85b 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -3396,7 +3396,7 @@ static __be32
3396nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid, 3396nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid,
3397 stateid_t *stateid, int flags, 3397 stateid_t *stateid, int flags,
3398 struct nfs4_stateowner **sopp, 3398 struct nfs4_stateowner **sopp,
3399 struct nfs4_stateid **stpp, struct nfsd4_lock *lock) 3399 struct nfs4_stateid **stpp)
3400{ 3400{
3401 struct nfs4_stateid *stp; 3401 struct nfs4_stateid *stp;
3402 struct nfs4_stateowner *sop; 3402 struct nfs4_stateowner *sop;
@@ -3439,27 +3439,6 @@ nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid,
3439 *stpp = stp; 3439 *stpp = stp;
3440 *sopp = sop = stp->st_stateowner; 3440 *sopp = sop = stp->st_stateowner;
3441 3441
3442 if (lock) {
3443 clientid_t *lockclid = &lock->v.new.clientid;
3444 struct nfs4_client *clp = sop->so_client;
3445 int lkflg = 0;
3446 __be32 status;
3447
3448 lkflg = setlkflg(lock->lk_type);
3449
3450 if (lock->lk_is_new) {
3451 if (!sop->so_is_open_owner)
3452 return nfserr_bad_stateid;
3453 if (!nfsd4_has_session(cstate) &&
3454 !same_clid(&clp->cl_clientid, lockclid))
3455 return nfserr_bad_stateid;
3456 }
3457 /* stp is the open stateid */
3458 status = nfs4_check_openmode(stp, lkflg);
3459 if (status)
3460 return status;
3461 }
3462
3463 if (nfs4_check_fh(current_fh, stp)) { 3442 if (nfs4_check_fh(current_fh, stp)) {
3464 dprintk("NFSD: preprocess_seqid_op: fh-stateid mismatch!\n"); 3443 dprintk("NFSD: preprocess_seqid_op: fh-stateid mismatch!\n");
3465 return nfserr_bad_stateid; 3444 return nfserr_bad_stateid;
@@ -3522,7 +3501,7 @@ nfsd4_open_confirm(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3522 if ((status = nfs4_preprocess_seqid_op(cstate, 3501 if ((status = nfs4_preprocess_seqid_op(cstate,
3523 oc->oc_seqid, &oc->oc_req_stateid, 3502 oc->oc_seqid, &oc->oc_req_stateid,
3524 CONFIRM | OPEN_STATE, 3503 CONFIRM | OPEN_STATE,
3525 &oc->oc_stateowner, &stp, NULL))) 3504 &oc->oc_stateowner, &stp)))
3526 goto out; 3505 goto out;
3527 3506
3528 sop = oc->oc_stateowner; 3507 sop = oc->oc_stateowner;
@@ -3585,7 +3564,7 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp,
3585 od->od_seqid, 3564 od->od_seqid,
3586 &od->od_stateid, 3565 &od->od_stateid,
3587 OPEN_STATE, 3566 OPEN_STATE,
3588 &od->od_stateowner, &stp, NULL))) 3567 &od->od_stateowner, &stp)))
3589 goto out; 3568 goto out;
3590 3569
3591 status = nfserr_inval; 3570 status = nfserr_inval;
@@ -3635,7 +3614,7 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3635 close->cl_seqid, 3614 close->cl_seqid,
3636 &close->cl_stateid, 3615 &close->cl_stateid,
3637 OPEN_STATE | CLOSE_STATE, 3616 OPEN_STATE | CLOSE_STATE,
3638 &close->cl_stateowner, &stp, NULL))) 3617 &close->cl_stateowner, &stp)))
3639 goto out; 3618 goto out;
3640 status = nfs_ok; 3619 status = nfs_ok;
3641 update_stateid(&stp->st_stateid); 3620 update_stateid(&stp->st_stateid);
@@ -3997,6 +3976,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3997 struct file_lock conflock; 3976 struct file_lock conflock;
3998 __be32 status = 0; 3977 __be32 status = 0;
3999 unsigned int strhashval; 3978 unsigned int strhashval;
3979 int lkflg;
4000 int err; 3980 int err;
4001 3981
4002 dprintk("NFSD: nfsd4_lock: start=%Ld length=%Ld\n", 3982 dprintk("NFSD: nfsd4_lock: start=%Ld length=%Ld\n",
@@ -4032,11 +4012,17 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
4032 lock->lk_new_open_seqid, 4012 lock->lk_new_open_seqid,
4033 &lock->lk_new_open_stateid, 4013 &lock->lk_new_open_stateid,
4034 OPEN_STATE, 4014 OPEN_STATE,
4035 &lock->lk_replay_owner, &open_stp, 4015 &lock->lk_replay_owner, &open_stp);
4036 lock);
4037 if (status) 4016 if (status)
4038 goto out; 4017 goto out;
4018 status = nfserr_bad_stateid;
4039 open_sop = lock->lk_replay_owner; 4019 open_sop = lock->lk_replay_owner;
4020 if (!open_sop->so_is_open_owner)
4021 goto out;
4022 if (!nfsd4_has_session(cstate) &&
4023 !same_clid(&open_sop->so_client->cl_clientid,
4024 &lock->v.new.clientid))
4025 goto out;
4040 /* create lockowner and lock stateid */ 4026 /* create lockowner and lock stateid */
4041 fp = open_stp->st_file; 4027 fp = open_stp->st_file;
4042 strhashval = lock_ownerstr_hashval(fp->fi_inode, 4028 strhashval = lock_ownerstr_hashval(fp->fi_inode,
@@ -4059,7 +4045,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
4059 lock->lk_old_lock_seqid, 4045 lock->lk_old_lock_seqid,
4060 &lock->lk_old_lock_stateid, 4046 &lock->lk_old_lock_stateid,
4061 LOCK_STATE, 4047 LOCK_STATE,
4062 &lock->lk_replay_owner, &lock_stp, lock); 4048 &lock->lk_replay_owner, &lock_stp);
4063 if (status) 4049 if (status)
4064 goto out; 4050 goto out;
4065 lock_sop = lock->lk_replay_owner; 4051 lock_sop = lock->lk_replay_owner;
@@ -4067,6 +4053,11 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
4067 } 4053 }
4068 /* lock->lk_replay_owner and lock_stp have been created or found */ 4054 /* lock->lk_replay_owner and lock_stp have been created or found */
4069 4055
4056 lkflg = setlkflg(lock->lk_type);
4057 status = nfs4_check_openmode(lock_stp, lkflg);
4058 if (status)
4059 goto out;
4060
4070 status = nfserr_grace; 4061 status = nfserr_grace;
4071 if (locks_in_grace() && !lock->lk_reclaim) 4062 if (locks_in_grace() && !lock->lk_reclaim)
4072 goto out; 4063 goto out;
@@ -4259,7 +4250,7 @@ nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
4259 locku->lu_seqid, 4250 locku->lu_seqid,
4260 &locku->lu_stateid, 4251 &locku->lu_stateid,
4261 LOCK_STATE, 4252 LOCK_STATE,
4262 &locku->lu_stateowner, &stp, NULL))) 4253 &locku->lu_stateowner, &stp)))
4263 goto out; 4254 goto out;
4264 4255
4265 filp = find_any_file(stp->st_file); 4256 filp = find_any_file(stp->st_file);