summaryrefslogtreecommitdiffstats
path: root/module/zfs/zrlock.c
diff options
context:
space:
mode:
authorMatthew Ahrens <[email protected]>2015-04-26 15:29:43 -0700
committerBrian Behlendorf <[email protected]>2015-04-30 14:43:40 -0700
commit8dd86a10cf836d64cddd9c8693f449686e35788c (patch)
treef5ac0a87f3301c7e263fa13b4e70498a7a9cd680 /module/zfs/zrlock.c
parent6186e2975316e6693d576ab9eec8289c806e38a9 (diff)
Illumos 5812 - assertion failed in zrl_tryenter(): zr_owner==NULL
5812 assertion failed in zrl_tryenter(): zr_owner==NULL Reviewed by: George Wilson <[email protected]> Reviewed by: Alex Reece <[email protected]> Reviewed by: Will Andrews <[email protected]> Approved by: Gordon Ross <[email protected]> References: https://www.illumos.org/issues/5812 https://github.com/illumos/illumos-gate/commit/8df1730 Ported-by: DHE <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #3357
Diffstat (limited to 'module/zfs/zrlock.c')
-rw-r--r--module/zfs/zrlock.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/module/zfs/zrlock.c b/module/zfs/zrlock.c
index 144e72eb4..52f9ee839 100644
--- a/module/zfs/zrlock.c
+++ b/module/zfs/zrlock.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014 by Delphix. All rights reserved.
*/
/*
@@ -43,7 +44,7 @@
* A ZRL can be locked only while there are zero references, so ZRL_LOCKED is
* treated as zero references.
*/
-#define ZRL_LOCKED ((uint32_t)-1)
+#define ZRL_LOCKED -1
#define ZRL_DESTROYED -2
void
@@ -61,7 +62,7 @@ zrl_init(zrlock_t *zrl)
void
zrl_destroy(zrlock_t *zrl)
{
- ASSERT(zrl->zr_refcount == 0);
+ ASSERT0(zrl->zr_refcount);
mutex_destroy(&zrl->zr_mtx);
zrl->zr_refcount = ZRL_DESTROYED;
@@ -81,7 +82,7 @@ zrl_add(zrlock_t *zrl)
uint32_t cas = atomic_cas_32(
(uint32_t *)&zrl->zr_refcount, n, n + 1);
if (cas == n) {
- ASSERT((int32_t)n >= 0);
+ ASSERT3S((int32_t)n, >=, 0);
#ifdef ZFS_DEBUG
if (zrl->zr_owner == curthread) {
DTRACE_PROBE2(zrlock__reentry,
@@ -99,7 +100,7 @@ zrl_add(zrlock_t *zrl)
while (zrl->zr_refcount == ZRL_LOCKED) {
cv_wait(&zrl->zr_cv, &zrl->zr_mtx);
}
- ASSERT(zrl->zr_refcount >= 0);
+ ASSERT3S(zrl->zr_refcount, >=, 0);
zrl->zr_refcount++;
#ifdef ZFS_DEBUG
zrl->zr_owner = curthread;
@@ -113,14 +114,14 @@ zrl_remove(zrlock_t *zrl)
{
uint32_t n;
- n = atomic_dec_32_nv((uint32_t *)&zrl->zr_refcount);
- ASSERT((int32_t)n >= 0);
#ifdef ZFS_DEBUG
if (zrl->zr_owner == curthread) {
zrl->zr_owner = NULL;
zrl->zr_caller = NULL;
}
#endif
+ n = atomic_dec_32_nv((uint32_t *)&zrl->zr_refcount);
+ ASSERT3S((int32_t)n, >=, 0);
}
int
@@ -133,14 +134,14 @@ zrl_tryenter(zrlock_t *zrl)
(uint32_t *)&zrl->zr_refcount, 0, ZRL_LOCKED);
if (cas == 0) {
#ifdef ZFS_DEBUG
- ASSERT(zrl->zr_owner == NULL);
+ ASSERT3P(zrl->zr_owner, ==, NULL);
zrl->zr_owner = curthread;
#endif
return (1);
}
}
- ASSERT((int32_t)n > ZRL_DESTROYED);
+ ASSERT3S((int32_t)n, >, ZRL_DESTROYED);
return (0);
}
@@ -148,11 +149,11 @@ zrl_tryenter(zrlock_t *zrl)
void
zrl_exit(zrlock_t *zrl)
{
- ASSERT(zrl->zr_refcount == ZRL_LOCKED);
+ ASSERT3S(zrl->zr_refcount, ==, ZRL_LOCKED);
mutex_enter(&zrl->zr_mtx);
#ifdef ZFS_DEBUG
- ASSERT(zrl->zr_owner == curthread);
+ ASSERT3P(zrl->zr_owner, ==, curthread);
zrl->zr_owner = NULL;
membar_producer(); /* make sure the owner store happens first */
#endif
@@ -166,7 +167,7 @@ zrl_refcount(zrlock_t *zrl)
{
int n;
- ASSERT(zrl->zr_refcount > ZRL_DESTROYED);
+ ASSERT3S(zrl->zr_refcount, >, ZRL_DESTROYED);
n = (int)zrl->zr_refcount;
return (n <= 0 ? 0 : n);
@@ -175,7 +176,7 @@ zrl_refcount(zrlock_t *zrl)
int
zrl_is_zero(zrlock_t *zrl)
{
- ASSERT(zrl->zr_refcount > ZRL_DESTROYED);
+ ASSERT3S(zrl->zr_refcount, >, ZRL_DESTROYED);
return (zrl->zr_refcount <= 0);
}
@@ -183,7 +184,7 @@ zrl_is_zero(zrlock_t *zrl)
int
zrl_is_locked(zrlock_t *zrl)
{
- ASSERT(zrl->zr_refcount > ZRL_DESTROYED);
+ ASSERT3S(zrl->zr_refcount, >, ZRL_DESTROYED);
return (zrl->zr_refcount == ZRL_LOCKED);
}