Commit 034199be authored by Al Viro's avatar Al Viro Committed by Greg Kroah-Hartman

nfsd: fix error values returned by nfsd4_lockt() when nfsd_open() fails

commit 04da6e9d upstream.

nfsd_open() already returns an NFS error value; only vfs_test_lock()
result needs to be fed through nfserrno().  Broken by commit 55ef12
(nfsd: Ensure nfsv4 calls the underlying filesystem on LOCKT)
three years ago...
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarJonathan Nieder <jrnieder@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d2fd339e
...@@ -3956,16 +3956,14 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -3956,16 +3956,14 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
* vfs_test_lock. (Arguably perhaps test_lock should be done with an * vfs_test_lock. (Arguably perhaps test_lock should be done with an
* inode operation.) * inode operation.)
*/ */
static int nfsd_test_lock(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file_lock *lock) static __be32 nfsd_test_lock(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file_lock *lock)
{ {
struct file *file; struct file *file;
int err; __be32 err = nfsd_open(rqstp, fhp, S_IFREG, NFSD_MAY_READ, &file);
if (!err) {
err = nfsd_open(rqstp, fhp, S_IFREG, NFSD_MAY_READ, &file); err = nfserrno(vfs_test_lock(file, lock));
if (err) nfsd_close(file);
return err; }
err = vfs_test_lock(file, lock);
nfsd_close(file);
return err; return err;
} }
...@@ -3978,7 +3976,6 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -3978,7 +3976,6 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
{ {
struct inode *inode; struct inode *inode;
struct file_lock file_lock; struct file_lock file_lock;
int error;
__be32 status; __be32 status;
if (locks_in_grace()) if (locks_in_grace())
...@@ -4030,12 +4027,10 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -4030,12 +4027,10 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
nfs4_transform_lock_offset(&file_lock); nfs4_transform_lock_offset(&file_lock);
status = nfs_ok; status = nfsd_test_lock(rqstp, &cstate->current_fh, &file_lock);
error = nfsd_test_lock(rqstp, &cstate->current_fh, &file_lock); if (status)
if (error) {
status = nfserrno(error);
goto out; goto out;
}
if (file_lock.fl_type != F_UNLCK) { if (file_lock.fl_type != F_UNLCK) {
status = nfserr_denied; status = nfserr_denied;
nfs4_set_lock_denied(&file_lock, &lockt->lt_denied); nfs4_set_lock_denied(&file_lock, &lockt->lt_denied);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment