]> git.proxmox.com Git - mirror_spl.git/commitdiff
Revert "Remove misguided HAVE_MUTEX_OWNER check"
authorBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 2 Aug 2017 19:07:11 +0000 (15:07 -0400)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 2 Aug 2017 19:08:02 +0000 (15:08 -0400)
This reverts commit d89616fda88bc030aaff758d37ede7d35e58841a which
introduced some build failures which need to be resolved before
this can be merged.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #633

config/spl-build.m4
include/sys/mutex.h

index b2a50bf164b9908235587c6e00e786c5dc06583d..630d67c2d5daad0fa5c09e6ea82c82e026874f90 100644 (file)
@@ -49,6 +49,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
        SPL_AC_USLEEP_RANGE
        SPL_AC_KMEM_CACHE_ALLOCFLAGS
        SPL_AC_WAIT_ON_BIT
+       SPL_AC_MUTEX_OWNER
        SPL_AC_INODE_LOCK
        SPL_AC_GROUP_INFO_GID
        SPL_AC_KMEM_CACHE_CREATE_USERCOPY
@@ -1561,6 +1562,35 @@ AC_DEFUN([SPL_AC_WAIT_ON_BIT], [
        ])
 ])
 
+dnl #
+dnl # Check whether mutex has owner with task_struct type.
+dnl #
+dnl # Note that before Linux 3.0, mutex owner is of type thread_info.
+dnl #
+dnl # Note that in Linux 3.18, the condition for owner is changed from
+dnl # defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_SMP) to
+dnl # defined(CONFIG_DEBUG_MUTEXES) || defined(CONFIG_MUTEX_SPIN_ON_OWNER)
+dnl #
+AC_DEFUN([SPL_AC_MUTEX_OWNER], [
+       AC_MSG_CHECKING([whether mutex has owner])
+       tmp_flags="$EXTRA_KCFLAGS"
+       EXTRA_KCFLAGS="-Werror"
+       SPL_LINUX_TRY_COMPILE([
+               #include <linux/mutex.h>
+               #include <linux/spinlock.h>
+       ],[
+               DEFINE_MUTEX(m);
+               struct task_struct *t __attribute__ ((unused));
+               t = m.owner;
+       ],[
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_MUTEX_OWNER, 1, [yes])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+       EXTRA_KCFLAGS="$tmp_flags"
+])
+
 dnl #
 dnl # 4.7 API change
 dnl # i_mutex is changed to i_rwsem. Instead of directly using
index d6bd99b4c627fc79261c7574111a005273772dbb..31923522308e8391ad2e2ba6dec94345f9eb7a98 100644 (file)
@@ -40,8 +40,10 @@ typedef enum {
 typedef struct {
        struct mutex            m_mutex;
        spinlock_t              m_lock; /* used for serializing mutex_exit */
+#ifndef HAVE_MUTEX_OWNER
        /* only when kernel doesn't have owner */
        kthread_t               *m_owner;
+#endif
 #ifdef CONFIG_LOCKDEP
        kmutex_type_t           m_type;
 #endif /* CONFIG_LOCKDEP */
@@ -56,16 +58,24 @@ spl_mutex_set_owner(kmutex_t *mp)
         * kernel will handle its owner, so we don't need to do anything if it
         * is defined.
         */
+#ifndef HAVE_MUTEX_OWNER
        mp->m_owner = current;
+#endif
 }
 
 static inline void
 spl_mutex_clear_owner(kmutex_t *mp)
 {
+#ifndef HAVE_MUTEX_OWNER
        mp->m_owner = NULL;
+#endif
 }
 
+#ifdef HAVE_MUTEX_OWNER
 #define        mutex_owner(mp)         (ACCESS_ONCE(MUTEX(mp)->owner))
+#else
+#define        mutex_owner(mp)         (ACCESS_ONCE((mp)->m_owner))
+#endif
 #define        mutex_owned(mp)         (mutex_owner(mp) == current)
 #define        MUTEX_HELD(mp)          mutex_owned(mp)
 #define        MUTEX_NOT_HELD(mp)      (!MUTEX_HELD(mp))