freebsd glock assertions
authorDerrick Brashear <shadow@dementia.org>
Fri, 2 Apr 2010 03:11:42 +0000 (23:11 -0400)
committerDerrick Brashear <shadow@dementia.org>
Fri, 2 Apr 2010 03:38:28 +0000 (20:38 -0700)
assert we don't try to recurse on the glock

Change-Id: Iecf0f869e4a541a0b5322def47c944dec310ae3e
Reviewed-on: http://gerrit.openafs.org/1683
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/afs/FBSD/osi_machdep.h

index 2847de7..dd5e965 100644 (file)
@@ -116,8 +116,17 @@ extern void osi_fbsd_free(void *p);
   vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(cred),(cred),(aresid), curthread)
 extern struct mtx afs_global_mtx;
 extern struct thread *afs_global_owner;
-#define AFS_GLOCK() mtx_lock(&afs_global_mtx)
-#define AFS_GUNLOCK() mtx_unlock(&afs_global_mtx)
+#define AFS_GLOCK() \
+    do { \
+       mtx_assert(&afs_global_mtx, (MA_NOTOWNED)); \
+       mtx_lock(&afs_global_mtx); \
+       mtx_assert(&afs_global_mtx, (MA_OWNED|MA_NOTRECURSED)); \
+    } while (0)
+#define AFS_GUNLOCK() \
+    do { \
+       mtx_assert(&afs_global_mtx, (MA_OWNED|MA_NOTRECURSED)); \
+       mtx_unlock(&afs_global_mtx); \
+    } while (0)
 #define ISAFS_GLOCK() (mtx_owned(&afs_global_mtx))
 # if defined(AFS_FBSD80_ENV) && defined(WITNESS)
 #  define osi_InitGlock() \