Module Name: src Committed By: riastradh Date: Tue Apr 11 06:47:25 UTC 2017
Modified Files: src/sys/sys: vnode.h Log Message: 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_*. To generate a diff of this commit: cvs rdiff -u -r1.275 -r1.276 src/sys/sys/vnode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/sys/vnode.h diff -u src/sys/sys/vnode.h:1.275 src/sys/sys/vnode.h:1.276 --- src/sys/sys/vnode.h:1.275 Thu Mar 30 09:16:53 2017 +++ src/sys/sys/vnode.h Tue Apr 11 06:47:25 2017 @@ -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 @@ int vn_extattr_rm(struct vnode *, int, i 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);