aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2009-11-15 14:27:15 -0800
committerBrian Behlendorf <[email protected]>2009-11-15 14:27:15 -0800
commit05b48408fb8bc420908d93d97231bb6727b17e9a (patch)
tree6d85a3265b31b366ce1b63d9303f9af356b30fd1 /include
parent8b45dda2bc82ee821992b928ea9d7278a953e8f9 (diff)
Add mutex_enter_nested() as wrapper for mutex_lock_nested().
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.
Diffstat (limited to 'include')
-rw-r--r--include/sys/mutex.h26
1 files changed, 24 insertions, 2 deletions
diff --git a/include/sys/mutex.h b/include/sys/mutex.h
index 49d17659d..596c15612 100644
--- a/include/sys/mutex.h
+++ b/include/sys/mutex.h
@@ -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);