Skip to content

Commit

Permalink
dax: Use non-exclusive wait in wait_entry_unlocked()
Browse files Browse the repository at this point in the history
get_unlocked_entry() uses an exclusive wait because it is guaranteed to
eventually obtain the lock and follow on with an unlock+wakeup cycle.
The wait_entry_unlocked() path does not have the same guarantee. Rather
than open-code an extra wakeup, just switch to a non-exclusive wait.

Cc: Jan Kara <jack@suse.cz>
Cc: Matthew Wilcox <willy@infradead.org>
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
  • Loading branch information
djbw committed Dec 21, 2018
1 parent 7566ec3 commit d8a7064
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions fs/dax.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,18 +246,16 @@ static void wait_entry_unlocked(struct xa_state *xas, void *entry)
ewait.wait.func = wake_exceptional_entry_func;

wq = dax_entry_waitqueue(xas, entry, &ewait.key);
prepare_to_wait_exclusive(wq, &ewait.wait, TASK_UNINTERRUPTIBLE);
/*
* Unlike get_unlocked_entry() there is no guarantee that this
* path ever successfully retrieves an unlocked entry before an
* inode dies. Perform a non-exclusive wait in case this path
* never successfully performs its own wake up.
*/
prepare_to_wait(wq, &ewait.wait, TASK_UNINTERRUPTIBLE);
xas_unlock_irq(xas);
schedule();
finish_wait(wq, &ewait.wait);

/*
* Entry lock waits are exclusive. Wake up the next waiter since
* we aren't sure we will acquire the entry lock and thus wake
* the next waiter up on unlock.
*/
if (waitqueue_active(wq))
__wake_up(wq, TASK_NORMAL, 1, &ewait.key);
}

static void put_unlocked_entry(struct xa_state *xas, void *entry)
Expand Down

0 comments on commit d8a7064

Please sign in to comment.