]> git.baikalelectronics.ru Git - kernel.git/commit
locks: wake any locks blocked on request before deadlock check
authorJeff Layton <jlayton@kernel.org>
Mon, 25 Mar 2019 12:15:14 +0000 (08:15 -0400)
committerJeff Layton <jlayton@kernel.org>
Mon, 25 Mar 2019 12:36:24 +0000 (08:36 -0400)
commit4ddaa7e84fa9adfb76ef4071c7825b64e5deda92
tree8f35ecd8e926416c684725ce93ee604164fd16d9
parentb85d83bae525031a6bd85f15b7d05f521f7900d2
locks: wake any locks blocked on request before deadlock check

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
chain.

URL: https://bugzilla.kernel.org/show_bug.cgi?id=202975
Fixes: 7fb6bb143600 ("fs/locks: allow a lock request to block other requests.")
Cc: stable@vger.kernel.org
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