diff options
author | Yihao Wu | 2019-05-13 08:58:22 +0200 |
---|---|---|
committer | Greg Kroah-Hartman | 2019-06-11 12:20:51 +0200 |
commit | 56e3f73e838ae6315a17b70c99d1fe8bab3aca2d (patch) | |
tree | b2c0c3e6150591b70af54abd6af3db374588cff3 /fs | |
parent | NFSv4.1: Again fix a race where CB_NOTIFY_LOCK fails to wake a waiter (diff) | |
download | kernel-qcow2-linux-56e3f73e838ae6315a17b70c99d1fe8bab3aca2d.tar.gz kernel-qcow2-linux-56e3f73e838ae6315a17b70c99d1fe8bab3aca2d.tar.xz kernel-qcow2-linux-56e3f73e838ae6315a17b70c99d1fe8bab3aca2d.zip |
NFSv4.1: Fix bug only first CB_NOTIFY_LOCK is handled
commit ba851a39c9703f09684a541885ed176f8fb7c868 upstream.
When a waiter is waked by CB_NOTIFY_LOCK, it will retry
nfs4_proc_setlk(). The waiter may fail to nfs4_proc_setlk() and sleep
again. However, the waiter is already removed from clp->cl_lock_waitq
when handling CB_NOTIFY_LOCK in nfs4_wake_lock_waiter(). So any
subsequent CB_NOTIFY_LOCK won't wake this waiter anymore. We should
put the waiter back to clp->cl_lock_waitq before retrying.
Cc: stable@vger.kernel.org #4.9+
Signed-off-by: Yihao Wu <wuyihao@linux.alibaba.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfs/nfs4proc.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 06d9548a14d0..53cf8599a46e 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -6905,20 +6905,22 @@ nfs4_retry_setlk(struct nfs4_state *state, int cmd, struct file_lock *request) init_wait(&wait); wait.private = &waiter; wait.func = nfs4_wake_lock_waiter; - add_wait_queue(q, &wait); while(!signalled()) { + add_wait_queue(q, &wait); status = nfs4_proc_setlk(state, cmd, request); - if ((status != -EAGAIN) || IS_SETLK(cmd)) + if ((status != -EAGAIN) || IS_SETLK(cmd)) { + finish_wait(q, &wait); break; + } status = -ERESTARTSYS; freezer_do_not_count(); wait_woken(&wait, TASK_INTERRUPTIBLE, NFS4_LOCK_MAXTIMEOUT); freezer_count(); + finish_wait(q, &wait); } - finish_wait(q, &wait); return status; } #else /* !CONFIG_NFS_V4_1 */ |