Module Name: src Committed By: hannken Date: Fri Aug 12 17:41:17 UTC 2011
Modified Files: src/sys/fs/union: union.h union_subr.c union_vnops.c Log Message: Change some `#ifdef DIAGNOSTIC' to `KASSERT'. Instead of a `pid_t' use a `lwp_t *' for locking diagnostics. No functional changes intended. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/fs/union/union.h cvs rdiff -u -r1.47 -r1.48 src/sys/fs/union/union_subr.c cvs rdiff -u -r1.44 -r1.45 src/sys/fs/union/union_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/fs/union/union.h diff -u src/sys/fs/union/union.h:1.19 src/sys/fs/union/union.h:1.20 --- src/sys/fs/union/union.h:1.19 Sun Aug 7 06:01:51 2011 +++ src/sys/fs/union/union.h Fri Aug 12 17:41:17 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: union.h,v 1.19 2011/08/07 06:01:51 hannken Exp $ */ +/* $NetBSD: union.h,v 1.20 2011/08/12 17:41:17 hannken Exp $ */ /* * Copyright (c) 1994 The Regents of the University of California. @@ -121,7 +121,7 @@ struct vnode **un_dircache; /* cached union stack */ off_t un_uppersz; /* size of upper object */ off_t un_lowersz; /* size of lower object */ - pid_t un_pid; /* DIAGNOSTIC only */ + lwp_t *un_lwp; /* DIAGNOSTIC only */ }; #define UN_WANTED 0x01 Index: src/sys/fs/union/union_subr.c diff -u src/sys/fs/union/union_subr.c:1.47 src/sys/fs/union/union_subr.c:1.48 --- src/sys/fs/union/union_subr.c:1.47 Fri Aug 12 06:40:10 2011 +++ src/sys/fs/union/union_subr.c Fri Aug 12 17:41:17 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: union_subr.c,v 1.47 2011/08/12 06:40:10 hannken Exp $ */ +/* $NetBSD: union_subr.c,v 1.48 2011/08/12 17:41:17 hannken Exp $ */ /* * Copyright (c) 1994 @@ -72,7 +72,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.47 2011/08/12 06:40:10 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.48 2011/08/12 17:41:17 hannken Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -437,13 +437,9 @@ * the lock on (uppervp) no other * process can hold the lock on (un). */ -#ifdef DIAGNOSTIC - if ((un->un_flags & UN_LOCKED) == 0) - panic("union: . not locked"); - else if (curproc && un->un_pid != curproc->p_pid && - un->un_pid > -1 && curproc->p_pid > -1) - panic("union: allocvp not lock owner"); -#endif + KASSERT((un->un_flags & UN_LOCKED) != 0); + KASSERT(curlwp == NULL || un->un_lwp == NULL || + un->un_lwp == curlwp); } else { if (un->un_flags & UN_LOCKED) { vrele(UNIONTOV(un)); @@ -454,12 +450,7 @@ } un->un_flags |= UN_LOCKED; -#ifdef DIAGNOSTIC - if (curproc) - un->un_pid = curproc->p_pid; - else - un->un_pid = -1; -#endif + un->un_lwp = curlwp; } /* @@ -588,12 +579,7 @@ if (un->un_uppervp) un->un_flags |= UN_ULOCK; -#ifdef DIAGNOSTIC - if (curproc) - un->un_pid = curproc->p_pid; - else - un->un_pid = -1; -#endif + un->un_lwp = curlwp; if (dvp && cnp && (lowervp != NULLVP)) { un->un_hash = cnp->cn_hash; un->un_path = malloc(cnp->cn_namelen+1, M_TEMP, M_WAITOK); Index: src/sys/fs/union/union_vnops.c diff -u src/sys/fs/union/union_vnops.c:1.44 src/sys/fs/union/union_vnops.c:1.45 --- src/sys/fs/union/union_vnops.c:1.44 Fri Aug 12 14:36:29 2011 +++ src/sys/fs/union/union_vnops.c Fri Aug 12 17:41:17 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: union_vnops.c,v 1.44 2011/08/12 14:36:29 hannken Exp $ */ +/* $NetBSD: union_vnops.c,v 1.45 2011/08/12 17:41:17 hannken Exp $ */ /* * Copyright (c) 1992, 1993, 1994, 1995 @@ -72,7 +72,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: union_vnops.c,v 1.44 2011/08/12 14:36:29 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: union_vnops.c,v 1.45 2011/08/12 17:41:17 hannken Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -1235,13 +1235,7 @@ dun = VTOUNION(ap->a_dvp); -#ifdef DIAGNOSTIC - if (!(ap->a_cnp->cn_flags & LOCKPARENT)) { - printf("union_link called without LOCKPARENT set!\n"); - error = EIO; /* need some error code for "caller is a bozo" */ - } else -#endif - + KASSERT((ap->a_cnp->cn_flags & LOCKPARENT) != 0); if (ap->a_dvp->v_op != ap->a_vp->v_op) { vp = ap->a_vp; @@ -1680,17 +1674,6 @@ flags = (flags & ~LK_SHARED) | LK_EXCLUSIVE; } - /* - * Need to do real lockmgr-style locking here. - * in the mean time, draining won't work quite right, - * which could lead to a few race conditions. - * the following test was here, but is not quite right, we - * still need to take the lock: - if ((flags & LK_TYPE_MASK) == LK_DRAIN) - return (0); - */ - - un = VTOUNION(vp); start: un = VTOUNION(vp); @@ -1718,22 +1701,14 @@ /* XXX ignores LK_NOWAIT */ if (un->un_flags & UN_LOCKED) { -#ifdef DIAGNOSTIC - if (curproc && un->un_pid == curproc->p_pid && - un->un_pid > -1 && curproc->p_pid > -1) - panic("union: locking against myself"); -#endif + KASSERT(curlwp == NULL || un->un_lwp == NULL || + un->un_lwp != curlwp); un->un_flags |= UN_WANTED; tsleep(&un->un_flags, PINOD, "unionlk2", 0); goto start; } -#ifdef DIAGNOSTIC - if (curproc) - un->un_pid = curproc->p_pid; - else - un->un_pid = -1; -#endif + un->un_lwp = curlwp; un->un_flags |= UN_LOCKED; return (0); @@ -1759,13 +1734,9 @@ } */ *ap = v; struct union_node *un = VTOUNION(ap->a_vp); -#ifdef DIAGNOSTIC - if ((un->un_flags & UN_LOCKED) == 0) - panic("union: unlock unlocked node"); - if (curproc && un->un_pid != curproc->p_pid && - curproc->p_pid > -1 && un->un_pid > -1) - panic("union: unlocking other process's union node"); -#endif + KASSERT((un->un_flags & UN_LOCKED) != 0); + KASSERT(curlwp == NULL || un->un_lwp == NULL || + un->un_lwp == curlwp); un->un_flags &= ~UN_LOCKED; @@ -1779,9 +1750,7 @@ wakeup( &un->un_flags); } -#ifdef DIAGNOSTIC - un->un_pid = 0; -#endif + un->un_lwp = NULL; return (0); } @@ -1895,15 +1864,9 @@ struct vnode *ovp = OTHERVP(ap->a_vp); struct buf *bp = ap->a_bp; -#ifdef DIAGNOSTIC - if (ovp == NULLVP) - panic("union_strategy: nil vp"); - if (!NODE_IS_SPECIAL(ovp)) { - if (((bp->b_flags & B_READ) == 0) && - (ovp == LOWERVP(bp->b_vp))) - panic("union_strategy: writing to lowervp"); - } -#endif + KASSERT(ovp != NULLVP); + if (!NODE_IS_SPECIAL(ovp)) + KASSERT((bp->b_flags & B_READ) || ovp != LOWERVP(bp->b_vp)); return (VOP_STRATEGY(ovp, bp)); } @@ -1918,15 +1881,9 @@ struct vnode *ovp = OTHERVP(ap->a_vp); struct buf *bp = ap->a_bp; -#ifdef DIAGNOSTIC - if (ovp == NULLVP) - panic("union_bwrite: nil vp"); - if (!NODE_IS_SPECIAL(ovp)) { - if (((bp->b_flags & B_READ) == 0) && - (ovp == LOWERVP(bp->b_vp))) - panic("union_strategy: writing to lowervp"); - } -#endif + KASSERT(ovp != NULLVP); + if (!NODE_IS_SPECIAL(ovp)) + KASSERT((bp->b_flags & B_READ) || ovp != LOWERVP(bp->b_vp)); return (VOP_BWRITE(ovp, bp)); }