Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/union Change some `#ifdef DIAGNOSTIC' to `KASSERT'.
details: https://anonhg.NetBSD.org/src/rev/d7aba84461eb
branches: trunk
changeset: 768242:d7aba84461eb
user: hannken <hannken%NetBSD.org@localhost>
date: Fri Aug 12 17:41:17 2011 +0000
description:
Change some `#ifdef DIAGNOSTIC' to `KASSERT'.
Instead of a `pid_t' use a `lwp_t *' for locking diagnostics.
No functional changes intended.
diffstat:
sys/fs/union/union.h | 4 +-
sys/fs/union/union_subr.c | 28 ++++------------
sys/fs/union/union_vnops.c | 75 +++++++++------------------------------------
3 files changed, 25 insertions(+), 82 deletions(-)
diffs (224 lines):
diff -r e7293f103b19 -r d7aba84461eb sys/fs/union/union.h
--- a/sys/fs/union/union.h Fri Aug 12 17:40:49 2011 +0000
+++ b/sys/fs/union/union.h Fri Aug 12 17:41:17 2011 +0000
@@ -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
diff -r e7293f103b19 -r d7aba84461eb sys/fs/union/union_subr.c
--- a/sys/fs/union/union_subr.c Fri Aug 12 17:40:49 2011 +0000
+++ b/sys/fs/union/union_subr.c Fri Aug 12 17:41:17 2011 +0000
@@ -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);
diff -r e7293f103b19 -r d7aba84461eb sys/fs/union/union_vnops.c
--- a/sys/fs/union/union_vnops.c Fri Aug 12 17:40:49 2011 +0000
+++ b/sys/fs/union/union_vnops.c Fri Aug 12 17:41:17 2011 +0000
@@ -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));
}
Home |
Main Index |
Thread Index |
Old Index