aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4state.c
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@primarydata.com>2014-04-18 14:44:07 -0400
committerJ. Bruce Fields <bfields@redhat.com>2014-05-07 11:05:48 -0400
commit14bcab1a395b1b150e654100cce09a1b552ec5f1 (patch)
tree709b87c167c18c446b5ad73dacb11f80aabe6e3c /fs/nfsd/nfs4state.c
parent50cc62317dece5173b56aa8d3569930b065ce47d (diff)
NFSd: Clean up nfs4_preprocess_stateid_op
Move the state locking and file descriptor reference out from the callers and into nfs4_preprocess_stateid_op() itself. Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4state.c')
-rw-r--r--fs/nfsd/nfs4state.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index fcab9091f094..b5278941f3a1 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -3654,6 +3654,7 @@ nfs4_preprocess_stateid_op(struct net *net, struct nfsd4_compound_state *cstate,
3654 struct svc_fh *current_fh = &cstate->current_fh; 3654 struct svc_fh *current_fh = &cstate->current_fh;
3655 struct inode *ino = current_fh->fh_dentry->d_inode; 3655 struct inode *ino = current_fh->fh_dentry->d_inode;
3656 struct nfsd_net *nn = net_generic(net, nfsd_net_id); 3656 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
3657 struct file *file = NULL;
3657 __be32 status; 3658 __be32 status;
3658 3659
3659 if (filpp) 3660 if (filpp)
@@ -3665,10 +3666,12 @@ nfs4_preprocess_stateid_op(struct net *net, struct nfsd4_compound_state *cstate,
3665 if (ZERO_STATEID(stateid) || ONE_STATEID(stateid)) 3666 if (ZERO_STATEID(stateid) || ONE_STATEID(stateid))
3666 return check_special_stateids(net, current_fh, stateid, flags); 3667 return check_special_stateids(net, current_fh, stateid, flags);
3667 3668
3669 nfs4_lock_state();
3670
3668 status = nfsd4_lookup_stateid(stateid, NFS4_DELEG_STID|NFS4_OPEN_STID|NFS4_LOCK_STID, 3671 status = nfsd4_lookup_stateid(stateid, NFS4_DELEG_STID|NFS4_OPEN_STID|NFS4_LOCK_STID,
3669 &s, cstate->minorversion, nn); 3672 &s, cstate->minorversion, nn);
3670 if (status) 3673 if (status)
3671 return status; 3674 goto out;
3672 status = check_stateid_generation(stateid, &s->sc_stateid, nfsd4_has_session(cstate)); 3675 status = check_stateid_generation(stateid, &s->sc_stateid, nfsd4_has_session(cstate));
3673 if (status) 3676 if (status)
3674 goto out; 3677 goto out;
@@ -3679,8 +3682,8 @@ nfs4_preprocess_stateid_op(struct net *net, struct nfsd4_compound_state *cstate,
3679 if (status) 3682 if (status)
3680 goto out; 3683 goto out;
3681 if (filpp) { 3684 if (filpp) {
3682 *filpp = dp->dl_file->fi_deleg_file; 3685 file = dp->dl_file->fi_deleg_file;
3683 if (!*filpp) { 3686 if (!file) {
3684 WARN_ON_ONCE(1); 3687 WARN_ON_ONCE(1);
3685 status = nfserr_serverfault; 3688 status = nfserr_serverfault;
3686 goto out; 3689 goto out;
@@ -3701,16 +3704,20 @@ nfs4_preprocess_stateid_op(struct net *net, struct nfsd4_compound_state *cstate,
3701 goto out; 3704 goto out;
3702 if (filpp) { 3705 if (filpp) {
3703 if (flags & RD_STATE) 3706 if (flags & RD_STATE)
3704 *filpp = find_readable_file(stp->st_file); 3707 file = find_readable_file(stp->st_file);
3705 else 3708 else
3706 *filpp = find_writeable_file(stp->st_file); 3709 file = find_writeable_file(stp->st_file);
3707 } 3710 }
3708 break; 3711 break;
3709 default: 3712 default:
3710 return nfserr_bad_stateid; 3713 status = nfserr_bad_stateid;
3714 goto out;
3711 } 3715 }
3712 status = nfs_ok; 3716 status = nfs_ok;
3717 if (file)
3718 *filpp = get_file(file);
3713out: 3719out:
3720 nfs4_unlock_state();
3714 return status; 3721 return status;
3715} 3722}
3716 3723