Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Make option VNODE_LOCKDEBUG more functional.
details: https://anonhg.NetBSD.org/src/rev/e6982eb79acc
branches: trunk
changeset: 365915:e6982eb79acc
user: hannken <hannken%NetBSD.org@localhost>
date: Tue May 03 08:33:59 2022 +0000
description:
Make option VNODE_LOCKDEBUG more functional.
- Add "LOCKED=EXCL" option for vnode operations needing exclusive locked nodes.
- As it is impossible to check for shared locks held by current thread avoid
false assertions by testing for exclusive lock only in the "LOCKED=NO" case.
- New option "RUMP_VNODE_LOCKDEBUG" enables VNODE_LOCKDEBUG for the rump kernel.
diffstat:
sys/kern/vnode_if.sh | 81 ++++++++++++++++++++++++++++----------------
sys/kern/vnode_if.src | 38 ++++++++++----------
sys/rump/Makefile.rump | 6 ++-
sys/rump/README.compileopts | 9 ++++-
4 files changed, 83 insertions(+), 51 deletions(-)
diffs (truncated from 347 to 300 lines):
diff -r 22a19dda1ac5 -r e6982eb79acc sys/kern/vnode_if.sh
--- a/sys/kern/vnode_if.sh Tue May 03 07:36:20 2022 +0000
+++ b/sys/kern/vnode_if.sh Tue May 03 08:33:59 2022 +0000
@@ -29,7 +29,7 @@
* SUCH DAMAGE.
*/
"
-SCRIPT_ID='$NetBSD: vnode_if.sh,v 1.73 2022/03/19 13:53:32 hannken Exp $'
+SCRIPT_ID='$NetBSD: vnode_if.sh,v 1.74 2022/05/03 08:33:59 hannken Exp $'
# Script to produce VFS front-end sugar.
#
@@ -53,7 +53,7 @@
out_rumph=../rump/include/rump/rumpvnode_if.h
# generate VNODE_LOCKDEBUG checks (not fully functional)
-lockdebug=0
+lockdebug=1
# Awk program (must support nawk extensions)
# Use "awk" at Berkeley, "nawk" or "gawk" elsewhere.
@@ -150,14 +150,17 @@
i=2;
if (is_context == 0) {
- if ($2 == "LOCKED=YES") {
- lockstate[argc] = 1;
+ if ($2 == "LOCKED=EXCL") {
+ lockstate[argc] = "elocked";
+ i++;
+ } else if ($2 == "LOCKED=YES") {
+ lockstate[argc] = "locked";
i++;
} else if ($2 == "LOCKED=NO") {
- lockstate[argc] = 0;
+ lockstate[argc] = "unlocked";
i++;
} else
- lockstate[argc] = -1;
+ lockstate[argc] = "";
if ($2 == "WILLRELE" ||
$3 == "WILLRELE") {
@@ -175,7 +178,8 @@
i++;
}
if (argc == 0 && fstrans == "") {
- if (lockstate[0] == 1)
+ if (lockstate[0] == "locked" ||
+ lockstate[0] == "elocked")
fstrans = "NO";
else
fstrans = "YES";
@@ -249,12 +253,6 @@
echo ''
echo "#ifndef _${SYS}VNODE_IF_H_"
echo "#define _${SYS}VNODE_IF_H_"
-if [ ${lockdebug} -ne 0 ] ; then
- echo ''
- echo '#ifdef _KERNEL_OPT'
- echo '#include "opt_vnode_lockdebug.h"'
- echo '#endif /* _KERNEL_OPT */'
-fi
[ -z "${rump}" ] && echo "
extern const struct vnodeop_desc ${rump}vop_default_desc;"
echo
@@ -343,7 +341,12 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, \"\$NetBSD\$\");"
-[ ${lockdebug} -ne 0 ] && echo && echo '#include "opt_vnode_lockdebug.h"'
+if [ -z "${rump}" -a ${lockdebug} -ne 0 ] ; then
+ echo ''
+ echo '#ifdef _KERNEL_OPT'
+ echo '#include "opt_vnode_lockdebug.h"'
+ echo '#endif /* _KERNEL_OPT */'
+fi
echo '
#include <sys/param.h>
@@ -604,6 +607,33 @@
}
}
+static inline void
+assert_vop_unlocked(vnode_t *vp, const char *str)
+{
+
+ if (VOP_ISLOCKED(vp) == LK_EXCLUSIVE)
+ panic(\"%s: %p %d/%d is locked but should not be\",
+ str, vp, vp->v_tag, vp->v_type);
+}
+
+static inline void
+assert_vop_locked(vnode_t *vp, const char *str)
+{
+
+ if (VOP_ISLOCKED(vp) == LK_NONE)
+ panic(\"%s: %p %d/%d is not locked but should be\",
+ str, vp, vp->v_tag, vp->v_type);
+}
+
+static inline void
+assert_vop_elocked(vnode_t *vp, const char *str)
+{
+
+ if (VOP_ISLOCKED(vp) != LK_EXCLUSIVE)
+ panic(\"%s: %p %d/%d is not exclusive locked but should be\",
+ str, vp, vp->v_tag, vp->v_type);
+}
+
const struct vnodeop_desc vop_default_desc = {"
echo ' 0,
"default",
@@ -691,25 +721,16 @@
printf("{\n\tint error;\n\tbool mpsafe;\n\tstruct %s_args a;\n",
args_name);
printf("\tstruct mount *mp;\n");
- if (lockdebug) {
- printf("#ifdef VNODE_LOCKDEBUG\n");
- for (i=0; i<argc; i++) {
- if (lockstate[i] != -1)
- printf("\tint islocked_%s;\n", argname[i]);
- }
- printf("#endif\n");
- }
printf("\ta.a_desc = VDESC(%s);\n", name);
for (i=0; i<argc; i++) {
printf("\ta.a_%s = %s;\n", argname[i], argname[i]);
- if (lockdebug && lockstate[i] != -1) {
- printf("#ifdef VNODE_LOCKDEBUG\n");
- printf("\tislocked_%s = (VOP_ISLOCKED(%s) == LK_EXCLUSIVE);\n",
- argname[i], argname[i]);
- printf("\tif (islocked_%s != %d)\n", argname[i],
- lockstate[i]);
- printf("\t\tpanic(\"%s: %s: locked %%d, expected %%d\", islocked_%s, %d);\n", name, argname[i], argname[i], lockstate[i]);
- printf("#endif\n");
+ }
+ if (lockdebug) {
+ for (i=0; i<argc; i++) {
+ if (lockstate[i] == "")
+ continue;
+ printf("\tassert_vop_%s(%s, \"%s: %s\");\n",
+ lockstate[i], argname[i], name, argname[i]);
}
}
# This is done before generic vop_pre() because we want
diff -r 22a19dda1ac5 -r e6982eb79acc sys/kern/vnode_if.src
--- a/sys/kern/vnode_if.src Tue May 03 07:36:20 2022 +0000
+++ b/sys/kern/vnode_if.src Tue May 03 08:33:59 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: vnode_if.src,v 1.83 2021/10/20 03:08:18 thorpej Exp $
+# $NetBSD: vnode_if.src,v 1.84 2022/05/03 08:33:59 hannken Exp $
#
# Copyright (c) 1992, 1993
# The Regents of the University of California. All rights reserved.
@@ -96,7 +96,7 @@
vop_create {
VERSION 3
POST=vop_create_post
- IN LOCKED=YES struct vnode *dvp;
+ IN LOCKED=EXCL struct vnode *dvp;
OUT WILLMAKE struct vnode **vpp;
IN struct componentname *cnp;
IN struct vattr *vap;
@@ -111,7 +111,7 @@
vop_mknod {
VERSION 3
POST=vop_mknod_post
- IN LOCKED=YES struct vnode *dvp;
+ IN LOCKED=EXCL struct vnode *dvp;
OUT WILLMAKE struct vnode **vpp;
IN struct componentname *cnp;
IN struct vattr *vap;
@@ -170,7 +170,7 @@
vop_setattr {
PRE=vop_setattr_pre
POST=vop_setattr_post
- IN LOCKED=YES struct vnode *vp;
+ IN LOCKED=EXCL struct vnode *vp;
IN struct vattr *vap;
IN kauth_cred_t cred;
};
@@ -306,7 +306,7 @@
VERSION 3
PRE=vop_remove_pre
POST=vop_remove_post
- IN LOCKED=YES struct vnode *dvp;
+ IN LOCKED=EXCL struct vnode *dvp;
IN LOCKED=YES WILLPUT struct vnode *vp;
IN struct componentname *cnp;
CONTEXT nlink_t vp_new_nlink;
@@ -321,7 +321,7 @@
vop_link {
VERSION 2
POST=vop_link_post
- IN LOCKED=YES struct vnode *dvp;
+ IN LOCKED=EXCL struct vnode *dvp;
IN LOCKED=NO struct vnode *vp;
IN struct componentname *cnp;
};
@@ -336,8 +336,8 @@
#! rename tcnp RENAME, LOCKPARENT | LOCKLEAF | NOCACHE
#
vop_rename {
- IN LOCKED=NO WILLRELE struct vnode *fdvp;
- IN LOCKED=NO WILLRELE struct vnode *fvp;
+ IN WILLRELE struct vnode *fdvp;
+ IN WILLRELE struct vnode *fvp;
IN struct componentname *fcnp;
IN LOCKED=YES WILLPUT struct vnode *tdvp;
IN WILLPUT struct vnode *tvp;
@@ -353,7 +353,7 @@
vop_mkdir {
VERSION 3
POST=vop_mkdir_post
- IN LOCKED=YES struct vnode *dvp;
+ IN LOCKED=EXCL struct vnode *dvp;
OUT WILLMAKE struct vnode **vpp;
IN struct componentname *cnp;
IN struct vattr *vap;
@@ -369,8 +369,8 @@
VERSION 2
PRE=vop_rmdir_pre
POST=vop_rmdir_post
- IN LOCKED=YES struct vnode *dvp;
- IN LOCKED=YES WILLPUT struct vnode *vp;
+ IN LOCKED=EXCL struct vnode *dvp;
+ IN LOCKED=EXCL WILLPUT struct vnode *vp;
IN struct componentname *cnp;
};
@@ -383,7 +383,7 @@
vop_symlink {
VERSION 3
POST=vop_symlink_post
- IN LOCKED=YES struct vnode *dvp;
+ IN LOCKED=EXCL struct vnode *dvp;
OUT WILLMAKE struct vnode **vpp;
IN struct componentname *cnp;
IN struct vattr *vap;
@@ -426,7 +426,7 @@
#
vop_inactive {
VERSION 2
- IN LOCKED=YES struct vnode *vp;
+ IN LOCKED=EXCL struct vnode *vp;
INOUT bool *recycle;
};
@@ -436,7 +436,7 @@
vop_reclaim {
VERSION 2
FSTRANS=NO
- IN LOCKED=YES struct vnode *vp;
+ IN LOCKED=EXCL struct vnode *vp;
};
#
@@ -444,7 +444,7 @@
#
vop_lock {
FSTRANS=LOCK
- IN LOCKED=NO struct vnode *vp;
+ IN struct vnode *vp;
IN int flags;
};
@@ -521,7 +521,7 @@
#! whiteout cnp CREATE, LOCKPARENT
#
vop_whiteout {
- IN LOCKED=YES struct vnode *dvp;
+ IN LOCKED=EXCL struct vnode *dvp;
IN struct componentname *cnp;
IN int flags;
};
@@ -567,7 +567,7 @@
#
vop_setacl {
POST=vop_setacl_post
- IN struct vnode *vp;
+ IN LOCKED=EXCL struct vnode *vp;
IN acl_type_t type;
IN struct acl *aclp;
IN kauth_cred_t cred;
@@ -628,7 +628,7 @@
#% deleteextattr vp L L L
#
vop_deleteextattr {
- IN LOCKED=YES struct vnode *vp;
+ IN LOCKED=EXCL struct vnode *vp;
IN int attrnamespace;
IN const char *name;
IN kauth_cred_t cred;
@@ -638,7 +638,7 @@
#% setextattr vp L L L
#
vop_setextattr {
- IN LOCKED=YES struct vnode *vp;
Home |
Main Index |
Thread Index |
Old Index