Threads holding a read lock of a sleepable rm lock are not permitted

to sleep.  The rmlock implementation enforces this by disabling
sleeping when a read lock is acquired. To simplify the implementation,
sleeping is disabled for most of the duration of rm_rlock.  However,
it doesn't need to be disabled until the lock is acquired.  If a
sleepable rm lock is contested, then rm_rlock may need to acquire the
backing sx lock.  This tripped the overly-broad assertion.  Fix by
relaxing the assertion around the call to sx_xlock().

Reported by:	mjg
Reviewed by:	kib, mjg
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D3324
This commit is contained in:
John Baldwin 2015-09-15 22:16:21 +00:00
parent e5fe11011a
commit e89d5f43da
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=287833

View File

@ -407,9 +407,11 @@ _rm_rlock_hard(struct rmlock *rm, struct rm_priotracker *tracker, int trylock)
return (0);
}
} else {
if (rm->lock_object.lo_flags & LO_SLEEPABLE)
if (rm->lock_object.lo_flags & LO_SLEEPABLE) {
THREAD_SLEEPING_OK();
sx_xlock(&rm->rm_lock_sx);
else
THREAD_NO_SLEEPING();
} else
mtx_lock(&rm->rm_lock_mtx);
}