MFV 286604: 5812 assertion failed in zrl_tryenter(): zr_owner==NULL
Reviewed by: George Wilson <george@delphix.com> Reviewed by: Alex Reece <alex@delphix.com> Reviewed by: Will Andrews <will@freebsd.org> Approved by: Gordon Ross <gwr@nexenta.com> Author: Matthew Ahrens <mahrens@delphix.com> illumos/illumos-gate@8df173054c
This commit is contained in:
parent
799f47828d
commit
1af86496cb
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=286605
@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* Copyright (c) 2014 by Delphix. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -42,7 +43,7 @@
|
|||||||
* A ZRL can be locked only while there are zero references, so ZRL_LOCKED is
|
* A ZRL can be locked only while there are zero references, so ZRL_LOCKED is
|
||||||
* treated as zero references.
|
* treated as zero references.
|
||||||
*/
|
*/
|
||||||
#define ZRL_LOCKED ((uint32_t)-1)
|
#define ZRL_LOCKED -1
|
||||||
#define ZRL_DESTROYED -2
|
#define ZRL_DESTROYED -2
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -60,7 +61,7 @@ zrl_init(zrlock_t *zrl)
|
|||||||
void
|
void
|
||||||
zrl_destroy(zrlock_t *zrl)
|
zrl_destroy(zrlock_t *zrl)
|
||||||
{
|
{
|
||||||
ASSERT(zrl->zr_refcount == 0);
|
ASSERT0(zrl->zr_refcount);
|
||||||
|
|
||||||
mutex_destroy(&zrl->zr_mtx);
|
mutex_destroy(&zrl->zr_mtx);
|
||||||
zrl->zr_refcount = ZRL_DESTROYED;
|
zrl->zr_refcount = ZRL_DESTROYED;
|
||||||
@ -80,7 +81,7 @@ zrl_add(zrlock_t *zrl)
|
|||||||
uint32_t cas = atomic_cas_32(
|
uint32_t cas = atomic_cas_32(
|
||||||
(uint32_t *)&zrl->zr_refcount, n, n + 1);
|
(uint32_t *)&zrl->zr_refcount, n, n + 1);
|
||||||
if (cas == n) {
|
if (cas == n) {
|
||||||
ASSERT((int32_t)n >= 0);
|
ASSERT3S((int32_t)n, >=, 0);
|
||||||
#ifdef ZFS_DEBUG
|
#ifdef ZFS_DEBUG
|
||||||
if (zrl->zr_owner == curthread) {
|
if (zrl->zr_owner == curthread) {
|
||||||
DTRACE_PROBE2(zrlock__reentry,
|
DTRACE_PROBE2(zrlock__reentry,
|
||||||
@ -98,7 +99,7 @@ zrl_add(zrlock_t *zrl)
|
|||||||
while (zrl->zr_refcount == ZRL_LOCKED) {
|
while (zrl->zr_refcount == ZRL_LOCKED) {
|
||||||
cv_wait(&zrl->zr_cv, &zrl->zr_mtx);
|
cv_wait(&zrl->zr_cv, &zrl->zr_mtx);
|
||||||
}
|
}
|
||||||
ASSERT(zrl->zr_refcount >= 0);
|
ASSERT3S(zrl->zr_refcount, >=, 0);
|
||||||
zrl->zr_refcount++;
|
zrl->zr_refcount++;
|
||||||
#ifdef ZFS_DEBUG
|
#ifdef ZFS_DEBUG
|
||||||
zrl->zr_owner = curthread;
|
zrl->zr_owner = curthread;
|
||||||
@ -112,14 +113,14 @@ zrl_remove(zrlock_t *zrl)
|
|||||||
{
|
{
|
||||||
uint32_t n;
|
uint32_t n;
|
||||||
|
|
||||||
n = atomic_dec_32_nv((uint32_t *)&zrl->zr_refcount);
|
|
||||||
ASSERT((int32_t)n >= 0);
|
|
||||||
#ifdef ZFS_DEBUG
|
#ifdef ZFS_DEBUG
|
||||||
if (zrl->zr_owner == curthread) {
|
if (zrl->zr_owner == curthread) {
|
||||||
zrl->zr_owner = NULL;
|
zrl->zr_owner = NULL;
|
||||||
zrl->zr_caller = NULL;
|
zrl->zr_caller = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
n = atomic_dec_32_nv((uint32_t *)&zrl->zr_refcount);
|
||||||
|
ASSERT3S((int32_t)n, >=, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -132,14 +133,14 @@ zrl_tryenter(zrlock_t *zrl)
|
|||||||
(uint32_t *)&zrl->zr_refcount, 0, ZRL_LOCKED);
|
(uint32_t *)&zrl->zr_refcount, 0, ZRL_LOCKED);
|
||||||
if (cas == 0) {
|
if (cas == 0) {
|
||||||
#ifdef ZFS_DEBUG
|
#ifdef ZFS_DEBUG
|
||||||
ASSERT(zrl->zr_owner == NULL);
|
ASSERT3P(zrl->zr_owner, ==, NULL);
|
||||||
zrl->zr_owner = curthread;
|
zrl->zr_owner = curthread;
|
||||||
#endif
|
#endif
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT((int32_t)n > ZRL_DESTROYED);
|
ASSERT3S((int32_t)n, >, ZRL_DESTROYED);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -147,11 +148,11 @@ zrl_tryenter(zrlock_t *zrl)
|
|||||||
void
|
void
|
||||||
zrl_exit(zrlock_t *zrl)
|
zrl_exit(zrlock_t *zrl)
|
||||||
{
|
{
|
||||||
ASSERT(zrl->zr_refcount == ZRL_LOCKED);
|
ASSERT3S(zrl->zr_refcount, ==, ZRL_LOCKED);
|
||||||
|
|
||||||
mutex_enter(&zrl->zr_mtx);
|
mutex_enter(&zrl->zr_mtx);
|
||||||
#ifdef ZFS_DEBUG
|
#ifdef ZFS_DEBUG
|
||||||
ASSERT(zrl->zr_owner == curthread);
|
ASSERT3P(zrl->zr_owner, ==, curthread);
|
||||||
zrl->zr_owner = NULL;
|
zrl->zr_owner = NULL;
|
||||||
membar_producer(); /* make sure the owner store happens first */
|
membar_producer(); /* make sure the owner store happens first */
|
||||||
#endif
|
#endif
|
||||||
@ -163,7 +164,7 @@ zrl_exit(zrlock_t *zrl)
|
|||||||
int
|
int
|
||||||
zrl_refcount(zrlock_t *zrl)
|
zrl_refcount(zrlock_t *zrl)
|
||||||
{
|
{
|
||||||
ASSERT(zrl->zr_refcount > ZRL_DESTROYED);
|
ASSERT3S(zrl->zr_refcount, >, ZRL_DESTROYED);
|
||||||
|
|
||||||
int n = (int)zrl->zr_refcount;
|
int n = (int)zrl->zr_refcount;
|
||||||
return (n <= 0 ? 0 : n);
|
return (n <= 0 ? 0 : n);
|
||||||
@ -172,7 +173,7 @@ zrl_refcount(zrlock_t *zrl)
|
|||||||
int
|
int
|
||||||
zrl_is_zero(zrlock_t *zrl)
|
zrl_is_zero(zrlock_t *zrl)
|
||||||
{
|
{
|
||||||
ASSERT(zrl->zr_refcount > ZRL_DESTROYED);
|
ASSERT3S(zrl->zr_refcount, >, ZRL_DESTROYED);
|
||||||
|
|
||||||
return (zrl->zr_refcount <= 0);
|
return (zrl->zr_refcount <= 0);
|
||||||
}
|
}
|
||||||
@ -180,7 +181,7 @@ zrl_is_zero(zrlock_t *zrl)
|
|||||||
int
|
int
|
||||||
zrl_is_locked(zrlock_t *zrl)
|
zrl_is_locked(zrlock_t *zrl)
|
||||||
{
|
{
|
||||||
ASSERT(zrl->zr_refcount > ZRL_DESTROYED);
|
ASSERT3S(zrl->zr_refcount, >, ZRL_DESTROYED);
|
||||||
|
|
||||||
return (zrl->zr_refcount == ZRL_LOCKED);
|
return (zrl->zr_refcount == ZRL_LOCKED);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user