Print this page
3746 ZRLs are racy
Submitted by:   Justin Gibbs <justing@spectralogic.com>

*** 74,83 **** --- 74,84 ---- zrl_add(zrlock_t *zrl) #endif { uint32_t n = (uint32_t)zrl->zr_refcount; + while (1) { while (n != ZRL_LOCKED) { uint32_t cas = atomic_cas_32( (uint32_t *)&zrl->zr_refcount, n, n + 1); if (cas == n) { ASSERT((int32_t)n >= 0);
*** 91,112 **** #endif return; } n = cas; } - mutex_enter(&zrl->zr_mtx); while (zrl->zr_refcount == ZRL_LOCKED) { cv_wait(&zrl->zr_cv, &zrl->zr_mtx); } - ASSERT(zrl->zr_refcount >= 0); - zrl->zr_refcount++; - #ifdef ZFS_DEBUG - zrl->zr_owner = curthread; - zrl->zr_caller = zc; - #endif mutex_exit(&zrl->zr_mtx); } void zrl_remove(zrlock_t *zrl) { --- 92,107 ---- #endif return; } n = cas; } mutex_enter(&zrl->zr_mtx); while (zrl->zr_refcount == ZRL_LOCKED) { cv_wait(&zrl->zr_cv, &zrl->zr_mtx); } mutex_exit(&zrl->zr_mtx); + } } void zrl_remove(zrlock_t *zrl) {