aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4state.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfsd/nfs4state.c')
-rw-r--r--fs/nfsd/nfs4state.c57
1 files changed, 24 insertions, 33 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index e4535ff92876..bc1a9dbc289c 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -3388,7 +3388,6 @@ setlkflg (int type)
3388static __be32 3388static __be32
3389nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid, 3389nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid,
3390 stateid_t *stateid, int flags, 3390 stateid_t *stateid, int flags,
3391 struct nfs4_stateowner **sopp,
3392 struct nfs4_stateid **stpp) 3391 struct nfs4_stateid **stpp)
3393{ 3392{
3394 struct nfs4_stateid *stp; 3393 struct nfs4_stateid *stp;
@@ -3400,7 +3399,6 @@ nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid,
3400 seqid, STATEID_VAL(stateid)); 3399 seqid, STATEID_VAL(stateid));
3401 3400
3402 *stpp = NULL; 3401 *stpp = NULL;
3403 *sopp = NULL;
3404 3402
3405 if (ZERO_STATEID(stateid) || ONE_STATEID(stateid)) { 3403 if (ZERO_STATEID(stateid) || ONE_STATEID(stateid)) {
3406 dprintk("NFSD: preprocess_seqid_op: magic stateid!\n"); 3404 dprintk("NFSD: preprocess_seqid_op: magic stateid!\n");
@@ -3431,7 +3429,7 @@ nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid,
3431 } 3429 }
3432 3430
3433 *stpp = stp; 3431 *stpp = stp;
3434 *sopp = sop = stp->st_stateowner; 3432 sop = stp->st_stateowner;
3435 nfs4_get_stateowner(sop); 3433 nfs4_get_stateowner(sop);
3436 cstate->replay_owner = sop; 3434 cstate->replay_owner = sop;
3437 3435
@@ -3467,7 +3465,6 @@ check_replay:
3467 } 3465 }
3468 dprintk("NFSD: preprocess_seqid_op: bad seqid (expected %d, got %d)\n", 3466 dprintk("NFSD: preprocess_seqid_op: bad seqid (expected %d, got %d)\n",
3469 sop->so_seqid, seqid); 3467 sop->so_seqid, seqid);
3470 *sopp = NULL;
3471 return nfserr_bad_seqid; 3468 return nfserr_bad_seqid;
3472} 3469}
3473 3470
@@ -3489,13 +3486,13 @@ nfsd4_open_confirm(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3489 3486
3490 nfs4_lock_state(); 3487 nfs4_lock_state();
3491 3488
3492 if ((status = nfs4_preprocess_seqid_op(cstate, 3489 status = nfs4_preprocess_seqid_op(cstate,
3493 oc->oc_seqid, &oc->oc_req_stateid, 3490 oc->oc_seqid, &oc->oc_req_stateid,
3494 CONFIRM | OPEN_STATE, 3491 CONFIRM | OPEN_STATE, &stp);
3495 &oc->oc_stateowner, &stp))) 3492 if (status)
3496 goto out; 3493 goto out;
3497 3494
3498 sop = oc->oc_stateowner; 3495 sop = stp->st_stateowner;
3499 sop->so_confirmed = 1; 3496 sop->so_confirmed = 1;
3500 update_stateid(&stp->st_stateid); 3497 update_stateid(&stp->st_stateid);
3501 memcpy(&oc->oc_resp_stateid, &stp->st_stateid, sizeof(stateid_t)); 3498 memcpy(&oc->oc_resp_stateid, &stp->st_stateid, sizeof(stateid_t));
@@ -3547,11 +3544,9 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp,
3547 return nfserr_inval; 3544 return nfserr_inval;
3548 3545
3549 nfs4_lock_state(); 3546 nfs4_lock_state();
3550 if ((status = nfs4_preprocess_seqid_op(cstate, 3547 status = nfs4_preprocess_seqid_op(cstate, od->od_seqid,
3551 od->od_seqid, 3548 &od->od_stateid, OPEN_STATE, &stp);
3552 &od->od_stateid, 3549 if (status)
3553 OPEN_STATE,
3554 &od->od_stateowner, &stp)))
3555 goto out; 3550 goto out;
3556 3551
3557 status = nfserr_inval; 3552 status = nfserr_inval;
@@ -3586,6 +3581,7 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3586{ 3581{
3587 __be32 status; 3582 __be32 status;
3588 struct nfs4_stateid *stp; 3583 struct nfs4_stateid *stp;
3584 struct nfs4_stateowner *so;
3589 3585
3590 dprintk("NFSD: nfsd4_close on file %.*s\n", 3586 dprintk("NFSD: nfsd4_close on file %.*s\n",
3591 (int)cstate->current_fh.fh_dentry->d_name.len, 3587 (int)cstate->current_fh.fh_dentry->d_name.len,
@@ -3593,12 +3589,12 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3593 3589
3594 nfs4_lock_state(); 3590 nfs4_lock_state();
3595 /* check close_lru for replay */ 3591 /* check close_lru for replay */
3596 if ((status = nfs4_preprocess_seqid_op(cstate, 3592 status = nfs4_preprocess_seqid_op(cstate, close->cl_seqid,
3597 close->cl_seqid,
3598 &close->cl_stateid, 3593 &close->cl_stateid,
3599 OPEN_STATE | CLOSE_STATE, 3594 OPEN_STATE | CLOSE_STATE, &stp);
3600 &close->cl_stateowner, &stp))) 3595 if (status)
3601 goto out; 3596 goto out;
3597 so = stp->st_stateowner;
3602 status = nfs_ok; 3598 status = nfs_ok;
3603 update_stateid(&stp->st_stateid); 3599 update_stateid(&stp->st_stateid);
3604 memcpy(&close->cl_stateid, &stp->st_stateid, sizeof(stateid_t)); 3600 memcpy(&close->cl_stateid, &stp->st_stateid, sizeof(stateid_t));
@@ -3610,8 +3606,8 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3610 * released by the laundromat service after the lease period 3606 * released by the laundromat service after the lease period
3611 * to enable us to handle CLOSE replay 3607 * to enable us to handle CLOSE replay
3612 */ 3608 */
3613 if (list_empty(&close->cl_stateowner->so_stateids)) 3609 if (list_empty(&so->so_stateids))
3614 move_to_close_lru(close->cl_stateowner); 3610 move_to_close_lru(so);
3615out: 3611out:
3616 nfs4_unlock_state(); 3612 nfs4_unlock_state();
3617 return status; 3613 return status;
@@ -3962,12 +3958,11 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3962 status = nfs4_preprocess_seqid_op(cstate, 3958 status = nfs4_preprocess_seqid_op(cstate,
3963 lock->lk_new_open_seqid, 3959 lock->lk_new_open_seqid,
3964 &lock->lk_new_open_stateid, 3960 &lock->lk_new_open_stateid,
3965 OPEN_STATE, 3961 OPEN_STATE, &open_stp);
3966 &lock->lk_replay_owner, &open_stp);
3967 if (status) 3962 if (status)
3968 goto out; 3963 goto out;
3969 status = nfserr_bad_stateid; 3964 status = nfserr_bad_stateid;
3970 open_sop = lock->lk_replay_owner; 3965 open_sop = open_stp->st_stateowner;
3971 if (!nfsd4_has_session(cstate) && 3966 if (!nfsd4_has_session(cstate) &&
3972 !same_clid(&open_sop->so_client->cl_clientid, 3967 !same_clid(&open_sop->so_client->cl_clientid,
3973 &lock->v.new.clientid)) 3968 &lock->v.new.clientid))
@@ -3993,14 +3988,13 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3993 status = nfs4_preprocess_seqid_op(cstate, 3988 status = nfs4_preprocess_seqid_op(cstate,
3994 lock->lk_old_lock_seqid, 3989 lock->lk_old_lock_seqid,
3995 &lock->lk_old_lock_stateid, 3990 &lock->lk_old_lock_stateid,
3996 LOCK_STATE, 3991 LOCK_STATE, &lock_stp);
3997 &lock->lk_replay_owner, &lock_stp);
3998 if (status) 3992 if (status)
3999 goto out; 3993 goto out;
4000 lock_sop = lock->lk_replay_owner; 3994 lock_sop = lock_stp->st_stateowner;
4001 fp = lock_stp->st_file; 3995 fp = lock_stp->st_file;
4002 } 3996 }
4003 /* lock->lk_replay_owner and lock_stp have been created or found */ 3997 /* lock_sop and lock_stp have been created or found */
4004 3998
4005 lkflg = setlkflg(lock->lk_type); 3999 lkflg = setlkflg(lock->lk_type);
4006 status = nfs4_check_openmode(lock_stp, lkflg); 4000 status = nfs4_check_openmode(lock_stp, lkflg);
@@ -4191,13 +4185,10 @@ nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
4191 4185
4192 nfs4_lock_state(); 4186 nfs4_lock_state();
4193 4187
4194 if ((status = nfs4_preprocess_seqid_op(cstate, 4188 status = nfs4_preprocess_seqid_op(cstate, locku->lu_seqid,
4195 locku->lu_seqid, 4189 &locku->lu_stateid, LOCK_STATE, &stp);
4196 &locku->lu_stateid, 4190 if (status)
4197 LOCK_STATE,
4198 &locku->lu_stateowner, &stp)))
4199 goto out; 4191 goto out;
4200
4201 filp = find_any_file(stp->st_file); 4192 filp = find_any_file(stp->st_file);
4202 if (!filp) { 4193 if (!filp) {
4203 status = nfserr_lock_range; 4194 status = nfserr_lock_range;
@@ -4206,7 +4197,7 @@ nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
4206 BUG_ON(!filp); 4197 BUG_ON(!filp);
4207 locks_init_lock(&file_lock); 4198 locks_init_lock(&file_lock);
4208 file_lock.fl_type = F_UNLCK; 4199 file_lock.fl_type = F_UNLCK;
4209 file_lock.fl_owner = (fl_owner_t) locku->lu_stateowner; 4200 file_lock.fl_owner = (fl_owner_t) stp->st_stateowner;
4210 file_lock.fl_pid = current->tgid; 4201 file_lock.fl_pid = current->tgid;
4211 file_lock.fl_file = filp; 4202 file_lock.fl_file = filp;
4212 file_lock.fl_flags = FL_POSIX; 4203 file_lock.fl_flags = FL_POSIX;