linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] locks: ignore same lock in blocked_lock_hash
@ 2019-03-21 11:27 Jeff Layton
  2019-03-21 21:51 ` NeilBrown
  2019-03-22  0:42 ` J. Bruce Fields
  0 siblings, 2 replies; 12+ messages in thread
From: Jeff Layton @ 2019-03-21 11:27 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: neilb, bfields, asn

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.

If posix_locks_deadlock() fails to find a deadlock, the caller_fl
will be passed to __locks_insert_block(), and this wakes up all
locks that are blocked on caller_fl, clearing the fl_blocker link.

So if posix_locks_deadlock() finds caller_fl while searching for
a deadlock, it can be sure that link in the cycle is about to be
broken and it need not treat it as the cause of a deadlock.

More details here: https://bugzilla.kernel.org/show_bug.cgi?id=202975

Cc: stable@vger.kernel.org
Fixes: 5946c4319ebb ("fs/locks: allow a lock request to block other requests.")
Reported-by: Andreas Schneider <asn@redhat.com>
Signed-off-by: Neil Brown <neilb@suse.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/locks.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/locks.c b/fs/locks.c
index eaa1cfaf73b0..b074f6d7fd2d 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1023,6 +1023,10 @@ static int posix_locks_deadlock(struct file_lock *caller_fl,
 	while ((block_fl = what_owner_is_waiting_for(block_fl))) {
 		if (i++ > MAX_DEADLK_ITERATIONS)
 			return 0;
+
+		if (caller_fl == block_fl)
+			return 0;
+
 		if (posix_same_owner(caller_fl, block_fl))
 			return 1;
 	}
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-03-25 22:33 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-21 11:27 [PATCH] locks: ignore same lock in blocked_lock_hash Jeff Layton
2019-03-21 21:51 ` NeilBrown
2019-03-22  0:42 ` J. Bruce Fields
2019-03-22  1:58   ` NeilBrown
2019-03-22 20:27     ` J. Bruce Fields
2019-03-23 12:08       ` [PATCH v2] " Jeff Layton
2019-03-24  0:51         ` NeilBrown
2019-03-25 12:31           ` Jeff Layton
2019-03-25 12:32             ` [PATCH v3] locks: wake any locks blocked on request before deadlock check Jeff Layton
2019-03-25 22:09               ` J. Bruce Fields
2019-03-25 22:33               ` NeilBrown
2019-03-23 12:05     ` [PATCH] locks: ignore same lock in blocked_lock_hash Jeff Layton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).