Change some #ifdef DIAGNOSTIC' to
KASSERT'.
Instead of a `pid_t' use a `lwp_t *' for locking diagnostics. No functional changes intended.
This commit is contained in:
parent
bf2a34aeb3
commit
94fc281af2
@ -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.
|
* Copyright (c) 1994 The Regents of the University of California.
|
||||||
@ -121,7 +121,7 @@ struct union_node {
|
|||||||
struct vnode **un_dircache; /* cached union stack */
|
struct vnode **un_dircache; /* cached union stack */
|
||||||
off_t un_uppersz; /* size of upper object */
|
off_t un_uppersz; /* size of upper object */
|
||||||
off_t un_lowersz; /* size of lower 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
|
#define UN_WANTED 0x01
|
||||||
|
@ -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
|
* Copyright (c) 1994
|
||||||
@ -72,7 +72,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#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/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
@ -437,13 +437,9 @@ loop:
|
|||||||
* the lock on (uppervp) no other
|
* the lock on (uppervp) no other
|
||||||
* process can hold the lock on (un).
|
* process can hold the lock on (un).
|
||||||
*/
|
*/
|
||||||
#ifdef DIAGNOSTIC
|
KASSERT((un->un_flags & UN_LOCKED) != 0);
|
||||||
if ((un->un_flags & UN_LOCKED) == 0)
|
KASSERT(curlwp == NULL || un->un_lwp == NULL ||
|
||||||
panic("union: . not locked");
|
un->un_lwp == curlwp);
|
||||||
else if (curproc && un->un_pid != curproc->p_pid &&
|
|
||||||
un->un_pid > -1 && curproc->p_pid > -1)
|
|
||||||
panic("union: allocvp not lock owner");
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
if (un->un_flags & UN_LOCKED) {
|
if (un->un_flags & UN_LOCKED) {
|
||||||
vrele(UNIONTOV(un));
|
vrele(UNIONTOV(un));
|
||||||
@ -454,12 +450,7 @@ loop:
|
|||||||
}
|
}
|
||||||
un->un_flags |= UN_LOCKED;
|
un->un_flags |= UN_LOCKED;
|
||||||
|
|
||||||
#ifdef DIAGNOSTIC
|
un->un_lwp = curlwp;
|
||||||
if (curproc)
|
|
||||||
un->un_pid = curproc->p_pid;
|
|
||||||
else
|
|
||||||
un->un_pid = -1;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -588,12 +579,7 @@ loop:
|
|||||||
|
|
||||||
if (un->un_uppervp)
|
if (un->un_uppervp)
|
||||||
un->un_flags |= UN_ULOCK;
|
un->un_flags |= UN_ULOCK;
|
||||||
#ifdef DIAGNOSTIC
|
un->un_lwp = curlwp;
|
||||||
if (curproc)
|
|
||||||
un->un_pid = curproc->p_pid;
|
|
||||||
else
|
|
||||||
un->un_pid = -1;
|
|
||||||
#endif
|
|
||||||
if (dvp && cnp && (lowervp != NULLVP)) {
|
if (dvp && cnp && (lowervp != NULLVP)) {
|
||||||
un->un_hash = cnp->cn_hash;
|
un->un_hash = cnp->cn_hash;
|
||||||
un->un_path = malloc(cnp->cn_namelen+1, M_TEMP, M_WAITOK);
|
un->un_path = malloc(cnp->cn_namelen+1, M_TEMP, M_WAITOK);
|
||||||
|
@ -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
|
* Copyright (c) 1992, 1993, 1994, 1995
|
||||||
@ -72,7 +72,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#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/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
@ -1235,13 +1235,7 @@ union_link(void *v)
|
|||||||
|
|
||||||
dun = VTOUNION(ap->a_dvp);
|
dun = VTOUNION(ap->a_dvp);
|
||||||
|
|
||||||
#ifdef DIAGNOSTIC
|
KASSERT((ap->a_cnp->cn_flags & LOCKPARENT) != 0);
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
if (ap->a_dvp->v_op != ap->a_vp->v_op) {
|
if (ap->a_dvp->v_op != ap->a_vp->v_op) {
|
||||||
vp = ap->a_vp;
|
vp = ap->a_vp;
|
||||||
@ -1680,17 +1674,6 @@ union_lock(void *v)
|
|||||||
flags = (flags & ~LK_SHARED) | LK_EXCLUSIVE;
|
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:
|
start:
|
||||||
un = VTOUNION(vp);
|
un = VTOUNION(vp);
|
||||||
|
|
||||||
@ -1718,22 +1701,14 @@ start:
|
|||||||
|
|
||||||
/* XXX ignores LK_NOWAIT */
|
/* XXX ignores LK_NOWAIT */
|
||||||
if (un->un_flags & UN_LOCKED) {
|
if (un->un_flags & UN_LOCKED) {
|
||||||
#ifdef DIAGNOSTIC
|
KASSERT(curlwp == NULL || un->un_lwp == NULL ||
|
||||||
if (curproc && un->un_pid == curproc->p_pid &&
|
un->un_lwp != curlwp);
|
||||||
un->un_pid > -1 && curproc->p_pid > -1)
|
|
||||||
panic("union: locking against myself");
|
|
||||||
#endif
|
|
||||||
un->un_flags |= UN_WANTED;
|
un->un_flags |= UN_WANTED;
|
||||||
tsleep(&un->un_flags, PINOD, "unionlk2", 0);
|
tsleep(&un->un_flags, PINOD, "unionlk2", 0);
|
||||||
goto start;
|
goto start;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DIAGNOSTIC
|
un->un_lwp = curlwp;
|
||||||
if (curproc)
|
|
||||||
un->un_pid = curproc->p_pid;
|
|
||||||
else
|
|
||||||
un->un_pid = -1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
un->un_flags |= UN_LOCKED;
|
un->un_flags |= UN_LOCKED;
|
||||||
return (0);
|
return (0);
|
||||||
@ -1759,13 +1734,9 @@ union_unlock(void *v)
|
|||||||
} */ *ap = v;
|
} */ *ap = v;
|
||||||
struct union_node *un = VTOUNION(ap->a_vp);
|
struct union_node *un = VTOUNION(ap->a_vp);
|
||||||
|
|
||||||
#ifdef DIAGNOSTIC
|
KASSERT((un->un_flags & UN_LOCKED) != 0);
|
||||||
if ((un->un_flags & UN_LOCKED) == 0)
|
KASSERT(curlwp == NULL || un->un_lwp == NULL ||
|
||||||
panic("union: unlock unlocked node");
|
un->un_lwp == curlwp);
|
||||||
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
|
|
||||||
|
|
||||||
un->un_flags &= ~UN_LOCKED;
|
un->un_flags &= ~UN_LOCKED;
|
||||||
|
|
||||||
@ -1779,9 +1750,7 @@ union_unlock(void *v)
|
|||||||
wakeup( &un->un_flags);
|
wakeup( &un->un_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DIAGNOSTIC
|
un->un_lwp = NULL;
|
||||||
un->un_pid = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -1895,15 +1864,9 @@ union_strategy(void *v)
|
|||||||
struct vnode *ovp = OTHERVP(ap->a_vp);
|
struct vnode *ovp = OTHERVP(ap->a_vp);
|
||||||
struct buf *bp = ap->a_bp;
|
struct buf *bp = ap->a_bp;
|
||||||
|
|
||||||
#ifdef DIAGNOSTIC
|
KASSERT(ovp != NULLVP);
|
||||||
if (ovp == NULLVP)
|
if (!NODE_IS_SPECIAL(ovp))
|
||||||
panic("union_strategy: nil vp");
|
KASSERT((bp->b_flags & B_READ) || ovp != LOWERVP(bp->b_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
|
|
||||||
|
|
||||||
return (VOP_STRATEGY(ovp, bp));
|
return (VOP_STRATEGY(ovp, bp));
|
||||||
}
|
}
|
||||||
@ -1918,15 +1881,9 @@ union_bwrite(void *v)
|
|||||||
struct vnode *ovp = OTHERVP(ap->a_vp);
|
struct vnode *ovp = OTHERVP(ap->a_vp);
|
||||||
struct buf *bp = ap->a_bp;
|
struct buf *bp = ap->a_bp;
|
||||||
|
|
||||||
#ifdef DIAGNOSTIC
|
KASSERT(ovp != NULLVP);
|
||||||
if (ovp == NULLVP)
|
if (!NODE_IS_SPECIAL(ovp))
|
||||||
panic("union_bwrite: nil vp");
|
KASSERT((bp->b_flags & B_READ) || ovp != LOWERVP(bp->b_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
|
|
||||||
|
|
||||||
return (VOP_BWRITE(ovp, bp));
|
return (VOP_BWRITE(ovp, bp));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user