kernel - Fix rare lockmgr() state transition (2)
authorMatthew Dillon <dillon@apollo.backplane.com>
Sun, 1 Oct 2017 18:18:49 +0000 (11:18 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 3 Oct 2017 01:41:17 +0000 (18:41 -0700)
commitbb36d905d2bf2569ce40fc3ebdab1877ae6342bf
treed506fcf69ee78df2d0b75658bfcc95ab3b96b364
parenteccac4ffb5982fd205a1701631a4c37bfa42cc25
kernel - Fix rare lockmgr() state transition (2)

* Fix two lock timeout cases for LK_EXCLUPGRADE and LK_UPGRADE, and
  fix a bug in undo_upreq().

* A tsleep failure (such as the LK_TIMELOCK case via
  vm_map_lock_read_to()) was not properly backing-out a LKC_UPREQ,
  resulting in a situation where the lock becomes exclusively owned
  by nobody and deadlocks against all-comers.  Fix by properly
  calling undo_upreq().

* Fix a bug in undo_upreq() itself.  When undoing a granted UPREQ,
  the lockholder must be set prior to releasing the now-granted
  exclusive lock in order to avoid an assertion panic.

* While we are at it, replace a weird cmpset count,count with a
  fetchadd(count, 0).
share/man/man9/lock.9
sys/kern/kern_lock.c