Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ufs/ffs #if DIAGNOSTIC panic ---> KASSERT
details: https://anonhg.NetBSD.org/src/rev/15bb5a13662e
branches: trunk
changeset: 352130:15bb5a13662e
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sat Mar 18 05:20:04 2017 +0000
description:
#if DIAGNOSTIC panic ---> KASSERT
diffstat:
sys/ufs/ffs/ffs_alloc.c | 51 ++++++++++++++++++++++++++-------------------
sys/ufs/ffs/ffs_inode.c | 24 +++++++++++---------
sys/ufs/ffs/ffs_snapshot.c | 11 ++++-----
3 files changed, 47 insertions(+), 39 deletions(-)
diffs (158 lines):
diff -r 6d18a52ffae1 -r 15bb5a13662e sys/ufs/ffs/ffs_alloc.c
--- a/sys/ufs/ffs/ffs_alloc.c Fri Mar 17 23:43:43 2017 +0000
+++ b/sys/ufs/ffs/ffs_alloc.c Sat Mar 18 05:20:04 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_alloc.c,v 1.155 2017/03/01 10:42:45 hannken Exp $ */
+/* $NetBSD: ffs_alloc.c,v 1.156 2017/03/18 05:20:04 riastradh Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.155 2017/03/01 10:42:45 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.156 2017/03/18 05:20:04 riastradh Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@@ -226,15 +226,15 @@
#endif
*bnp = 0;
-#ifdef DIAGNOSTIC
- if (cred == NOCRED)
- panic("%s: missing credential", __func__);
- if ((u_int)size > fs->fs_bsize || ffs_fragoff(fs, size) != 0) {
- panic("%s: bad size: dev = 0x%llx, bsize = %d, size = %d, "
- "fs = %s", __func__, (unsigned long long)ip->i_dev,
- fs->fs_bsize, size, fs->fs_fsmnt);
- }
-#endif /* DIAGNOSTIC */
+
+ KASSERTMSG((cred != NOCRED), "missing credential");
+ KASSERTMSG(((u_int)size <= fs->fs_bsize),
+ "bad size: dev = 0x%llx, bsize = %d, size = %d, fs = %s",
+ (unsigned long long)ip->i_dev, fs->fs_bsize, size, fs->fs_fsmnt);
+ KASSERTMSG((ffs_fragoff(fs, size) == 0),
+ "bad size: dev = 0x%llx, bsize = %d, size = %d, fs = %s",
+ (unsigned long long)ip->i_dev, fs->fs_bsize, size, fs->fs_fsmnt);
+
if (size == fs->fs_bsize && fs->fs_cstotal.cs_nbfree == 0)
goto nospace;
if (freespace(fs, fs->fs_minfree) <= 0 &&
@@ -344,17 +344,24 @@
}
#endif
-#ifdef DIAGNOSTIC
- if (cred == NOCRED)
- panic("%s: missing credential", __func__);
- if ((u_int)osize > fs->fs_bsize || ffs_fragoff(fs, osize) != 0 ||
- (u_int)nsize > fs->fs_bsize || ffs_fragoff(fs, nsize) != 0) {
- panic("%s: bad size: dev = 0x%llx, bsize = %d, osize = %d, "
- "nsize = %d, fs = %s", __func__,
- (unsigned long long)ip->i_dev, fs->fs_bsize, osize, nsize,
- fs->fs_fsmnt);
- }
-#endif /* DIAGNOSTIC */
+ KASSERTMSG((cred != NOCRED), "missing credential");
+ KASSERTMSG(((u_int)osize <= fs->fs_bsize),
+ "bad size: dev=0x%llx, bsize=%d, osize=%d, nsize=%d, fs=%s",
+ (unsigned long long)ip->i_dev, fs->fs_bsize, osize, nsize,
+ fs->fs_fsmnt);
+ KASSERTMSG((ffs_fragoff(fs, osize) == 0),
+ "bad size: dev=0x%llx, bsize=%d, osize=%d, nsize=%d, fs=%s",
+ (unsigned long long)ip->i_dev, fs->fs_bsize, osize, nsize,
+ fs->fs_fsmnt);
+ KASSERTMSG(((u_int)nsize <= fs->fs_bsize),
+ "bad size: dev=0x%llx, bsize=%d, osize=%d, nsize=%d, fs=%s",
+ (unsigned long long)ip->i_dev, fs->fs_bsize, osize, nsize,
+ fs->fs_fsmnt);
+ KASSERTMSG((ffs_fragoff(fs, nsize) == 0),
+ "bad size: dev=0x%llx, bsize=%d, osize=%d, nsize=%d, fs=%s",
+ (unsigned long long)ip->i_dev, fs->fs_bsize, osize, nsize,
+ fs->fs_fsmnt);
+
if (freespace(fs, fs->fs_minfree) <= 0 &&
kauth_authorize_system(cred, KAUTH_SYSTEM_FS_RESERVEDSPACE, 0, NULL,
NULL, NULL) != 0) {
diff -r 6d18a52ffae1 -r 15bb5a13662e sys/ufs/ffs/ffs_inode.c
--- a/sys/ufs/ffs/ffs_inode.c Fri Mar 17 23:43:43 2017 +0000
+++ b/sys/ufs/ffs/ffs_inode.c Sat Mar 18 05:20:04 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_inode.c,v 1.123 2016/11/11 10:50:16 hannken Exp $ */
+/* $NetBSD: ffs_inode.c,v 1.124 2017/03/18 05:26:40 riastradh Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.123 2016/11/11 10:50:16 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.124 2017/03/18 05:26:40 riastradh Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@@ -527,17 +527,19 @@
}
done:
-#ifdef DIAGNOSTIC
for (level = SINGLE; level <= TRIPLE; level++)
- if (blks[UFS_NDADDR + level] != DIP(oip, ib[level]))
- panic("itrunc1");
+ KASSERTMSG((blks[UFS_NDADDR + level] == DIP(oip, ib[level])),
+ "itrunc1 blk mismatch: %jx != %jx",
+ (uintmax_t)blks[UFS_NDADDR + level],
+ (uintmax_t)DIP(oip, ib[level]));
for (i = 0; i < UFS_NDADDR; i++)
- if (blks[i] != DIP(oip, db[i]))
- panic("itrunc2");
- if (length == 0 &&
- (!LIST_EMPTY(&ovp->v_cleanblkhd) || !LIST_EMPTY(&ovp->v_dirtyblkhd)))
- panic("itrunc3");
-#endif /* DIAGNOSTIC */
+ KASSERTMSG((blks[i] == DIP(oip, db[i])),
+ "itrunc2 blk mismatch: %jx != %jx",
+ (uintmax_t)blks[i], (uintmax_t)DIP(oip, db[i]));
+ KASSERTMSG((length != 0 || LIST_EMPTY(&ovp->v_cleanblkhd)),
+ "itrunc3: zero length and nonempty cleanblkhd");
+ KASSERTMSG((length != 0 || LIST_EMPTY(&ovp->v_dirtyblkhd)),
+ "itrunc3: zero length and nonempty dirtyblkhd");
out:
/*
diff -r 6d18a52ffae1 -r 15bb5a13662e sys/ufs/ffs/ffs_snapshot.c
--- a/sys/ufs/ffs/ffs_snapshot.c Fri Mar 17 23:43:43 2017 +0000
+++ b/sys/ufs/ffs/ffs_snapshot.c Sat Mar 18 05:20:04 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_snapshot.c,v 1.146 2017/03/01 10:42:45 hannken Exp $ */
+/* $NetBSD: ffs_snapshot.c,v 1.147 2017/03/18 05:29:16 riastradh Exp $ */
/*
* Copyright 2000 Marshall Kirk McKusick. All Rights Reserved.
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.146 2017/03/01 10:42:45 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.147 2017/03/18 05:29:16 riastradh Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@@ -1993,10 +1993,9 @@
if (gen != si->si_gen)
goto retry;
}
-#ifdef DIAGNOSTIC
- if (blkno == BLK_SNAP && bp->b_lblkno >= 0)
- panic("ffs_copyonwrite: bad copy block");
-#endif
+ KASSERTMSG((blkno != BLK_SNAP || bp->b_lblkno < 0),
+ "ffs_copyonwrite: bad copy block: blkno %jd, lblkno %jd",
+ (intmax_t)blkno, (intmax_t)bp->b_lblkno);
if (blkno != 0)
continue;
Home |
Main Index |
Thread Index |
Old Index