]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - queue-5.1/nfsv4.1-fix-bug-only-first-cb_notify_lock-is-handled.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / queue-5.1 / nfsv4.1-fix-bug-only-first-cb_notify_lock-is-handled.patch
CommitLineData
7a7567a2
GKH
1From ba851a39c9703f09684a541885ed176f8fb7c868 Mon Sep 17 00:00:00 2001
2From: Yihao Wu <wuyihao@linux.alibaba.com>
3Date: Mon, 13 May 2019 14:58:22 +0800
4Subject: NFSv4.1: Fix bug only first CB_NOTIFY_LOCK is handled
5
6From: Yihao Wu <wuyihao@linux.alibaba.com>
7
8commit ba851a39c9703f09684a541885ed176f8fb7c868 upstream.
9
10When a waiter is waked by CB_NOTIFY_LOCK, it will retry
11nfs4_proc_setlk(). The waiter may fail to nfs4_proc_setlk() and sleep
12again. However, the waiter is already removed from clp->cl_lock_waitq
13when handling CB_NOTIFY_LOCK in nfs4_wake_lock_waiter(). So any
14subsequent CB_NOTIFY_LOCK won't wake this waiter anymore. We should
15put the waiter back to clp->cl_lock_waitq before retrying.
16
17Cc: stable@vger.kernel.org #4.9+
18Signed-off-by: Yihao Wu <wuyihao@linux.alibaba.com>
19Reviewed-by: Jeff Layton <jlayton@kernel.org>
20Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
21Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22
23---
24 fs/nfs/nfs4proc.c | 8 +++++---
25 1 file changed, 5 insertions(+), 3 deletions(-)
26
27--- a/fs/nfs/nfs4proc.c
28+++ b/fs/nfs/nfs4proc.c
29@@ -6922,20 +6922,22 @@ nfs4_retry_setlk(struct nfs4_state *stat
30 init_wait(&wait);
31 wait.private = &waiter;
32 wait.func = nfs4_wake_lock_waiter;
33- add_wait_queue(q, &wait);
34
35 while(!signalled()) {
36+ add_wait_queue(q, &wait);
37 status = nfs4_proc_setlk(state, cmd, request);
38- if ((status != -EAGAIN) || IS_SETLK(cmd))
39+ if ((status != -EAGAIN) || IS_SETLK(cmd)) {
40+ finish_wait(q, &wait);
41 break;
42+ }
43
44 status = -ERESTARTSYS;
45 freezer_do_not_count();
46 wait_woken(&wait, TASK_INTERRUPTIBLE, NFS4_LOCK_MAXTIMEOUT);
47 freezer_count();
48+ finish_wait(q, &wait);
49 }
50
51- finish_wait(q, &wait);
52 return status;
53 }
54 #else /* !CONFIG_NFS_V4_1 */