Illumos 5981 - Deadlock in dmu_objset_find_dp

5981 Deadlock in dmu_objset_find_dp
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Approved by: Robert Mustacchi <rm@joyent.com>

References:
  https://www.illumos.org/issues/5981
  https://github.com/illumos/illumos-gate/commit/1d3f896

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3553
This commit is contained in:
Arne Jansen
2015-07-02 17:58:17 +02:00
committed by Brian Behlendorf
parent 71e2fe41be
commit 5e8cd5d17f
5 changed files with 40 additions and 4 deletions
+22 -3
View File
@@ -159,8 +159,8 @@ rrw_destroy(rrwlock_t *rrl)
refcount_destroy(&rrl->rr_linked_rcount);
}
void
rrw_enter_read(rrwlock_t *rrl, void *tag)
static void
rrw_enter_read_impl(rrwlock_t *rrl, boolean_t prio, void *tag)
{
mutex_enter(&rrl->rr_lock);
#if !defined(DEBUG) && defined(_KERNEL)
@@ -176,7 +176,7 @@ rrw_enter_read(rrwlock_t *rrl, void *tag)
ASSERT(refcount_count(&rrl->rr_anon_rcount) >= 0);
while (rrl->rr_writer != NULL || (rrl->rr_writer_wanted &&
refcount_is_zero(&rrl->rr_anon_rcount) &&
refcount_is_zero(&rrl->rr_anon_rcount) && !prio &&
rrn_find(rrl) == NULL))
cv_wait(&rrl->rr_cv, &rrl->rr_lock);
@@ -191,6 +191,25 @@ rrw_enter_read(rrwlock_t *rrl, void *tag)
mutex_exit(&rrl->rr_lock);
}
void
rrw_enter_read(rrwlock_t *rrl, void *tag)
{
rrw_enter_read_impl(rrl, B_FALSE, tag);
}
/*
* take a read lock even if there are pending write lock requests. if we want
* to take a lock reentrantly, but from different threads (that have a
* relationship to each other), the normal detection mechanism to overrule
* the pending writer does not work, so we have to give an explicit hint here.
*/
void
rrw_enter_read_prio(rrwlock_t *rrl, void *tag)
{
rrw_enter_read_impl(rrl, B_TRUE, tag);
}
void
rrw_enter_write(rrwlock_t *rrl)
{