Commit a6f6ef2f authored by Andy Adamson's avatar Andy Adamson Committed by Linus Torvalds

[PATCH] nfsd4: misc lock fixes

Logic fixes for LOCK and UNLOCK.

- Move the permission check on the current file handle outside of
  nfs4_lock_state()

- remove the file manager fl_release_private calls; fl_ops is not set.
Signed-off-by: default avatarAndy Adamson <andros@citi.umich.edu>
Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: default avatarNeil Brown <neilb@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 1918e341
...@@ -2700,6 +2700,11 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock ...@@ -2700,6 +2700,11 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
if (check_lock_length(lock->lk_offset, lock->lk_length)) if (check_lock_length(lock->lk_offset, lock->lk_length))
return nfserr_inval; return nfserr_inval;
if ((status = fh_verify(rqstp, current_fh, S_IFREG, MAY_LOCK))) {
dprintk("NFSD: nfsd4_lock: permission denied!\n");
return status;
}
nfs4_lock_state(); nfs4_lock_state();
if (lock->lk_is_new) { if (lock->lk_is_new) {
...@@ -2757,11 +2762,6 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock ...@@ -2757,11 +2762,6 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
/* lock->lk_stateowner and lock_stp have been created or found */ /* lock->lk_stateowner and lock_stp have been created or found */
filp = lock_stp->st_vfs_file; filp = lock_stp->st_vfs_file;
if ((status = fh_verify(rqstp, current_fh, S_IFREG, MAY_LOCK))) {
dprintk("NFSD: nfsd4_lock: permission denied!\n");
goto out;
}
status = nfserr_grace; status = nfserr_grace;
if (nfs4_in_grace() && !lock->lk_reclaim) if (nfs4_in_grace() && !lock->lk_reclaim)
goto out; goto out;
...@@ -2802,8 +2802,6 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock ...@@ -2802,8 +2802,6 @@ nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
*/ */
status = posix_lock_file(filp, &file_lock); status = posix_lock_file(filp, &file_lock);
if (file_lock.fl_ops && file_lock.fl_ops->fl_release_private)
file_lock.fl_ops->fl_release_private(&file_lock);
dprintk("NFSD: nfsd4_lock: posix_lock_file status %d\n",status); dprintk("NFSD: nfsd4_lock: posix_lock_file status %d\n",status);
switch (-status) { switch (-status) {
case 0: /* success! */ case 0: /* success! */
...@@ -2977,8 +2975,6 @@ nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock ...@@ -2977,8 +2975,6 @@ nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_lock
* Try to unlock the file in the VFS. * Try to unlock the file in the VFS.
*/ */
status = posix_lock_file(filp, &file_lock); status = posix_lock_file(filp, &file_lock);
if (file_lock.fl_ops && file_lock.fl_ops->fl_release_private)
file_lock.fl_ops->fl_release_private(&file_lock);
if (status) { if (status) {
dprintk("NFSD: nfs4_locku: posix_lock_file failed!\n"); dprintk("NFSD: nfs4_locku: posix_lock_file failed!\n");
goto out_nfserr; goto out_nfserr;
......
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