aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfsd')
-rw-r--r--fs/nfsd/nfs4state.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 06b89df92218..e62d0e3df8b3 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -2782,6 +2782,25 @@ out:
2782} 2782}
2783 2783
2784/* 2784/*
2785 * The NFSv4 spec allows a client to do a LOCKT without holding an OPEN,
2786 * so we do a temporary open here just to get an open file to pass to
2787 * vfs_test_lock. (Arguably perhaps test_lock should be done with an
2788 * inode operation.)
2789 */
2790static int nfsd_test_lock(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file_lock *lock)
2791{
2792 struct file *file;
2793 int err;
2794
2795 err = nfsd_open(rqstp, fhp, S_IFREG, NFSD_MAY_READ, &file);
2796 if (err)
2797 return err;
2798 err = vfs_test_lock(file, lock);
2799 nfsd_close(file);
2800 return err;
2801}
2802
2803/*
2785 * LOCKT operation 2804 * LOCKT operation
2786 */ 2805 */
2787__be32 2806__be32
@@ -2789,7 +2808,6 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
2789 struct nfsd4_lockt *lockt) 2808 struct nfsd4_lockt *lockt)
2790{ 2809{
2791 struct inode *inode; 2810 struct inode *inode;
2792 struct file file;
2793 struct file_lock file_lock; 2811 struct file_lock file_lock;
2794 int error; 2812 int error;
2795 __be32 status; 2813 __be32 status;
@@ -2847,16 +2865,8 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
2847 2865
2848 nfs4_transform_lock_offset(&file_lock); 2866 nfs4_transform_lock_offset(&file_lock);
2849 2867
2850 /* vfs_test_lock uses the struct file _only_ to resolve the inode.
2851 * since LOCKT doesn't require an OPEN, and therefore a struct
2852 * file may not exist, pass vfs_test_lock a struct file with
2853 * only the dentry:inode set.
2854 */
2855 memset(&file, 0, sizeof (struct file));
2856 file.f_path.dentry = cstate->current_fh.fh_dentry;
2857
2858 status = nfs_ok; 2868 status = nfs_ok;
2859 error = vfs_test_lock(&file, &file_lock); 2869 error = nfsd_test_lock(rqstp, &cstate->current_fh, &file_lock);
2860 if (error) { 2870 if (error) {
2861 status = nfserrno(error); 2871 status = nfserrno(error);
2862 goto out; 2872 goto out;