[lkml]   [2019]   [Apr]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 5.0 045/146] locks: wake any locks blocked on request before deadlock check
5.0-stable review patch.  If anyone has any objections, please let me know.


From: Jeff Layton <>

commit 945ab8f6de94430c23a82f3cf2e3f6d6f2945ff7 upstream.

Andreas reported that he was seeing the tdbtorture test fail in some
cases with -EDEADLCK when it wasn't before. Some debugging showed that
deadlock detection was sometimes discovering the caller's lock request
itself in a dependency chain.

While we remove the request from the blocked_lock_hash prior to
reattempting to acquire it, any locks that are blocked on that request
will still be present in the hash and will still have their fl_blocker
pointer set to the current request.

This causes posix_locks_deadlock to find a deadlock dependency chain
when it shouldn't, as a lock request cannot block itself.

We are going to end up waking all of those blocked locks anyway when we
go to reinsert the request back into the blocked_lock_hash, so just do
it prior to checking for deadlocks. This ensures that any lock blocked
on the current request will no longer be part of any blocked request

Fixes: 5946c4319ebb ("fs/locks: allow a lock request to block other requests.")
Reported-by: Andreas Schneider <>
Signed-off-by: Neil Brown <>
Signed-off-by: Jeff Layton <>
Signed-off-by: Greg Kroah-Hartman <>

fs/locks.c | 5 +++++
1 file changed, 5 insertions(+)

--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1160,6 +1160,11 @@ static int posix_lock_inode(struct inode
error = -EDEADLK;
+ /*
+ * Ensure that we don't find any locks blocked on this
+ * request during deadlock detection.
+ */
+ __locks_wake_up_blocks(request);
if (likely(!posix_locks_deadlock(request, fl))) {
__locks_insert_block(fl, request,

 \ /
  Last update: 2019-04-01 20:11    [W:0.383 / U:6.368 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site