diff options
author | Constantine Sapuntzakis <csapuntz@cvs.openbsd.org> | 1998-12-05 16:50:42 +0000 |
---|---|---|
committer | Constantine Sapuntzakis <csapuntz@cvs.openbsd.org> | 1998-12-05 16:50:42 +0000 |
commit | 09221e0d39a8f8f51d8a4a958aaadf0fe03a7e4f (patch) | |
tree | e7147655dbb8093b8d0165ec078b470508a1c0d1 | |
parent | 65550f847eb22d7341ffc2e38f82b487376e0bcb (diff) |
Framework for generating automatic test code for locking discipline
in DIAGNOSTIC mode.
Added documentation to vfs_subr.c on locking needs of a couple calls.
Improvements to the vinvalbuf patch. We need to start over after we
let our pants down.
-rw-r--r-- | sys/kern/vfs_subr.c | 19 | ||||
-rw-r--r-- | sys/kern/vnode_if.c | 34 | ||||
-rw-r--r-- | sys/kern/vnode_if.sh | 19 | ||||
-rw-r--r-- | sys/sys/vnode.h | 3 |
4 files changed, 51 insertions, 24 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index a268067c23c..2e012441016 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.26 1998/12/04 15:57:01 csapuntz Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.27 1998/12/05 16:50:40 csapuntz Exp $ */ /* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */ /* @@ -1040,6 +1040,9 @@ vclean(vp, flags, p) vp->v_op = dead_vnodeop_p; vp->v_tag = VT_NON; vp->v_flag &= ~VXLOCK; +#ifdef DIAGNOSTIC + vp->v_flag &= ~VLOCKSWORK; +#endif if (vp->v_flag & VXWANT) { vp->v_flag &= ~VXWANT; wakeup((caddr_t)vp); @@ -1802,6 +1805,8 @@ fs_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p) /* * Update outstanding I/O count and do wakeup if requested. + * + * Manipulates v_numoutput. Must be called at splbio() */ void vwakeup(bp) @@ -1853,6 +1858,7 @@ vinvalbuf(vp, flags, cred, p, slpflag, slptimeo) } splx(s); } +loop: s = splbio(); for (;;) { if ((blist = vp->v_cleanblkhd.lh_first) && @@ -1890,17 +1896,16 @@ vinvalbuf(vp, flags, cred, p, slpflag, slptimeo) if ((bp->b_flags & B_DELWRI) && (flags & V_SAVE)) { splx(s); (void) VOP_BWRITE(bp); - s = splbio(); - break; + goto loop; } bp->b_flags |= B_INVAL; brelse(bp); } } - splx(s); if (!(flags & V_SAVEMETA) && (vp->v_dirtyblkhd.lh_first || vp->v_cleanblkhd.lh_first)) panic("vinvalbuf: flush failed"); + splx(s); return (0); } @@ -1949,6 +1954,8 @@ loop: /* * Associate a buffer with a vnode. + * + * Manipulates buffer vnode queues. Must be called at splbio(). */ void bgetvp(vp, bp) @@ -1972,6 +1979,8 @@ bgetvp(vp, bp) /* * Disassociate a buffer from a vnode. + * + * Manipulates vnode buffer queues. Must be called at splbio(). */ void brelvp(bp) @@ -1998,6 +2007,8 @@ brelvp(bp) * Reassign a buffer from one vnode to another. Used to assign buffers * to the appropriate clean or dirty list and to add newly dirty vnodes * to the appropriate filesystem syncer list. + * + * Manipulates vnode buffer queues. Must be called at splbio(). */ void reassignbuf(bp, newvp) diff --git a/sys/kern/vnode_if.c b/sys/kern/vnode_if.c index e2319524733..fb9ad91de03 100644 --- a/sys/kern/vnode_if.c +++ b/sys/kern/vnode_if.c @@ -58,6 +58,22 @@ struct vnodeop_desc vop_default_desc = { }; +int vop_islocked_vp_offsets[] = { + VOPARG_OFFSETOF(struct vop_islocked_args,a_vp), + VDESC_NO_OFFSET +}; +struct vnodeop_desc vop_islocked_desc = { + 0, + "vop_islocked", + 0, + vop_islocked_vp_offsets, + VDESC_NO_OFFSET, + VDESC_NO_OFFSET, + VDESC_NO_OFFSET, + VDESC_NO_OFFSET, + NULL, +}; + int vop_lookup_vp_offsets[] = { VOPARG_OFFSETOF(struct vop_lookup_args,a_dvp), VDESC_NO_OFFSET @@ -576,22 +592,6 @@ struct vnodeop_desc vop_print_desc = { NULL, }; -int vop_islocked_vp_offsets[] = { - VOPARG_OFFSETOF(struct vop_islocked_args,a_vp), - VDESC_NO_OFFSET -}; -struct vnodeop_desc vop_islocked_desc = { - 0, - "vop_islocked", - 0, - vop_islocked_vp_offsets, - VDESC_NO_OFFSET, - VDESC_NO_OFFSET, - VDESC_NO_OFFSET, - VDESC_NO_OFFSET, - NULL, -}; - int vop_pathconf_vp_offsets[] = { VOPARG_OFFSETOF(struct vop_pathconf_args,a_vp), VDESC_NO_OFFSET @@ -791,6 +791,7 @@ struct vnodeop_desc *vfs_op_descs[] = { &vop_strategy_desc, /* XXX: SPECIAL CASE */ &vop_bwrite_desc, /* XXX: SPECIAL CASE */ + &vop_islocked_desc, &vop_lookup_desc, &vop_create_desc, &vop_mknod_desc, @@ -823,7 +824,6 @@ struct vnodeop_desc *vfs_op_descs[] = { &vop_unlock_desc, &vop_bmap_desc, &vop_print_desc, - &vop_islocked_desc, &vop_pathconf_desc, &vop_advlock_desc, &vop_blkatoff_desc, diff --git a/sys/kern/vnode_if.sh b/sys/kern/vnode_if.sh index b859ec7f9df..9ddf086f8f7 100644 --- a/sys/kern/vnode_if.sh +++ b/sys/kern/vnode_if.sh @@ -33,7 +33,7 @@ copyright="\ * SUCH DAMAGE. */ " -SCRIPT_ID='$OpenBSD: vnode_if.sh,v 1.3 1996/04/19 16:09:13 niklas Exp $' +SCRIPT_ID='$OpenBSD: vnode_if.sh,v 1.4 1998/12/05 16:50:41 csapuntz Exp $' # SCRIPT_ID='$NetBSD: vnode_if.sh,v 1.9 1996/02/29 20:58:22 cgd Exp $' # Script to produce VFS front-end sugar. @@ -108,11 +108,19 @@ awk_parser=' # Middle lines of description { argdir[argc] = $1; i=2; - if ($2 == "WILLRELE") { + if ($2 == "WILLRELE" || + $3 == "WILLRELE") { willrele[argc] = 1; i++; } else willrele[argc] = 0; + + if ($2 == "SHOULDBELOCKED") { + shouldbelocked[argc] = 1; + i++; + } else + shouldbelocked[argc] = 0; + argtype[argc] = $i; i++; while (i < NF) { argtype[argc] = argtype[argc]" "$i; @@ -154,6 +162,7 @@ echo ' extern struct vnodeop_desc vop_default_desc; ' +echo '#include "systm.h"' # Body stuff # This awk program needs toupper() so define it if necessary. sed -e "$sed_prep" $src | $awk "$toupper"' @@ -197,6 +206,11 @@ function doit() { 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 (shouldbelocked[i]) { + printf ("#ifdef DIAGNOSTIC\n"); + printf ("\tif ((%s->v_flag & VLOCKSWORK) && !VOP_ISLOCKED(%s)) panic(\"%s: %s\");\n", argname[i], argname[i], name, argname[i]); + printf ("#endif\n"); + } } printf("\treturn (VCALL(%s%s, VOFFSET(%s), &a));\n}\n", argname[0], arg0special, name); @@ -209,6 +223,7 @@ END { argc=1; argtype[0]="struct buf *"; argname[0]="bp"; + shouldbelocked[0] = 0; arg0special="->b_vp"; name="vop_strategy"; doit(); diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 9485d7012bd..99cb6a9a707 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vnode.h,v 1.18 1998/11/15 17:15:01 art Exp $ */ +/* $OpenBSD: vnode.h,v 1.19 1998/12/05 16:50:40 csapuntz Exp $ */ /* $NetBSD: vnode.h,v 1.38 1996/02/29 20:59:05 cgd Exp $ */ /* @@ -133,6 +133,7 @@ struct vnode { #define VALIASED 0x0800 /* vnode has an alias */ #define VDIROP 0x1000 /* LFS: vnode is involved in a directory op */ #define VONFREELIST 0x2000 /* Vnode is on a free list */ +#define VLOCKSWORK 0x4000 /* FS supports locking discipline */ /* * Vnode attributes. A field value of VNOVAL represents a field whose value |