]>
Commit | Line | Data |
---|---|---|
7a7567a2 GKH |
1 | From ba851a39c9703f09684a541885ed176f8fb7c868 Mon Sep 17 00:00:00 2001 |
2 | From: Yihao Wu <wuyihao@linux.alibaba.com> | |
3 | Date: Mon, 13 May 2019 14:58:22 +0800 | |
4 | Subject: NFSv4.1: Fix bug only first CB_NOTIFY_LOCK is handled | |
5 | ||
6 | From: Yihao Wu <wuyihao@linux.alibaba.com> | |
7 | ||
8 | commit ba851a39c9703f09684a541885ed176f8fb7c868 upstream. | |
9 | ||
10 | When a waiter is waked by CB_NOTIFY_LOCK, it will retry | |
11 | nfs4_proc_setlk(). The waiter may fail to nfs4_proc_setlk() and sleep | |
12 | again. However, the waiter is already removed from clp->cl_lock_waitq | |
13 | when handling CB_NOTIFY_LOCK in nfs4_wake_lock_waiter(). So any | |
14 | subsequent CB_NOTIFY_LOCK won't wake this waiter anymore. We should | |
15 | put the waiter back to clp->cl_lock_waitq before retrying. | |
16 | ||
17 | Cc: stable@vger.kernel.org #4.9+ | |
18 | Signed-off-by: Yihao Wu <wuyihao@linux.alibaba.com> | |
19 | Reviewed-by: Jeff Layton <jlayton@kernel.org> | |
20 | Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com> | |
21 | Signed-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 */ |