diff options
Diffstat (limited to 'sys/contrib/openzfs/include/os/linux/spl/sys/mutex.h')
-rw-r--r-- | sys/contrib/openzfs/include/os/linux/spl/sys/mutex.h | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/sys/contrib/openzfs/include/os/linux/spl/sys/mutex.h b/sys/contrib/openzfs/include/os/linux/spl/sys/mutex.h index 047607f826bc..b4eaa0266d20 100644 --- a/sys/contrib/openzfs/include/os/linux/spl/sys/mutex.h +++ b/sys/contrib/openzfs/include/os/linux/spl/sys/mutex.h @@ -113,8 +113,8 @@ spl_mutex_lockdep_on_maybe(kmutex_t *mp) \ VERIFY3P(mutex_owner(mp), ==, NULL); \ } -/* BEGIN CSTYLED */ #define mutex_tryenter(mp) \ +/* CSTYLED */ \ ({ \ int _rc_; \ \ @@ -125,11 +125,9 @@ spl_mutex_lockdep_on_maybe(kmutex_t *mp) \ \ _rc_; \ }) -/* END CSTYLED */ #define NESTED_SINGLE 1 -#ifdef CONFIG_DEBUG_LOCK_ALLOC #define mutex_enter_nested(mp, subclass) \ { \ ASSERT3P(mutex_owner(mp), !=, current); \ @@ -138,16 +136,22 @@ spl_mutex_lockdep_on_maybe(kmutex_t *mp) \ spl_mutex_lockdep_on_maybe(mp); \ spl_mutex_set_owner(mp); \ } -#else /* CONFIG_DEBUG_LOCK_ALLOC */ -#define mutex_enter_nested(mp, subclass) \ -{ \ + +#define mutex_enter_interruptible(mp) \ +/* CSTYLED */ \ +({ \ + int _rc_; \ + \ ASSERT3P(mutex_owner(mp), !=, current); \ spl_mutex_lockdep_off_maybe(mp); \ - mutex_lock(MUTEX(mp)); \ + _rc_ = mutex_lock_interruptible(MUTEX(mp)); \ spl_mutex_lockdep_on_maybe(mp); \ - spl_mutex_set_owner(mp); \ -} -#endif /* CONFIG_DEBUG_LOCK_ALLOC */ + if (!_rc_) { \ + spl_mutex_set_owner(mp); \ + } \ + \ + _rc_; \ +}) #define mutex_enter(mp) mutex_enter_nested((mp), 0) @@ -172,6 +176,7 @@ spl_mutex_lockdep_on_maybe(kmutex_t *mp) \ */ #define mutex_exit(mp) \ { \ + ASSERT3P(mutex_owner(mp), ==, current); \ spl_mutex_clear_owner(mp); \ spin_lock(&(mp)->m_lock); \ spl_mutex_lockdep_off_maybe(mp); \ |