From: Andy Adamson 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: Andy Adamson Signed-off-by: J. Bruce Fields Signed-off-by: Neil Brown Signed-off-by: Andrew Morton --- fs/nfsd/nfs4state.c | 14 +++++--------- 1 files changed, 5 insertions(+), 9 deletions(-) diff -puN fs/nfsd/nfs4state.c~nfsd4-misc-lock-fixes fs/nfsd/nfs4state.c --- 25/fs/nfsd/nfs4state.c~nfsd4-misc-lock-fixes Fri Jan 13 17:54:22 2006 +++ 25-akpm/fs/nfsd/nfs4state.c Fri Jan 13 17:54:22 2006 @@ -2701,6 +2701,11 @@ nfsd4_lock(struct svc_rqst *rqstp, struc if (check_lock_length(lock->lk_offset, lock->lk_length)) 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(); if (lock->lk_is_new) { @@ -2758,11 +2763,6 @@ nfsd4_lock(struct svc_rqst *rqstp, struc /* lock->lk_stateowner and lock_stp have been created or found */ 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; if (nfs4_in_grace() && !lock->lk_reclaim) goto out; @@ -2803,8 +2803,6 @@ nfsd4_lock(struct svc_rqst *rqstp, struc */ 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); switch (-status) { case 0: /* success! */ @@ -2978,8 +2976,6 @@ nfsd4_locku(struct svc_rqst *rqstp, stru * Try to unlock the file in the VFS. */ 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) { dprintk("NFSD: nfs4_locku: posix_lock_file failed!\n"); goto out_nfserr; _