Module Name: src
Committed By: riastradh
Date: Mon Mar 13 14:24:20 UTC 2017
Modified Files:
src/sys/ufs/lfs: lfs_alloc.c lfs_bio.c lfs_segment.c lfs_syscalls.c
lfs_vfsops.c ulfs_bmap.c ulfs_vnops.c
Log Message:
#if DIAGNOSTIC panic ---> KASSERT
Replace some #if DEBUG by this too. DEBUG is only for expensive
assertions; these are not.
To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 src/sys/ufs/lfs/lfs_alloc.c
cvs rdiff -u -r1.135 -r1.136 src/sys/ufs/lfs/lfs_bio.c
cvs rdiff -u -r1.263 -r1.264 src/sys/ufs/lfs/lfs_segment.c
cvs rdiff -u -r1.172 -r1.173 src/sys/ufs/lfs/lfs_syscalls.c
cvs rdiff -u -r1.352 -r1.353 src/sys/ufs/lfs/lfs_vfsops.c
cvs rdiff -u -r1.7 -r1.8 src/sys/ufs/lfs/ulfs_bmap.c
cvs rdiff -u -r1.44 -r1.45 src/sys/ufs/lfs/ulfs_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/ufs/lfs/lfs_alloc.c
diff -u src/sys/ufs/lfs/lfs_alloc.c:1.133 src/sys/ufs/lfs/lfs_alloc.c:1.134
--- src/sys/ufs/lfs/lfs_alloc.c:1.133 Sun Aug 7 05:09:12 2016
+++ src/sys/ufs/lfs/lfs_alloc.c Mon Mar 13 14:24:20 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_alloc.c,v 1.133 2016/08/07 05:09:12 dholland Exp $ */
+/* $NetBSD: lfs_alloc.c,v 1.134 2017/03/13 14:24:20 riastradh Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.133 2016/08/07 05:09:12 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.134 2017/03/13 14:24:20 riastradh Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@@ -168,10 +168,8 @@ lfs_extend_ifile(struct lfs *fs, kauth_c
*/
LFS_GET_HEADFREE(fs, cip, cbp, &oldlast);
LFS_PUT_HEADFREE(fs, cip, cbp, i);
-#ifdef DIAGNOSTIC
- if (lfs_sb_getfreehd(fs) == LFS_UNUSED_INUM)
- panic("inode 0 allocated [2]");
-#endif /* DIAGNOSTIC */
+ KASSERTMSG((lfs_sb_getfreehd(fs) != LFS_UNUSED_INUM),
+ "inode 0 allocated [2]");
/* inode number to stop at (XXX: why *x*max?) */
xmax = i + lfs_sb_getifpb(fs);
@@ -298,10 +296,8 @@ lfs_valloc(struct vnode *pvp, int mode,
return error;
}
}
-#ifdef DIAGNOSTIC
- if (lfs_sb_getfreehd(fs) == LFS_UNUSED_INUM)
- panic("inode 0 allocated [3]");
-#endif /* DIAGNOSTIC */
+ KASSERTMSG((lfs_sb_getfreehd(fs) != LFS_UNUSED_INUM),
+ "inode 0 allocated [3]");
/* Set superblock modified bit */
mutex_enter(&lfs_lock);
@@ -667,12 +663,8 @@ lfs_vfree(struct vnode *vp, ino_t ino, i
}
}
}
-#ifdef DIAGNOSTIC
/* XXX: shouldn't this check be further up *before* we trash the fs? */
- if (ino == LFS_UNUSED_INUM) {
- panic("inode 0 freed");
- }
-#endif /* DIAGNOSTIC */
+ KASSERTMSG((ino != LFS_UNUSED_INUM), "inode 0 freed");
/*
* Update the segment summary for the segment where the on-disk
@@ -681,18 +673,12 @@ lfs_vfree(struct vnode *vp, ino_t ino, i
if (old_iaddr != LFS_UNUSED_DADDR) {
/* load it */
LFS_SEGENTRY(sup, fs, lfs_dtosn(fs, old_iaddr), bp);
-#ifdef DIAGNOSTIC
/* the number of bytes in the segment should not become < 0 */
- if (sup->su_nbytes < DINOSIZE(fs)) {
- printf("lfs_vfree: negative byte count"
- " (segment %" PRIu32 " short by %d)\n",
- lfs_dtosn(fs, old_iaddr),
- (int)DINOSIZE(fs) -
- sup->su_nbytes);
- panic("lfs_vfree: negative byte count");
- sup->su_nbytes = DINOSIZE(fs);
- }
-#endif
+ KASSERTMSG((sup->su_nbytes >= DINOSIZE(fs)),
+ "lfs_vfree: negative byte count"
+ " (segment %" PRIu32 " short by %d)\n",
+ lfs_dtosn(fs, old_iaddr),
+ (int)DINOSIZE(fs) - sup->su_nbytes);
/* update the number of bytes in the segment */
sup->su_nbytes -= DINOSIZE(fs);
/* write the segment entry */
Index: src/sys/ufs/lfs/lfs_bio.c
diff -u src/sys/ufs/lfs/lfs_bio.c:1.135 src/sys/ufs/lfs/lfs_bio.c:1.136
--- src/sys/ufs/lfs/lfs_bio.c:1.135 Sat Oct 3 09:31:29 2015
+++ src/sys/ufs/lfs/lfs_bio.c Mon Mar 13 14:24:20 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_bio.c,v 1.135 2015/10/03 09:31:29 hannken Exp $ */
+/* $NetBSD: lfs_bio.c,v 1.136 2017/03/13 14:24:20 riastradh Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2008 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.135 2015/10/03 09:31:29 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_bio.c,v 1.136 2017/03/13 14:24:20 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -315,11 +315,9 @@ lfs_bwrite(void *v)
} */ *ap = v;
struct buf *bp = ap->a_bp;
-#ifdef DIAGNOSTIC
- if (VTOI(bp->b_vp)->i_lfs->lfs_ronly == 0 && (bp->b_flags & B_ASYNC)) {
- panic("bawrite LFS buffer");
- }
-#endif /* DIAGNOSTIC */
+ KASSERTMSG((VTOI(bp->b_vp)->i_lfs->lfs_ronly ||
+ !(bp->b_flags & B_ASYNC)),
+ "bawrite LFS buffer");
return lfs_bwrite_ext(bp, 0);
}
@@ -385,10 +383,7 @@ lfs_availwait(struct lfs *fs, int fsb)
#endif
lfs_wakeup_cleaner(fs);
-#ifdef DIAGNOSTIC
- if (LFS_SEGLOCK_HELD(fs))
- panic("lfs_availwait: deadlock");
-#endif
+ KASSERTMSG(!LFS_SEGLOCK_HELD(fs), "lfs_availwait: deadlock");
error = tsleep(&fs->lfs_availsleep, PCATCH | PUSER,
"cleaner", 0);
if (error)
@@ -717,12 +712,8 @@ lfs_newbuf(struct lfs *fs, struct vnode
bp->b_data = lfs_malloc(fs, nbytes, type);
/* memset(bp->b_data, 0, nbytes); */
}
-#ifdef DIAGNOSTIC
- if (vp == NULL)
- panic("vp is NULL in lfs_newbuf");
- if (bp == NULL)
- panic("bp is NULL after malloc in lfs_newbuf");
-#endif
+ KASSERT(vp != NULL);
+ KASSERT(bp != NULL);
bp->b_bufsize = size;
bp->b_bcount = size;
@@ -778,11 +769,9 @@ lfs_countlocked(int *count, long *bytes,
KASSERT(bp->b_iodone == NULL);
n++;
size += bp->b_bufsize;
-#ifdef DIAGNOSTIC
- if (n > nbuf)
- panic("lfs_countlocked: this can't happen: more"
- " buffers locked than exist");
-#endif
+ KASSERTMSG((n <= nbuf),
+ "lfs_countlocked: this can't happen: more"
+ " buffers locked than exist");
}
/*
* Theoretically this function never really does anything.
Index: src/sys/ufs/lfs/lfs_segment.c
diff -u src/sys/ufs/lfs/lfs_segment.c:1.263 src/sys/ufs/lfs/lfs_segment.c:1.264
--- src/sys/ufs/lfs/lfs_segment.c:1.263 Mon Oct 19 04:21:48 2015
+++ src/sys/ufs/lfs/lfs_segment.c Mon Mar 13 14:24:20 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_segment.c,v 1.263 2015/10/19 04:21:48 dholland Exp $ */
+/* $NetBSD: lfs_segment.c,v 1.264 2017/03/13 14:24:20 riastradh Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.263 2015/10/19 04:21:48 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.264 2017/03/13 14:24:20 riastradh Exp $");
#ifdef DEBUG
# define vndebug(vp, str) do { \
@@ -906,10 +906,8 @@ lfs_writefile(struct lfs *fs, struct seg
ip->i_lfs_fragsize[i] < lfs_sb_getbsize(fs))
++frag;
}
-#ifdef DIAGNOSTIC
- if (frag > 1)
- panic("lfs_writefile: more than one fragment!");
-#endif
+ KASSERTMSG((frag <= 1),
+ "lfs_writefile: more than one fragment! frag=%d", frag);
if (IS_FLUSHING(fs, vp) ||
(frag == 0 && (lfs_writeindir || (sp->seg_flags & SEGM_CKP)))) {
lfs_gather(fs, sp, vp, lfs_match_indir);
@@ -992,27 +990,21 @@ lfs_update_iaddr(struct lfs *fs, struct
*/
if (daddr != LFS_UNUSED_DADDR) {
u_int32_t oldsn = lfs_dtosn(fs, daddr);
-#ifdef DIAGNOSTIC
- int ndupino = (sp->seg_number == oldsn) ? sp->ndupino : 0;
-#endif
+ int ndupino __diagused =
+ (sp->seg_number == oldsn) ? sp->ndupino : 0;
LFS_SEGENTRY(sup, fs, oldsn, bp);
-#ifdef DIAGNOSTIC
- if (sup->su_nbytes + DINOSIZE(fs) * ndupino < DINOSIZE(fs)) {
- printf("lfs_writeinode: negative bytes "
- "(segment %" PRIu32 " short by %d, "
- "oldsn=%" PRIu32 ", cursn=%" PRIu32
- ", daddr=%" PRId64 ", su_nbytes=%u, "
- "ndupino=%d)\n",
- lfs_dtosn(fs, daddr),
- (int)DINOSIZE(fs) *
- (1 - sp->ndupino) - sup->su_nbytes,
- oldsn, sp->seg_number, daddr,
- (unsigned int)sup->su_nbytes,
- sp->ndupino);
- panic("lfs_writeinode: negative bytes");
- sup->su_nbytes = DINOSIZE(fs);
- }
-#endif
+ KASSERTMSG(((sup->su_nbytes + DINOSIZE(fs)*ndupino)
+ >= DINOSIZE(fs)),
+ "lfs_writeinode: negative bytes "
+ "(segment %" PRIu32 " short by %d, "
+ "oldsn=%" PRIu32 ", cursn=%" PRIu32
+ ", daddr=%" PRId64 ", su_nbytes=%u, "
+ "ndupino=%d)\n",
+ lfs_dtosn(fs, daddr),
+ (int)DINOSIZE(fs) * (1 - sp->ndupino) - sup->su_nbytes,
+ oldsn, sp->seg_number, daddr,
+ (unsigned int)sup->su_nbytes,
+ sp->ndupino);
DLOG((DLOG_SU, "seg %d -= %d for ino %d inode\n",
lfs_dtosn(fs, daddr), DINOSIZE(fs), ino));
sup->su_nbytes -= DINOSIZE(fs);
@@ -1313,10 +1305,8 @@ lfs_gatherblock(struct segment *sp, stru
* If full, finish this segment. We may be doing I/O, so
* release and reacquire the splbio().
*/
-#ifdef DIAGNOSTIC
- if (sp->vp == NULL)
- panic ("lfs_gatherblock: Null vp in segment");
-#endif
+ KASSERTMSG((sp->vp != NULL),
+ "lfs_gatherblock: Null vp in segment");
fs = sp->fs;
blksinblk = howmany(bp->b_bcount, lfs_sb_getbsize(fs));
if (sp->sum_bytes_left < sizeof(int32_t) * blksinblk ||
@@ -1545,37 +1535,26 @@ lfs_update_single(struct lfs *fs, struct
*/
if (daddr > 0) {
u_int32_t oldsn = lfs_dtosn(fs, daddr);
-#ifdef DIAGNOSTIC
- int ndupino;
+ int ndupino __diagused = (sp && sp->seg_number == oldsn ?
+ sp->ndupino : 0);
- if (sp && sp->seg_number == oldsn) {
- ndupino = sp->ndupino;
- } else {
- ndupino = 0;
- }
-#endif
KASSERT(oldsn < lfs_sb_getnseg(fs));
if (lbn >= 0 && lbn < ULFS_NDADDR)
osize = ip->i_lfs_fragsize[lbn];
else
osize = lfs_sb_getbsize(fs);
LFS_SEGENTRY(sup, fs, oldsn, bp);
-#ifdef DIAGNOSTIC
- if (sup->su_nbytes + DINOSIZE(fs) * ndupino < osize) {
- printf("lfs_updatemeta: negative bytes "
- "(segment %" PRIu32 " short by %" PRId64
- ")\n", lfs_dtosn(fs, daddr),
- (int64_t)osize -
- (DINOSIZE(fs) * ndupino + sup->su_nbytes));
- printf("lfs_updatemeta: ino %llu, lbn %" PRId64
- ", addr = 0x%" PRIx64 "\n",
- (unsigned long long)ip->i_number, lbn, daddr);
- printf("lfs_updatemeta: ndupino=%d\n", ndupino);
- panic("lfs_updatemeta: negative bytes");
- sup->su_nbytes = osize -
- DINOSIZE(fs) * ndupino;
- }
-#endif
+ KASSERTMSG(((sup->su_nbytes + DINOSIZE(fs)*ndupino) >= osize),
+ "lfs_updatemeta: negative bytes "
+ "(segment %" PRIu32 " short by %" PRId64
+ ")\n"
+ "lfs_updatemeta: ino %llu, lbn %" PRId64
+ ", addr = 0x%" PRIx64 "\n"
+ "lfs_updatemeta: ndupino=%d",
+ lfs_dtosn(fs, daddr),
+ (int64_t)osize - (DINOSIZE(fs) * ndupino + sup->su_nbytes),
+ (unsigned long long)ip->i_number, lbn, daddr,
+ ndupino);
DLOG((DLOG_SU, "seg %" PRIu32 " -= %d for ino %d lbn %" PRId64
" db 0x%" PRIx64 "\n",
lfs_dtosn(fs, daddr), osize,
@@ -2292,15 +2271,13 @@ lfs_writeseg(struct lfs *fs, struct segm
cbp->b_cflags |= BC_BUSY;
cbp->b_bcount = 0;
-#if defined(DEBUG) && defined(DIAGNOSTIC)
- if (bpp - sp->bpp > (lfs_sb_getsumsize(fs) - SEGSUM_SIZE(fs))
- / sizeof(int32_t)) {
- panic("lfs_writeseg: real bpp overwrite");
- }
- if (bpp - sp->bpp > lfs_segsize(fs) / lfs_sb_getfsize(fs)) {
- panic("lfs_writeseg: theoretical bpp overwrite");
- }
-#endif
+ KASSERTMSG((bpp - sp->bpp <=
+ (lfs_sb_getsumsize(fs) - SEGSUM_SIZE(fs))
+ / sizeof(int32_t)),
+ "lfs_writeseg: real bpp overwrite");
+ KASSERTMSG((bpp - sp->bpp <=
+ lfs_segsize(fs) / lfs_sb_getfsize(fs)),
+ "lfs_writeseg: theoretical bpp overwrite");
/*
* Construct the cluster.
@@ -2329,17 +2306,13 @@ lfs_writeseg(struct lfs *fs, struct segm
LFS_NB_CLUSTER);
cl->flags |= LFS_CL_MALLOC;
}
-#ifdef DIAGNOSTIC
- if (lfs_dtosn(fs, LFS_DBTOFSB(fs, bp->b_blkno +
- btodb(bp->b_bcount - 1))) !=
- sp->seg_number) {
- printf("blk size %d daddr %" PRIx64
- " not in seg %d\n",
- bp->b_bcount, bp->b_blkno,
- sp->seg_number);
- panic("segment overwrite");
- }
-#endif
+ KASSERTMSG((lfs_dtosn(fs, LFS_DBTOFSB(fs, bp->b_blkno +
+ btodb(bp->b_bcount - 1))) ==
+ sp->seg_number),
+ "segment overwrite: blk size %d daddr %" PRIx64
+ " not in seg %d\n",
+ bp->b_bcount, bp->b_blkno,
+ sp->seg_number);
#ifdef LFS_USE_B_INVAL
/*
@@ -2413,13 +2386,11 @@ lfs_writesuper(struct lfs *fs, daddr_t d
int s;
ASSERT_MAYBE_SEGLOCK(fs);
-#ifdef DIAGNOSTIC
if (fs->lfs_is64) {
KASSERT(fs->lfs_dlfs_u.u_64.dlfs_magic == LFS64_MAGIC);
} else {
KASSERT(fs->lfs_dlfs_u.u_32.dlfs_magic == LFS_MAGIC);
}
-#endif
/*
* If we can write one superblock while another is in
* progress, we risk not having a complete checkpoint if we crash.
@@ -2684,10 +2655,8 @@ lfs_cluster_aiodone(struct buf *bp)
wakeup(&cl->seg->seg_iocount);
}
mutex_enter(&lfs_lock);
-#ifdef DIAGNOSTIC
- if (fs->lfs_iocount == 0)
- panic("lfs_cluster_aiodone: zero iocount");
-#endif
+ KASSERTMSG((fs->lfs_iocount != 0),
+ "lfs_cluster_aiodone: zero iocount");
if (--fs->lfs_iocount <= 1)
wakeup(&fs->lfs_iocount);
mutex_exit(&lfs_lock);
Index: src/sys/ufs/lfs/lfs_syscalls.c
diff -u src/sys/ufs/lfs/lfs_syscalls.c:1.172 src/sys/ufs/lfs/lfs_syscalls.c:1.173
--- src/sys/ufs/lfs/lfs_syscalls.c:1.172 Thu Oct 15 06:15:48 2015
+++ src/sys/ufs/lfs/lfs_syscalls.c Mon Mar 13 14:24:20 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_syscalls.c,v 1.172 2015/10/15 06:15:48 dholland Exp $ */
+/* $NetBSD: lfs_syscalls.c,v 1.173 2017/03/13 14:24:20 riastradh Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007, 2008
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.172 2015/10/15 06:15:48 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.173 2017/03/13 14:24:20 riastradh Exp $");
#ifndef LFS
# define LFS /* for prototypes in syscallargs.h */
@@ -465,10 +465,7 @@ lfs_markv(struct lwp *l, fsid_t *fsidp,
numrefed--;
}
-#ifdef DIAGNOSTIC
- if (numrefed != 0)
- panic("lfs_markv: numrefed=%d", numrefed);
-#endif
+ KASSERTMSG((numrefed == 0), "lfs_markv: numrefed=%d", numrefed);
DLOG((DLOG_CLEAN, "lfs_markv: writing %d blks %d inos (check point)\n",
nblkwritten, ninowritten));
@@ -512,10 +509,7 @@ err3:
lfs_segunlock(fs);
vfs_unbusy(mntp, false, NULL);
-#ifdef DIAGNOSTIC
- if (numrefed != 0)
- panic("lfs_markv: numrefed=%d", numrefed);
-#endif
+ KASSERTMSG((numrefed == 0), "lfs_markv: numrefed=%d", numrefed);
return (error);
}
@@ -769,10 +763,7 @@ lfs_bmapv(struct lwp *l, fsid_t *fsidp,
numrefed--;
}
-#ifdef DIAGNOSTIC
- if (numrefed != 0)
- panic("lfs_bmapv: numrefed=%d", numrefed);
-#endif
+ KASSERTMSG((numrefed == 0), "lfs_bmapv: numrefed=%d", numrefed);
vfs_unbusy(mntp, false, NULL);
Index: src/sys/ufs/lfs/lfs_vfsops.c
diff -u src/sys/ufs/lfs/lfs_vfsops.c:1.352 src/sys/ufs/lfs/lfs_vfsops.c:1.353
--- src/sys/ufs/lfs/lfs_vfsops.c:1.352 Fri Feb 17 08:31:26 2017
+++ src/sys/ufs/lfs/lfs_vfsops.c Mon Mar 13 14:24:20 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: lfs_vfsops.c,v 1.352 2017/02/17 08:31:26 hannken Exp $ */
+/* $NetBSD: lfs_vfsops.c,v 1.353 2017/03/13 14:24:20 riastradh Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.352 2017/02/17 08:31:26 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.353 2017/03/13 14:24:20 riastradh Exp $");
#if defined(_KERNEL_OPT)
#include "opt_lfs.h"
@@ -2319,16 +2319,10 @@ lfs_vinit(struct mount *mp, struct vnode
ip->i_lfs_fragsize[i] = lfs_blksize(fs, ip, i);
}
-#ifdef DIAGNOSTIC
- if (vp->v_type == VNON) {
-# ifdef DEBUG
- lfs_dump_dinode(fs, ip->i_din);
-# endif
- panic("lfs_vinit: ino %llu is type VNON! (ifmt=%o)\n",
- (unsigned long long)ip->i_number,
- (ip->i_mode & LFS_IFMT) >> 12);
- }
-#endif /* DIAGNOSTIC */
+ KASSERTMSG((vp->v_type != VNON),
+ "lfs_vinit: ino %llu is type VNON! (ifmt=%o)\n",
+ (unsigned long long)ip->i_number,
+ (ip->i_mode & LFS_IFMT) >> 12);
/*
* Finish inode initialization now that aliasing has been resolved.
Index: src/sys/ufs/lfs/ulfs_bmap.c
diff -u src/sys/ufs/lfs/ulfs_bmap.c:1.7 src/sys/ufs/lfs/ulfs_bmap.c:1.8
--- src/sys/ufs/lfs/ulfs_bmap.c:1.7 Tue Sep 1 06:08:37 2015
+++ src/sys/ufs/lfs/ulfs_bmap.c Mon Mar 13 14:24:20 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ulfs_bmap.c,v 1.7 2015/09/01 06:08:37 dholland Exp $ */
+/* $NetBSD: ulfs_bmap.c,v 1.8 2017/03/13 14:24:20 riastradh Exp $ */
/* from NetBSD: ufs_bmap.c,v 1.50 2013/01/22 09:39:18 dholland Exp */
/*
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ulfs_bmap.c,v 1.7 2015/09/01 06:08:37 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ulfs_bmap.c,v 1.8 2017/03/13 14:24:20 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -152,10 +152,8 @@ ulfs_bmaparray(struct vnode *vp, daddr_t
mp = vp->v_mount;
ump = ip->i_ump;
fs = ip->i_lfs;
-#ifdef DIAGNOSTIC
- if ((ap != NULL && nump == NULL) || (ap == NULL && nump != NULL))
- panic("ulfs_bmaparray: invalid arguments");
-#endif
+ KASSERTMSG(((ap == NULL) == (nump == NULL)),
+ "ulfs_bmaparray: invalid arguments: ap=%p, nump=%p", ap, nump);
if (runp) {
/*
@@ -275,12 +273,9 @@ ulfs_bmaparray(struct vnode *vp, daddr_t
}
if (bp->b_oflags & (BO_DONE | BO_DELWRI)) {
trace(TR_BREADHIT, pack(vp, size), metalbn);
- }
-#ifdef DIAGNOSTIC
- else if (!daddr)
- panic("ulfs_bmaparray: indirect block not in cache");
-#endif
- else {
+ } else {
+ KASSERTMSG(daddr,
+ "ulfs_bmaparray: indirect block not in cache");
trace(TR_BREADMISS, pack(vp, size), metalbn);
bp->b_blkno = blkptrtodb(fs, daddr);
bp->b_flags |= B_READ;
Index: src/sys/ufs/lfs/ulfs_vnops.c
diff -u src/sys/ufs/lfs/ulfs_vnops.c:1.44 src/sys/ufs/lfs/ulfs_vnops.c:1.45
--- src/sys/ufs/lfs/ulfs_vnops.c:1.44 Mon Jun 20 03:36:09 2016
+++ src/sys/ufs/lfs/ulfs_vnops.c Mon Mar 13 14:24:20 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ulfs_vnops.c,v 1.44 2016/06/20 03:36:09 dholland Exp $ */
+/* $NetBSD: ulfs_vnops.c,v 1.45 2017/03/13 14:24:20 riastradh Exp $ */
/* from NetBSD: ufs_vnops.c,v 1.232 2016/05/19 18:32:03 riastradh Exp */
/*-
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.44 2016/06/20 03:36:09 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.45 2017/03/13 14:24:20 riastradh Exp $");
#if defined(_KERNEL_OPT)
#include "opt_lfs.h"
@@ -637,10 +637,8 @@ ulfs_whiteout(void *v)
case CREATE:
/* create a new directory whiteout */
fstrans_start(dvp->v_mount, FSTRANS_SHARED);
-#ifdef DIAGNOSTIC
- if (fs->um_maxsymlinklen <= 0)
- panic("ulfs_whiteout: old format filesystem");
-#endif
+ KASSERTMSG((fs->um_maxsymlinklen > 0),
+ "ulfs_whiteout: old format filesystem");
error = ulfs_direnter(dvp, ulr, NULL,
cnp, ULFS_WINO, LFS_DT_WHT, NULL);
@@ -649,10 +647,8 @@ ulfs_whiteout(void *v)
case DELETE:
/* remove an existing directory whiteout */
fstrans_start(dvp->v_mount, FSTRANS_SHARED);
-#ifdef DIAGNOSTIC
- if (fs->um_maxsymlinklen <= 0)
- panic("ulfs_whiteout: old format filesystem");
-#endif
+ KASSERTMSG((fs->um_maxsymlinklen > 0),
+ "ulfs_whiteout: old format filesystem");
cnp->cn_flags &= ~DOWHITEOUT;
error = ulfs_dirremove(dvp, ulr, NULL, cnp->cn_flags, 0);