Module Name: src Committed By: pooka Date: Wed Apr 14 13:58:51 UTC 2010
Modified Files: src/sys/kern: vnode_if.sh Log Message: Make rump vnode interface lightweight: the only things we really need are: 0) provide VOP_OP in the alternate RUMP_VOP_OP namespace and for each op: 1) schedule rump cpu 2) call VOP_OP 3) unschedule rump cpu While here, take the opportunity to get rid of _t lossage in the rump-exported interfaces. To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/sys/kern/vnode_if.sh 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.55 src/sys/kern/vnode_if.sh:1.56 --- src/sys/kern/vnode_if.sh:1.55 Wed Apr 14 12:19:50 2010 +++ src/sys/kern/vnode_if.sh Wed Apr 14 13:58:51 2010 @@ -29,7 +29,7 @@ * SUCH DAMAGE. */ " -SCRIPT_ID='$NetBSD: vnode_if.sh,v 1.55 2010/04/14 12:19:50 pooka Exp $' +SCRIPT_ID='$NetBSD: vnode_if.sh,v 1.56 2010/04/14 13:58:51 pooka Exp $' # Script to produce VFS front-end sugar. # @@ -96,7 +96,7 @@ /^#/ { next; } # First line of description /^vop_/ { - name=rump $1; + name=$1; argc=0; willmake=-1; next; @@ -143,11 +143,13 @@ # nuke the types from the kernel, but that is a battle for # another day. at = $i; - if (length(rump) != 0) { + if (rump) { if (at == "vm_prot_t") at = "int"; if (at == "voff_t") at = "off_t"; + if (at == "kauth_cred_t") + at = "struct kauth_cred *" } argtype[argc] = at; i++; @@ -205,23 +207,27 @@ echo '#include "opt_vnode_lockdebug.h"' echo '#endif /* _KERNEL_OPT */' fi -echo " -extern const struct vnodeop_desc ${rump}vop_default_desc; -" +[ -z "${rump}" ] && echo " +extern const struct vnodeop_desc ${rump}vop_default_desc;" +echo # Body stuff # This awk program needs toupper() so define it if necessary. sed -e "$sed_prep" $src | $awk -v rump=${rump} "$toupper"' function doit() { + name = rump name # Declare arg struct, descriptor. - printf("\n#define %s_DESCOFFSET %d\n", toupper(name), vop_offset++); - printf("struct %s_args {\n", name); - printf("\tconst struct vnodeop_desc * a_desc;\n"); - for (i=0; i<argc; i++) { - printf("\t%s a_%s;\n", argtype[i], argname[i]); + if (!rump) { + printf("\n#define %s_DESCOFFSET %d\n", + toupper(name), vop_offset++); + printf("struct %s_args {\n", name); + printf("\tconst struct vnodeop_desc * a_desc;\n"); + for (i=0; i<argc; i++) { + printf("\t%s a_%s;\n", argtype[i], argname[i]); + } + printf("};\n"); + printf("extern const struct vnodeop_desc %s_desc;\n", name); } - printf("};\n"); - printf("extern const struct vnodeop_desc %s_desc;\n", name); # Prototype it. protoarg = sprintf("int %s(", toupper(name)); protolen = length(protoarg); @@ -244,20 +250,30 @@ arg0special=""; vop_offset = 1; # start at 1, to count the 'default' op - printf("/* Special cases: */\n\nstruct buf;\n"); - printf("#ifndef _KERNEL\n#include <stdbool.h>\n#endif\n"); + printf("struct buf;\n"); + if (rump) { + printf("struct flock;\n"); + printf("struct knote;\n"); + printf("struct vm_page;\n"); + } + printf("\n#ifndef _KERNEL\n#include <stdbool.h>\n#endif\n"); + printf("\n/* Special cases: */\n"); argc=1; argtype[0]="struct buf *"; argname[0]="bp"; lockstate[0] = -1; arg0special="->b_vp"; - name=rump "vop_bwrite"; + name="vop_bwrite"; doit(); printf("\n/* End of special cases */\n"); + if (rump) + printf("\n"); } END { - printf("\n#define VNODE_OPS_COUNT\t%d\n", vop_offset); + if (!rump) { + printf("\n#define VNODE_OPS_COUNT\t%d\n", vop_offset); + } } '"$awk_parser" | sed -e "$anal_retentive" @@ -295,8 +311,9 @@ [ ! -z "${rump}" ] && echo '#include <rump/rumpvnode_if.h>' \ && echo '#include "rump_private.h"' -echo " -const struct vnodeop_desc ${rump}vop_default_desc = {" +if [ -z "${rump}" ] ; then + echo " +const struct vnodeop_desc vop_default_desc = {" echo ' 0, "default", 0, @@ -306,6 +323,7 @@ VDESC_NO_OFFSET, }; ' +fi # Body stuff sed -e "$sed_prep" $src | $awk -v rump=${rump} -v lockdebug=${lockdebug} ' @@ -321,9 +339,9 @@ return -1; } -function doit() { +function offsets() { # Define offsets array - printf("\nconst int %s_vp_offsets[] = {\n", name); + printf("const int %s_vp_offsets[] = {\n", name); for (i=0; i<argc; i++) { if (argtype[i] == "struct vnode *") { printf ("\tVOPARG_OFFSETOF(struct %s_args,a_%s),\n", @@ -368,14 +386,22 @@ # componentname do_offset("struct componentname *"); printf ("};\n"); +} - # Define function. - printf("int\n%s(", toupper(name)); +function bodyrump() { + printf("{\n\tint error;\n\n"); + printf("\trump_schedule();\n"); + printf("\terror = %s(", toupper(name)); for (i=0; i<argc; i++) { - printf("%s %s", argtype[i], argname[i]); - if (i < (argc-1)) printf(",\n "); + printf("%s", argname[i]); + if (i < (argc-1)) printf(", "); } - printf(")\n"); + printf(");\n"); + printf("\trump_unschedule();\n\n"); + printf("\treturn error;\n}\n"); +} + +function bodynorm() { printf("{\n\tint error;\n\tbool mpsafe;\n\tstruct %s_args a;\n", name); if (lockdebug) { printf("#ifdef VNODE_LOCKDEBUG\n"); @@ -399,14 +425,10 @@ } } printf("\tmpsafe = (%s%s->v_vflag & VV_MPSAFE);\n", argname[0], arg0special); - if (rump) - printf("\trump_schedule();\n"); printf("\tif (!mpsafe) { KERNEL_LOCK(1, curlwp); }\n"); printf("\terror = (VCALL(%s%s, VOFFSET(%s), &a));\n", argname[0], arg0special, name); printf("\tif (!mpsafe) { KERNEL_UNLOCK_ONE(curlwp); }\n"); - if (rump) - printf("\trump_unschedule();\n"); if (willmake != -1) { printf("#ifdef DIAGNOSTIC\n"); printf("\tif (error == 0)\n" \ @@ -417,6 +439,30 @@ } printf("\treturn error;\n}\n"); } + +function doit() { + printf("\n"); + if (!rump) + offsets(); + + if (rump) + extname = "RUMP_" toupper(name); + else + extname = toupper(name); + + # Define function. + printf("int\n%s(", extname); + for (i=0; i<argc; i++) { + printf("%s %s", argtype[i], argname[i]); + if (i < (argc-1)) printf(",\n "); + } + printf(")\n"); + + if (rump) + bodyrump(); + else + bodynorm(); +} BEGIN { printf("\n/* Special cases: */\n"); # start from 1 (vop_default is at 0) @@ -428,7 +474,7 @@ lockstate[0] = -1; arg0special="->b_vp"; willrele[0]=0; - name=rump "vop_bwrite"; + name="vop_bwrite"; doit(); printf("\n/* End of special cases */\n"); @@ -437,6 +483,7 @@ '"$awk_parser" | sed -e "$anal_retentive" # End stuff +[ -n "${rump}" ] && return # Add the vfs_op_descs array to the C file. # Begin stuff