aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2016-09-17 18:17:37 -0400
committerAnna Schumaker <Anna.Schumaker@Netapp.com>2016-09-22 13:56:04 -0400
commit1ea67dbd9828278188fb846972c3c368b0ef23a1 (patch)
tree7b7482905a2f1642fe565b1d7c64df443938f995 /fs/nfs
parentdb783688d4a20bae1b77c5c96a0ad3eb3079f9f6 (diff)
nfs: move nfs4_set_lock_state call into caller
We need to have this info set up before adding the waiter to the waitqueue, so move this out of the _nfs4_proc_setlk and into the caller. That's more efficient anyway since we don't need to do this more than once if we end up waiting on the lock. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/nfs4proc.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 93cf38e8098a..ffadf6be3668 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -6135,15 +6135,8 @@ static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock
6135 struct nfs_inode *nfsi = NFS_I(state->inode); 6135 struct nfs_inode *nfsi = NFS_I(state->inode);
6136 struct nfs4_state_owner *sp = state->owner; 6136 struct nfs4_state_owner *sp = state->owner;
6137 unsigned char fl_flags = request->fl_flags; 6137 unsigned char fl_flags = request->fl_flags;
6138 int status = -ENOLCK; 6138 int status;
6139 6139
6140 if ((fl_flags & FL_POSIX) &&
6141 !test_bit(NFS_STATE_POSIX_LOCKS, &state->flags))
6142 goto out;
6143 /* Is this a delegated open? */
6144 status = nfs4_set_lock_state(state, request);
6145 if (status != 0)
6146 goto out;
6147 request->fl_flags |= FL_ACCESS; 6140 request->fl_flags |= FL_ACCESS;
6148 status = locks_lock_inode_wait(state->inode, request); 6141 status = locks_lock_inode_wait(state->inode, request);
6149 if (status < 0) 6142 if (status < 0)
@@ -6217,6 +6210,11 @@ nfs4_proc_lock(struct file *filp, int cmd, struct file_lock *request)
6217 6210
6218 if (state == NULL) 6211 if (state == NULL)
6219 return -ENOLCK; 6212 return -ENOLCK;
6213
6214 if ((request->fl_flags & FL_POSIX) &&
6215 !test_bit(NFS_STATE_POSIX_LOCKS, &state->flags))
6216 return -ENOLCK;
6217
6220 /* 6218 /*
6221 * Don't rely on the VFS having checked the file open mode, 6219 * Don't rely on the VFS having checked the file open mode,
6222 * since it won't do this for flock() locks. 6220 * since it won't do this for flock() locks.
@@ -6231,6 +6229,10 @@ nfs4_proc_lock(struct file *filp, int cmd, struct file_lock *request)
6231 return -EBADF; 6229 return -EBADF;
6232 } 6230 }
6233 6231
6232 status = nfs4_set_lock_state(state, request);
6233 if (status != 0)
6234 return status;
6235
6234 do { 6236 do {
6235 status = nfs4_proc_setlk(state, cmd, request); 6237 status = nfs4_proc_setlk(state, cmd, request);
6236 if ((status != -EAGAIN) || IS_SETLK(cmd)) 6238 if ((status != -EAGAIN) || IS_SETLK(cmd))