[2/2] NFSv4.1: Fix bug only the first CB_NOTIFY_LOCK is handled
diff mbox series

Message ID cdba66b5-29a3-e37b-1e0f-808c171d09c3@linux.alibaba.com
State New
Headers show
Series
  • Fix two bugs CB_NOTIFY_LOCK failing to wake a water
Related show

Commit Message

Yihao Wu May 8, 2019, 9:15 a.m. UTC
When the first CB_NOTIFY_LOCK wakes a waiter, it can still fail to
acquire the lock. Then it might goes to sleep again. However it's removed
from the wait queue and not put back. So when the CB_NOTIFY_LOCK comes
again, it fails to wake this waiter.

Signed-off-by: Yihao Wu <wuyihao@linux.alibaba.com>
---
 fs/nfs/nfs4proc.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Greg KH May 8, 2019, 9:23 a.m. UTC | #1
On Wed, May 08, 2019 at 05:15:03PM +0800, Yihao Wu wrote:
> When the first CB_NOTIFY_LOCK wakes a waiter, it can still fail to
> acquire the lock. Then it might goes to sleep again. However it's removed
> from the wait queue and not put back. So when the CB_NOTIFY_LOCK comes
> again, it fails to wake this waiter.
> 
> Signed-off-by: Yihao Wu <wuyihao@linux.alibaba.com>
> ---
>  fs/nfs/nfs4proc.c | 4 ++++
>  1 file changed, 4 insertions(+)

<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read:
    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

Patch
diff mbox series

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index f13ea09..9de2c2d 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -6932,6 +6932,10 @@  struct nfs4_lock_waiter {
 
 		status = -ERESTARTSYS;
 		wait_woken(&wait, TASK_INTERRUPTIBLE, NFS4_LOCK_MAXTIMEOUT);
+		if (!signalled())  {
+			finish_wait(q, &wait);
+			add_wait_queue(q, &wait);
+		}
 	}
 
 	finish_wait(q, &wait);