Commit 7d2a354861e9257824a201d39a11e6a4d2a60cb4

Authored by Benjamin Coddington
Committed by Greg Kroah-Hartman
1 parent b087b8b11e

NFSv4.1: Fix a race where CB_NOTIFY_LOCK fails to wake a waiter

commit b7dbcc0e433f0f61acb89ed9861ec996be4f2b38 upstream.

nfs4_retry_setlk() sets the task's state to TASK_INTERRUPTIBLE within the
same region protected by the wait_queue's lock after checking for a
notification from CB_NOTIFY_LOCK callback.  However, after releasing that
lock, a wakeup for that task may race in before the call to
freezable_schedule_timeout_interruptible() and set TASK_WAKING, then
freezable_schedule_timeout_interruptible() will set the state back to
TASK_INTERRUPTIBLE before the task will sleep.  The result is that the task
will sleep for the entire duration of the timeout.

Since we've already set TASK_INTERRUPTIBLE in the locked section, just use
freezable_schedule_timout() instead.

Fixes: a1d617d8f134 ("nfs: allow blocking locks to be awoken by lock callbacks")
Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

... ... @@ -6419,7 +6419,7 @@
6419 6419 set_current_state(TASK_INTERRUPTIBLE);
6420 6420 spin_unlock_irqrestore(&q->lock, flags);
6421 6421  
6422   - freezable_schedule_timeout_interruptible(NFS4_LOCK_MAXTIMEOUT);
  6422 + freezable_schedule_timeout(NFS4_LOCK_MAXTIMEOUT);
6423 6423 }
6424 6424  
6425 6425 finish_wait(q, &wait);