lockmgr: fix upgrade
TRYUPGRADE requests kept failing when they should not have due to wrong macro used to count readers. Fixes: f6b091fbbd77cbb0 ("lockmgr: rewrite upgrade to stop always dropping the lock") Noted by: asomers Differential Revision: https://reviews.freebsd.org/D27947
This commit is contained in:
parent
f635cef2a4
commit
38baca17e0
@ -984,17 +984,19 @@ lockmgr_upgrade(struct lock *lk, u_int flags, struct lock_object *ilk,
|
||||
op = flags & LK_TYPE_MASK;
|
||||
v = lockmgr_read_value(lk);
|
||||
for (;;) {
|
||||
if (LK_SHARERS_LOCK(v) > 1) {
|
||||
if (LK_SHARERS(v) > 1) {
|
||||
if (op == LK_TRYUPGRADE) {
|
||||
LOCK_LOG2(lk, "%s: %p failed the nowait upgrade",
|
||||
__func__, lk);
|
||||
error = EBUSY;
|
||||
goto out;
|
||||
}
|
||||
if (lockmgr_sunlock_try(lk, &v)) {
|
||||
if (atomic_fcmpset_rel_ptr(&lk->lk_lock, &v,
|
||||
v - LK_ONE_SHARER)) {
|
||||
lockmgr_note_shared_release(lk, file, line);
|
||||
goto out_xlock;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
MPASS((v & ~LK_ALL_WAITERS) == LK_SHARERS_LOCK(1));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user