]> git.proxmox.com Git - mirror_spl-debian.git/commitdiff
Add mutex_enter_nested() as wrapper for mutex_lock_nested().
authorBrian Behlendorf <behlendorf1@llnl.gov>
Sun, 15 Nov 2009 22:27:15 +0000 (14:27 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Sun, 15 Nov 2009 22:27:15 +0000 (14:27 -0800)
This symbol can be used by GPL modules which use the SPL to handle
cases where a call path takes a two different locks by the same
name.  This is needed to avoid a false positive in the lock checker.

include/sys/mutex.h

index 49d17659db790a4e150cbca22c4918d7d08d917c..596c15612c2cb63e2c8400dee6d28cde85e5fdb4 100644 (file)
@@ -52,17 +52,26 @@ mutex_owner(kmutex_t *mp)
 #define MUTEX_HELD(mp)          mutex_owned(mp)
 #undef mutex_init
 #define mutex_init(mp, name, type, ibc)                                 \
-({                                                                    \
+({                                                                      \
         static struct lock_class_key __key;                             \
         ASSERT(type == MUTEX_DEFAULT);                                  \
                                                                         \
         __mutex_init((mp), #mp, &__key);                                \
 })
-/* #define mutex_destroy(mp)    ((void)0) */
+
 #define mutex_tryenter(mp)      mutex_trylock(mp)
 #define mutex_enter(mp)         mutex_lock(mp)
 #define mutex_exit(mp)          mutex_unlock(mp)
 
+#ifdef HAVE_GPL_ONLY_SYMBOLS
+# define mutex_enter_nested(mp, sc)     mutex_lock_nested(mp, sc)
+#else
+# define mutex_enter_nested(mp, sc)     mutex_enter(mp)
+# ifdef CONFIG_DEBUG_MUTEXES
+#  define mutex_destroy(mp)            ((void)0)
+# endif /* CONFIG_DEBUG_MUTEXES */
+#endif /* HAVE_GPL_ONLY_SYMBOLS */
+
 #else /* HAVE_MUTEX_OWNER */
 
 typedef struct {
@@ -193,6 +202,19 @@ mutex_owner(kmutex_t *mp)
         mutex_unlock(MUTEX(mp));                                        \
 })
 
+#ifdef HAVE_GPL_ONLY_SYMBOLS
+# define mutex_enter_nested(mp, sc)                                     \
+({                                                                      \
+        mutex_lock_nested(MUTEX(mp, sc));                               \
+        spl_mutex_set_owner(mp);                                        \
+})
+#else
+# define mutex_enter_nested(mp, sc)                                     \
+({                                                                      \
+        mutex_enter(mp);                                                \
+})
+#endif
+
 #endif /* HAVE_MUTEX_OWNER */
 
 int spl_mutex_init(void);