diff --git a/include/sys/rwlock.h b/include/sys/rwlock.h index 6407e632d..83106846c 100644 --- a/include/sys/rwlock.h +++ b/include/sys/rwlock.h @@ -163,6 +163,8 @@ rw_tryenter(krwlock_t *rwlp, krw_t rw) rwlp->rw_owner = current; } break; + default: + BUG_ON(1); } return result; @@ -193,6 +195,8 @@ rw_enter(krwlock_t *rwlp, krw_t rw) BUG_ON(rwlp->rw_owner != NULL); rwlp->rw_owner = current; break; + default: + BUG_ON(1); } } diff --git a/modules/spl/spl-rwlock.c b/modules/spl/spl-rwlock.c index fa78d4c14..2ca8306f7 100644 --- a/modules/spl/spl-rwlock.c +++ b/modules/spl/spl-rwlock.c @@ -29,16 +29,21 @@ EXPORT_SYMBOL(__rw_write_held); int __rw_lock_held(krwlock_t *rwlp) { + int rc = 0; + BUG_ON(rwlp->rw_magic != RW_MAGIC); + spin_lock_irq(&(rwlp->rw_sem.wait_lock)); #ifdef CONFIG_RWSEM_GENERIC_SPINLOCK if (rwlp->rw_sem.activity != 0) { #else if (rwlp->rw_sem.count != 0) { #endif - return 1; + rc = 1; } - return 0; + spin_unlock_irq(&(rwlp->rw_sem.wait_lock)); + + return rc; } EXPORT_SYMBOL(__rw_lock_held);