Skip to content

Commit 1ea67db

Browse files
jtlaytonamschuma-ntap
authored andcommitted
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 <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent db78368 commit 1ea67db

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

fs/nfs/nfs4proc.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6135,15 +6135,8 @@ static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock
61356135
struct nfs_inode *nfsi = NFS_I(state->inode);
61366136
struct nfs4_state_owner *sp = state->owner;
61376137
unsigned char fl_flags = request->fl_flags;
6138-
int status = -ENOLCK;
6138+
int status;
61396139

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;
61476140
request->fl_flags |= FL_ACCESS;
61486141
status = locks_lock_inode_wait(state->inode, request);
61496142
if (status < 0)
@@ -6217,6 +6210,11 @@ nfs4_proc_lock(struct file *filp, int cmd, struct file_lock *request)
62176210

62186211
if (state == NULL)
62196212
return -ENOLCK;
6213+
6214+
if ((request->fl_flags & FL_POSIX) &&
6215+
!test_bit(NFS_STATE_POSIX_LOCKS, &state->flags))
6216+
return -ENOLCK;
6217+
62206218
/*
62216219
* Don't rely on the VFS having checked the file open mode,
62226220
* 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)
62316229
return -EBADF;
62326230
}
62336231

6232+
status = nfs4_set_lock_state(state, request);
6233+
if (status != 0)
6234+
return status;
6235+
62346236
do {
62356237
status = nfs4_proc_setlk(state, cmd, request);
62366238
if ((status != -EAGAIN) || IS_SETLK(cmd))

0 commit comments

Comments
 (0)