FBSD: lock interlock around v_usecount accesses
authorBen Kaduk <kaduk@mit.edu>
Fri, 29 Oct 2010 16:01:04 +0000 (12:01 -0400)
committerDerrick Brashear <shadow@dementia.org>
Fri, 29 Oct 2010 19:03:49 +0000 (12:03 -0700)
The FreeBSD vnode locking strategy requires that the vnode
interlock be held for all accesses to v_usecount, such as those
used by our VREFCOUNT and VREFCOUNT_GT macros.  Conveniently,
a wrapper function is provided that takes the lock around its
access of the element, vrefcnt().  Use it for our macros.

Change-Id: Ia88eb21046fe844a6adb830734dcae2f76ef2dc5
Reviewed-on: http://gerrit.openafs.org/3195
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/afs/afs.h

index 1ee9ab5..5c2c832 100644 (file)
@@ -670,6 +670,9 @@ struct SimpleLocks {
 
 #if defined(AFS_DARWIN80_ENV)
 #define VREFCOUNT_GT(v, y)    vnode_isinuse(AFSTOV(v), (y))
+#elif defined(AFS_FBSD_ENV)
+#define VREFCOUNT(v)           (vrefcnt(AFSTOV(v)))
+#define VREFCOUNT_GT(v, y)     (vrefcnt(AFSTOV(v)) > y)
 #elif defined(AFS_XBSD_ENV) || defined(AFS_DARWIN_ENV)
 #define VREFCOUNT(v)          ((v)->vrefCount)
 #define VREFCOUNT_GT(v, y)    (AFSTOV(v)->v_usecount > (y))