Change VOP_BWRITE() to take a vnode as its first argument like all other

VOPs do.  Layered file systems no longer have to modify bp->b_vp and run
into trouble when an async VOP_BWRITE() uses the wrong vnode.

Adresses PR kern/38762 panic: vwakeup: neg numoutput

No objections from tech-kern@.
This commit is contained in:
hannken 2011-07-11 08:23:00 +00:00
parent 67e341bb50
commit 4094bb1a9f
2 changed files with 14 additions and 37 deletions

View File

@ -29,7 +29,7 @@ copyright="\
* SUCH DAMAGE.
*/
"
SCRIPT_ID='$NetBSD: vnode_if.sh,v 1.57 2011/04/03 01:19:37 rmind Exp $'
SCRIPT_ID='$NetBSD: vnode_if.sh,v 1.58 2011/07/11 08:23:00 hannken Exp $'
# Script to produce VFS front-end sugar.
#
@ -247,7 +247,6 @@ function doit() {
printf(");\n");
}
BEGIN {
arg0special="";
vop_offset = 1; # start at 1, to count the 'default' op
printf("struct buf;\n");
@ -257,16 +256,6 @@ BEGIN {
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="vop_bwrite";
doit();
printf("\n/* End of special cases */\n");
if (rump)
printf("\n");
}
@ -420,10 +409,10 @@ function bodynorm() {
printf("#endif\n");
}
}
printf("\tmpsafe = (%s%s->v_vflag & VV_MPSAFE);\n", argname[0], arg0special);
printf("\tmpsafe = (%s->v_vflag & VV_MPSAFE);\n", argname[0]);
printf("\tif (!mpsafe) { KERNEL_LOCK(1, curlwp); }\n");
printf("\terror = (VCALL(%s%s, VOFFSET(%s), &a));\n",
argname[0], arg0special, name);
printf("\terror = (VCALL(%s, VOFFSET(%s), &a));\n",
argname[0], name);
printf("\tif (!mpsafe) { KERNEL_UNLOCK_ONE(curlwp); }\n");
if (willmake != -1) {
printf("#ifdef DIAGNOSTIC\n");
@ -460,21 +449,8 @@ function doit() {
bodynorm();
}
BEGIN {
printf("\n/* Special cases: */\n");
# start from 1 (vop_default is at 0)
argc=1;
willmake=-1;
argdir[0]="IN";
argtype[0]="struct buf *";
argname[0]="bp";
lockstate[0] = -1;
arg0special="->b_vp";
willrele[0]=0;
name="vop_bwrite";
doit();
printf("\n/* End of special cases */\n");
arg0special="";
}
'"$awk_parser" | sed -e "$anal_retentive"
@ -486,7 +462,6 @@ BEGIN {
echo "
const struct vnodeop_desc * const ${rump}vfs_op_descs[] = {
&${rump}vop_default_desc, /* MUST BE FIRST */
&${rump}vop_bwrite_desc, /* XXX: SPECIAL CASE */
"
# Body stuff

View File

@ -1,4 +1,4 @@
# $NetBSD: vnode_if.src,v 1.61 2011/04/02 23:05:50 rmind Exp $
# $NetBSD: vnode_if.src,v 1.62 2011/07/11 08:23:00 hannken Exp $
#
# Copyright (c) 1992, 1993
# The Regents of the University of California. All rights reserved.
@ -50,6 +50,14 @@
# parameter, the flags required for the initial namei() call are listed.
# Additional flags may be added to the namei() call, but these are required.
#
#
#% bwrite vp = = =
#
vop_bwrite {
IN struct vnode *vp;
IN struct buf *bp;
};
#
#% lookup dvp L L L
@ -456,13 +464,6 @@ vop_whiteout {
IN int flags;
};
#
# Needs work: no vp?
#
#vop_bwrite {
# IN struct buf *bp;
#};
#
#% getpages vp = = =
#
@ -516,6 +517,7 @@ vop_listextattr {
IN int attrnamespace;
INOUT struct uio *uio;
OUT size_t *size;
IN int flag;
IN kauth_cred_t cred;
};