Module Name:    src
Committed By:   hannken
Date:           Wed Feb 22 09:45:52 UTC 2017

Modified Files:
        src/sys/kern: vnode_if.sh vnode_if.src

Log Message:
Prepare to move fstrans into vnode_if.c, allow "FSTRANS=YES"
and "FSTRANS=NO" in the vop description.
Add fstrans_start()/fstrans_done() to all vops that have FSTRANS=YES
or have the first vnode unlocked.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/kern/vnode_if.sh
cvs rdiff -u -r1.69 -r1.70 src/sys/kern/vnode_if.src

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/vnode_if.sh
diff -u src/sys/kern/vnode_if.sh:1.61 src/sys/kern/vnode_if.sh:1.62
--- src/sys/kern/vnode_if.sh:1.61	Tue Jan 26 23:28:06 2016
+++ src/sys/kern/vnode_if.sh	Wed Feb 22 09:45:51 2017
@@ -29,7 +29,7 @@ copyright="\
  * SUCH DAMAGE.
  */
 "
-SCRIPT_ID='$NetBSD: vnode_if.sh,v 1.61 2016/01/26 23:28:06 pooka Exp $'
+SCRIPT_ID='$NetBSD: vnode_if.sh,v 1.62 2017/02/22 09:45:51 hannken Exp $'
 
 # Script to produce VFS front-end sugar.
 #
@@ -100,6 +100,7 @@ awk_parser='
 	args_name=$1;
 	argc=0;
 	willmake=-1;
+	fstrans=0;
 	next;
 }
 # Last line of description
@@ -112,6 +113,12 @@ awk_parser='
 	if ($1 == "VERSION") {
 		args_name=args_name "_v" $2;
 		next;
+	} else if ($1 == "FSTRANS=YES") {
+		fstrans = 1;
+		next;
+	} else if ($1 == "FSTRANS=NO") {
+		fstrans = -1;
+		next;
 	}
 
 	argdir[argc] = $1; i=2;
@@ -144,6 +151,8 @@ awk_parser='
 		willmake=argc;
 		i++;
 	}
+	if (argc == 0 && fstrans == 0 && lockstate[0] != 1)
+		fstrans = 1;
 
 	# XXX: replace non-portable types for rump.  We should really
 	# nuke the types from the kernel, but that is a battle for
@@ -305,6 +314,7 @@ echo '
 #include <sys/buf.h>
 #include <sys/vnode.h>
 #include <sys/lock.h>'
+[ -z "${rump}" ] && echo '#include <sys/fstrans.h>'
 [ ! -z "${rump}" ] && echo '#include <rump/rumpvnode_if.h>'		\
 	&& echo '#include <rump-sys/kern.h>'
 
@@ -397,6 +407,8 @@ function bodyrump() {
 function bodynorm() {
 	printf("{\n\tint error;\n\tbool mpsafe;\n\tstruct %s_args a;\n",
 		args_name);
+	if (fstrans == 1)
+		printf("\tstruct mount *mp = %s->v_mount;\n", argname[0]);
 	if (lockdebug) {
 		printf("#ifdef VNODE_LOCKDEBUG\n");
 		for (i=0; i<argc; i++) {
@@ -420,8 +432,12 @@ function bodynorm() {
 	}
 	printf("\tmpsafe = (%s->v_vflag & VV_MPSAFE);\n", argname[0]);
 	printf("\tif (!mpsafe) { KERNEL_LOCK(1, curlwp); }\n");
+	if (fstrans == 1)
+		printf("\tfstrans_start(mp, FSTRANS_SHARED);\n");
 	printf("\terror = (VCALL(%s, VOFFSET(%s), &a));\n",
 		argname[0], name);
+	if (fstrans == 1)
+		printf("\tfstrans_done(mp);\n");
 	printf("\tif (!mpsafe) { KERNEL_UNLOCK_ONE(curlwp); }\n");
 	if (willmake != -1) {
 		printf("#ifdef DIAGNOSTIC\n");

Index: src/sys/kern/vnode_if.src
diff -u src/sys/kern/vnode_if.src:1.69 src/sys/kern/vnode_if.src:1.70
--- src/sys/kern/vnode_if.src:1.69	Mon Apr 20 23:08:07 2015
+++ src/sys/kern/vnode_if.src	Wed Feb 22 09:45:51 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: vnode_if.src,v 1.69 2015/04/20 23:08:07 riastradh Exp $
+#	$NetBSD: vnode_if.src,v 1.70 2017/02/22 09:45:51 hannken Exp $
 #
 # Copyright (c) 1992, 1993
 #	The Regents of the University of California.  All rights reserved.
@@ -72,7 +72,7 @@ vop_bwrite {
 #
 vop_lookup {
 	VERSION 2
-	IN struct vnode *dvp;
+	IN LOCKED=YES struct vnode *dvp;
 	OUT WILLMAKE struct vnode **vpp;
 	IN struct componentname *cnp;
 };
@@ -136,7 +136,7 @@ vop_access {
 #% getattr    vp      L L L
 #
 vop_getattr {
-	IN struct vnode *vp;
+	IN LOCKED=YES struct vnode *vp;
 	IN struct vattr *vap;
 	IN kauth_cred_t cred;
 };
@@ -192,6 +192,7 @@ vop_fdiscard {
 #% ioctl      vp      U U U
 #
 vop_ioctl {
+	FSTRANS=NO
 	IN LOCKED=NO struct vnode *vp;
 	IN u_long command;
 	IN void *data;
@@ -203,6 +204,7 @@ vop_ioctl {
 #% fcntl      vp      U U U
 #
 vop_fcntl {
+	FSTRANS=NO
 	IN LOCKED=NO struct vnode *vp;
 	IN u_int command;
 	IN void *data;
@@ -230,6 +232,7 @@ vop_kqfilter {
 #% revoke     vp      U U U
 #
 vop_revoke {
+	FSTRANS=NO
 	IN LOCKED=NO struct vnode *vp;
 	IN int flags;
 };
@@ -392,6 +395,7 @@ vop_inactive {
 #% reclaim    vp      U U U
 #
 vop_reclaim {
+	FSTRANS=NO
 	IN LOCKED=NO struct vnode *vp;
 };
 
@@ -399,6 +403,7 @@ vop_reclaim {
 #% lock               vp      U L U
 #
 vop_lock {
+	FSTRANS=NO
 	IN LOCKED=NO struct vnode *vp;
 	IN int flags;
 };
@@ -407,6 +412,7 @@ vop_lock {
 #% unlock     vp      L U L
 #
 vop_unlock {
+	FSTRANS=NO
 	IN LOCKED=YES struct vnode *vp;
 };
 
@@ -441,6 +447,7 @@ vop_print {
 #% islocked   vp      = = =
 #
 vop_islocked {
+	FSTRANS=NO
 	IN struct vnode *vp;
 };
 
@@ -481,6 +488,7 @@ vop_whiteout {
 #% getpages	vp = = =
 #
 vop_getpages {
+	FSTRANS=NO
 	IN struct vnode *vp;
 	IN voff_t offset;
 	IN struct vm_page **m;
@@ -495,6 +503,7 @@ vop_getpages {
 #% putpages	vp = = =
 #
 vop_putpages {
+	FSTRANS=NO
 	IN struct vnode *vp;
 	IN voff_t offlo;
 	IN voff_t offhi;

Reply via email to