Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/sys New diagnostic functions vn_locked, vn_anylocked.



details:   https://anonhg.NetBSD.org/src/rev/66c5f37a10ad
branches:  trunk
changeset: 352804:66c5f37a10ad
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Tue Apr 11 06:47:25 2017 +0000

description:
New diagnostic functions vn_locked, vn_anylocked.

For use only within KASSERT.

vn_locked asserts exclusive lock, as most operations require.
vn_anylocked asserts exclusive or shared lock.

No effect unless VV_LOCKSWORK.  This will reduce the visual cost of
sprinkling lock ownership assertions throughout kern/vfs_*.

diffstat:

 sys/sys/vnode.h |  19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diffs (33 lines):

diff -r 01d80223fafc -r 66c5f37a10ad sys/sys/vnode.h
--- a/sys/sys/vnode.h   Tue Apr 11 06:01:03 2017 +0000
+++ b/sys/sys/vnode.h   Tue Apr 11 06:47:25 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vnode.h,v 1.275 2017/03/30 09:16:53 hannken Exp $      */
+/*     $NetBSD: vnode.h,v 1.276 2017/04/11 06:47:25 riastradh Exp $    */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -554,6 +554,23 @@
 void   vn_ra_allocctx(struct vnode *);
 int    vn_fifo_bypass(void *);
 
+#ifdef DIAGNOSTIC
+static inline bool
+vn_locked(struct vnode *_vp)
+{
+
+       return (_vp->v_vflag & VV_LOCKSWORK) == 0 ||
+           VOP_ISLOCKED(_vp) == LK_EXCLUSIVE;
+}
+
+static inline bool
+vn_anylocked(struct vnode *_vp)
+{
+
+       return (_vp->v_vflag & VV_LOCKSWORK) == 0 || VOP_ISLOCKED(_vp);
+}
+#endif
+
 /* initialise global vnode management */
 void   vntblinit(void);
 



Home | Main Index | Thread Index | Old Index