MFC: Turn most ffs 'DIAGNOSTIC's into INVARIANTS.

This commit is contained in:
obrien 2008-02-25 06:30:24 +00:00
parent fa064376d9
commit 3dba5af99a
9 changed files with 68 additions and 62 deletions

View File

@ -93,7 +93,7 @@ typedef ufs2_daddr_t allocfcn_t(struct inode *ip, int cg, ufs2_daddr_t bpref,
static ufs2_daddr_t ffs_alloccg(struct inode *, int, ufs2_daddr_t, int);
static ufs2_daddr_t
ffs_alloccgblk(struct inode *, struct buf *, ufs2_daddr_t);
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
static int ffs_checkblk(struct inode *, ufs2_daddr_t, long);
#endif
static ufs2_daddr_t ffs_clusteralloc(struct inode *, int, ufs2_daddr_t, int);
@ -151,7 +151,7 @@ ffs_alloc(ip, lbn, bpref, size, cred, bnp)
fs = ip->i_fs;
ump = ip->i_ump;
mtx_assert(UFS_MTX(ump), MA_OWNED);
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if ((u_int)size > fs->fs_bsize || fragoff(fs, size) != 0) {
printf("dev = %s, bsize = %ld, size = %d, fs = %s\n",
devtoname(ip->i_dev), (long)fs->fs_bsize, size,
@ -160,7 +160,7 @@ ffs_alloc(ip, lbn, bpref, size, cred, bnp)
}
if (cred == NOCRED)
panic("ffs_alloc: missing credential");
#endif /* DIAGNOSTIC */
#endif /* INVARIANTS */
reclaimed = 0;
retry:
#ifdef QUOTA
@ -251,7 +251,7 @@ ffs_realloccg(ip, lbprev, bprev, bpref, osize, nsize, cred, bpp)
bp = NULL;
ump = ip->i_ump;
mtx_assert(UFS_MTX(ump), MA_OWNED);
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (vp->v_mount->mnt_kern_flag & MNTK_SUSPENDED)
panic("ffs_realloccg: allocation on suspended filesystem");
if ((u_int)osize > fs->fs_bsize || fragoff(fs, osize) != 0 ||
@ -264,7 +264,7 @@ ffs_realloccg(ip, lbprev, bprev, bpref, osize, nsize, cred, bpp)
}
if (cred == NOCRED)
panic("ffs_realloccg: missing credential");
#endif /* DIAGNOSTIC */
#endif /* INVARIANTS */
reclaimed = 0;
retry:
if (suser_cred(cred, SUSER_ALLOWJAIL) &&
@ -505,7 +505,7 @@ ffs_reallocblks_ufs1(ap)
len = buflist->bs_nchildren;
start_lbn = buflist->bs_children[0]->b_lblkno;
end_lbn = start_lbn + len - 1;
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
for (i = 0; i < len; i++)
if (!ffs_checkblk(ip,
dbtofsb(fs, buflist->bs_children[i]->b_blkno), fs->fs_bsize))
@ -551,7 +551,7 @@ ffs_reallocblks_ufs1(ap)
if (end_lvl == 0 || (idp = &end_ap[end_lvl - 1])->in_off + 1 >= len) {
ssize = len;
} else {
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (start_lvl > 0 &&
start_ap[start_lvl - 1].in_lbn == idp->in_lbn)
panic("ffs_reallocblk: start == end");
@ -592,7 +592,7 @@ ffs_reallocblks_ufs1(ap)
bap = ebap;
soff = -i;
}
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (!ffs_checkblk(ip,
dbtofsb(fs, buflist->bs_children[i]->b_blkno), fs->fs_bsize))
panic("ffs_reallocblks: unallocated block 2");
@ -658,7 +658,7 @@ ffs_reallocblks_ufs1(ap)
dbtofsb(fs, buflist->bs_children[i]->b_blkno),
fs->fs_bsize, ip->i_number);
buflist->bs_children[i]->b_blkno = fsbtodb(fs, blkno);
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (!ffs_checkblk(ip,
dbtofsb(fs, buflist->bs_children[i]->b_blkno), fs->fs_bsize))
panic("ffs_reallocblks: unallocated block 3");
@ -713,7 +713,7 @@ ffs_reallocblks_ufs2(ap)
len = buflist->bs_nchildren;
start_lbn = buflist->bs_children[0]->b_lblkno;
end_lbn = start_lbn + len - 1;
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
for (i = 0; i < len; i++)
if (!ffs_checkblk(ip,
dbtofsb(fs, buflist->bs_children[i]->b_blkno), fs->fs_bsize))
@ -759,7 +759,7 @@ ffs_reallocblks_ufs2(ap)
if (end_lvl == 0 || (idp = &end_ap[end_lvl - 1])->in_off + 1 >= len) {
ssize = len;
} else {
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (start_lvl > 0 &&
start_ap[start_lvl - 1].in_lbn == idp->in_lbn)
panic("ffs_reallocblk: start == end");
@ -800,7 +800,7 @@ ffs_reallocblks_ufs2(ap)
bap = ebap;
soff = -i;
}
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (!ffs_checkblk(ip,
dbtofsb(fs, buflist->bs_children[i]->b_blkno), fs->fs_bsize))
panic("ffs_reallocblks: unallocated block 2");
@ -866,7 +866,7 @@ ffs_reallocblks_ufs2(ap)
dbtofsb(fs, buflist->bs_children[i]->b_blkno),
fs->fs_bsize, ip->i_number);
buflist->bs_children[i]->b_blkno = fsbtodb(fs, blkno);
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (!ffs_checkblk(ip,
dbtofsb(fs, buflist->bs_children[i]->b_blkno), fs->fs_bsize))
panic("ffs_reallocblks: unallocated block 3");
@ -1262,7 +1262,7 @@ ffs_hashalloc(ip, cg, pref, size, allocator)
int i, icg = cg;
mtx_assert(UFS_MTX(ip->i_ump), MA_OWNED);
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (ITOV(ip)->v_mount->mnt_kern_flag & MNTK_SUSPENDED)
panic("ffs_hashalloc: allocation on suspended filesystem");
#endif
@ -1851,7 +1851,7 @@ ffs_blkfree(ump, fs, devvp, bno, size, inum)
ffs_snapblkfree(fs, devvp, bno, size, inum))
return;
}
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if ((u_int)size > fs->fs_bsize || fragoff(fs, size) != 0 ||
fragnum(fs, bno) + numfrags(fs, size) > fs->fs_frag) {
printf("dev=%s, bno = %jd, bsize = %ld, size = %ld, fs = %s\n",
@ -1946,7 +1946,7 @@ ffs_blkfree(ump, fs, devvp, bno, size, inum)
bdwrite(bp);
}
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
/*
* Verify allocation of a block or fragment. Returns true if block or
* fragment is allocated, false if it is free.
@ -1995,7 +1995,7 @@ ffs_checkblk(ip, bno, size)
brelse(bp);
return (!free);
}
#endif /* DIAGNOSTIC */
#endif /* INVARIANTS */
/*
* Free an inode.

View File

@ -220,7 +220,7 @@ ffs_balloc_ufs1(struct vnode *vp, off_t startoffset, int size,
pref = 0;
if ((error = ufs_getlbns(vp, lbn, indirs, &num)) != 0)
return(error);
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (num < 1)
panic ("ffs_balloc_ufs1: ufs_getlbns returned indirect block");
#endif
@ -692,7 +692,7 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size,
pref = 0;
if ((error = ufs_getlbns(vp, lbn, indirs, &num)) != 0)
return(error);
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (num < 1)
panic ("ffs_balloc_ufs2: ufs_getlbns returned indirect block");
#endif

View File

@ -226,7 +226,7 @@ ffs_truncate(vp, length, flags, cred, td)
if (vp->v_type == VLNK &&
(ip->i_size < vp->v_mount->mnt_maxsymlinklen ||
datablocks == 0)) {
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (length != 0)
panic("ffs_truncate: partial truncate of symlink");
#endif
@ -479,7 +479,7 @@ ffs_truncate(vp, length, flags, cred, td)
}
}
done:
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
for (level = SINGLE; level <= TRIPLE; level++)
if (newblks[NDADDR + level] != DIP(ip, i_ib[level]))
panic("ffs_truncate1");
@ -493,7 +493,7 @@ done:
vp->v_bufobj.bo_clean.bv_cnt > 0))
panic("ffs_truncate3");
VI_UNLOCK(vp);
#endif /* DIAGNOSTIC */
#endif /* INVARIANTS */
/*
* Put back the real size.
*/

View File

@ -2294,7 +2294,7 @@ ffs_copyonwrite(devvp, bp)
blkno=((ufs2_daddr_t *)(ibp->b_data))[indiroff];
bqrelse(ibp);
}
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (blkno == BLK_SNAP && bp->b_lblkno >= 0)
panic("ffs_copyonwrite: bad copy block");
#endif

View File

@ -42,11 +42,8 @@
__FBSDID("$FreeBSD$");
/*
* For now we want the safety net that the DIAGNOSTIC and DEBUG flags provide.
* For now we want the safety net that DEBUG flags provide.
*/
#ifndef DIAGNOSTIC
#define DIAGNOSTIC
#endif
#ifndef DEBUG
#define DEBUG
#endif
@ -2780,13 +2777,13 @@ handle_workitem_freeblocks(freeblks, flags)
vput(vp);
}
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (freeblks->fb_chkcnt != blocksreleased &&
((fs->fs_flags & FS_UNCLEAN) == 0 || (flags & LK_NOWAIT) != 0))
printf("handle_workitem_freeblocks: block count\n");
if (allerror)
softdep_error("handle_workitem_freeblks", allerror);
#endif /* DIAGNOSTIC */
#endif /* INVARIANTS */
ACQUIRE_LOCK(&lk);
WORKITEM_FREE(freeblks, D_FREEBLKS);
@ -3875,7 +3872,10 @@ initiate_write_inodeblock_ufs1(inodedep, bp)
struct ufs1_dinode *dp;
struct ufs1_dinode *sip;
struct fs *fs;
ufs_lbn_t i, prevlbn = 0;
ufs_lbn_t i;
#ifdef INVARIANTS
ufs_lbn_t prevlbn = 0;
#endif
int deplist;
if (inodedep->id_state & IOSTARTED)
@ -3913,7 +3913,7 @@ initiate_write_inodeblock_ufs1(inodedep, bp)
*/
for (deplist = 0, adp = TAILQ_FIRST(&inodedep->id_inoupdt); adp;
adp = TAILQ_NEXT(adp, ad_next)) {
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (deplist != 0 && prevlbn >= adp->ad_lbn)
panic("softdep_write_inodeblock: lbn order");
prevlbn = adp->ad_lbn;
@ -3935,7 +3935,7 @@ initiate_write_inodeblock_ufs1(inodedep, bp)
if ((adp->ad_state & ATTACHED) == 0)
panic("softdep_write_inodeblock: Unknown state 0x%x",
adp->ad_state);
#endif /* DIAGNOSTIC */
#endif /* INVARIANTS */
adp->ad_state &= ~ATTACHED;
adp->ad_state |= UNDONE;
}
@ -3955,18 +3955,18 @@ initiate_write_inodeblock_ufs1(inodedep, bp)
continue;
dp->di_size = fs->fs_bsize * adp->ad_lbn + adp->ad_oldsize;
for (i = adp->ad_lbn + 1; i < NDADDR; i++) {
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (dp->di_db[i] != 0 && (deplist & (1 << i)) == 0)
panic("softdep_write_inodeblock: lost dep1");
#endif /* DIAGNOSTIC */
#endif /* INVARIANTS */
dp->di_db[i] = 0;
}
for (i = 0; i < NIADDR; i++) {
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (dp->di_ib[i] != 0 &&
(deplist & ((1 << NDADDR) << i)) == 0)
panic("softdep_write_inodeblock: lost dep2");
#endif /* DIAGNOSTIC */
#endif /* INVARIANTS */
dp->di_ib[i] = 0;
}
return;
@ -4018,7 +4018,10 @@ initiate_write_inodeblock_ufs2(inodedep, bp)
struct ufs2_dinode *dp;
struct ufs2_dinode *sip;
struct fs *fs;
ufs_lbn_t i, prevlbn = 0;
ufs_lbn_t i;
#ifdef INVARIANTS
ufs_lbn_t prevlbn = 0;
#endif
int deplist;
if (inodedep->id_state & IOSTARTED)
@ -4057,7 +4060,7 @@ initiate_write_inodeblock_ufs2(inodedep, bp)
*/
for (deplist = 0, adp = TAILQ_FIRST(&inodedep->id_extupdt); adp;
adp = TAILQ_NEXT(adp, ad_next)) {
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (deplist != 0 && prevlbn >= adp->ad_lbn)
panic("softdep_write_inodeblock: lbn order");
prevlbn = adp->ad_lbn;
@ -4071,7 +4074,7 @@ initiate_write_inodeblock_ufs2(inodedep, bp)
if ((adp->ad_state & ATTACHED) == 0)
panic("softdep_write_inodeblock: Unknown state 0x%x",
adp->ad_state);
#endif /* DIAGNOSTIC */
#endif /* INVARIANTS */
adp->ad_state &= ~ATTACHED;
adp->ad_state |= UNDONE;
}
@ -4089,10 +4092,10 @@ initiate_write_inodeblock_ufs2(inodedep, bp)
continue;
dp->di_extsize = fs->fs_bsize * adp->ad_lbn + adp->ad_oldsize;
for (i = adp->ad_lbn + 1; i < NXADDR; i++) {
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (dp->di_extb[i] != 0 && (deplist & (1 << i)) == 0)
panic("softdep_write_inodeblock: lost dep1");
#endif /* DIAGNOSTIC */
#endif /* INVARIANTS */
dp->di_extb[i] = 0;
}
lastadp = NULL;
@ -4116,7 +4119,7 @@ initiate_write_inodeblock_ufs2(inodedep, bp)
*/
for (deplist = 0, adp = TAILQ_FIRST(&inodedep->id_inoupdt); adp;
adp = TAILQ_NEXT(adp, ad_next)) {
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (deplist != 0 && prevlbn >= adp->ad_lbn)
panic("softdep_write_inodeblock: lbn order");
prevlbn = adp->ad_lbn;
@ -4138,7 +4141,7 @@ initiate_write_inodeblock_ufs2(inodedep, bp)
if ((adp->ad_state & ATTACHED) == 0)
panic("softdep_write_inodeblock: Unknown state 0x%x",
adp->ad_state);
#endif /* DIAGNOSTIC */
#endif /* INVARIANTS */
adp->ad_state &= ~ATTACHED;
adp->ad_state |= UNDONE;
}
@ -4158,18 +4161,18 @@ initiate_write_inodeblock_ufs2(inodedep, bp)
continue;
dp->di_size = fs->fs_bsize * adp->ad_lbn + adp->ad_oldsize;
for (i = adp->ad_lbn + 1; i < NDADDR; i++) {
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (dp->di_db[i] != 0 && (deplist & (1 << i)) == 0)
panic("softdep_write_inodeblock: lost dep2");
#endif /* DIAGNOSTIC */
#endif /* INVARIANTS */
dp->di_db[i] = 0;
}
for (i = 0; i < NIADDR; i++) {
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (dp->di_ib[i] != 0 &&
(deplist & ((1 << NDADDR) << i)) == 0)
panic("softdep_write_inodeblock: lost dep3");
#endif /* DIAGNOSTIC */
#endif /* INVARIANTS */
dp->di_ib[i] = 0;
}
return;

View File

@ -319,7 +319,7 @@ loop:
passes -= 1;
goto loop;
}
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (!vn_isdisk(vp, NULL))
vprint("ffs_fsync: dirty", vp);
#endif
@ -435,7 +435,7 @@ ffs_read(ap)
seqcount = ap->a_ioflag >> IO_SEQSHIFT;
ip = VTOI(vp);
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (uio->uio_rw != UIO_READ)
panic("ffs_read: mode");
@ -557,7 +557,7 @@ ffs_read(ap)
break;
if ((ioflag & (IO_VMIO|IO_DIRECT)) &&
(LIST_FIRST(&bp->b_dep) == NULL)) {
(LIST_EMPTY(&bp->b_dep))) {
/*
* If there are no dependencies, and it's VMIO,
* then we don't need the buf, mark it available
@ -584,7 +584,7 @@ ffs_read(ap)
*/
if (bp != NULL) {
if ((ioflag & (IO_VMIO|IO_DIRECT)) &&
(LIST_FIRST(&bp->b_dep) == NULL)) {
(LIST_EMPTY(&bp->b_dep))) {
bp->b_flags |= B_RELBUF;
brelse(bp);
} else {
@ -637,7 +637,7 @@ ffs_write(ap)
seqcount = ap->a_ioflag >> IO_SEQSHIFT;
ip = VTOI(vp);
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (uio->uio_rw != UIO_WRITE)
panic("ffs_write: mode");
#endif
@ -859,7 +859,7 @@ ffs_extread(struct vnode *vp, struct uio *uio, int ioflag)
fs = ip->i_fs;
dp = ip->i_din2;
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (uio->uio_rw != UIO_READ || fs->fs_magic != FS_UFS2_MAGIC)
panic("ffs_extread: mode");
@ -1018,7 +1018,10 @@ ffs_extwrite(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *ucred)
fs = ip->i_fs;
dp = ip->i_din2;
#ifdef DIAGNOSTIC
KASSERT(!(ip->i_flag & IN_SPACECOUNTED), ("inode %u: inode is dead",
ip->i_number));
#ifdef INVARIANTS
if (uio->uio_rw != UIO_WRITE || fs->fs_magic != FS_UFS2_MAGIC)
panic("ffs_extwrite: mode");
#endif

View File

@ -215,7 +215,7 @@ ufs_bmaparray(vp, bn, bnp, nbp, runp, runb)
ap->in_exists = 1;
bp = getblk(vp, metalbn, mp->mnt_stat.f_iosize, 0, 0, 0);
if ((bp->b_flags & B_CACHE) == 0) {
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (!daddr)
panic("ufs_bmaparray: indirect block not in cache");
#endif

View File

@ -657,7 +657,7 @@ ufs_makedirentry(ip, cnp, newdirp)
struct direct *newdirp;
{
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if ((cnp->cn_flags & SAVENAME) == 0)
panic("ufs_makedirentry: missing name");
#endif

View File

@ -834,7 +834,7 @@ ufs_link(ap)
struct direct newdir;
int error;
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if ((cnp->cn_flags & HASBUF) == 0)
panic("ufs_link: no name");
#endif
@ -900,7 +900,7 @@ ufs_whiteout(ap)
case CREATE:
/* create a new directory whiteout */
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if ((cnp->cn_flags & SAVENAME) == 0)
panic("ufs_whiteout: missing name");
if (dvp->v_mount->mnt_maxsymlinklen <= 0)
@ -916,7 +916,7 @@ ufs_whiteout(ap)
case DELETE:
/* remove an existing directory whiteout */
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if (dvp->v_mount->mnt_maxsymlinklen <= 0)
panic("ufs_whiteout: old format filesystem");
#endif
@ -977,7 +977,7 @@ ufs_rename(ap)
int doingdirectory = 0, oldparent = 0, newparent = 0;
int error = 0, ioflag;
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if ((tcnp->cn_flags & HASBUF) == 0 ||
(fcnp->cn_flags & HASBUF) == 0)
panic("ufs_rename: no name");
@ -1361,7 +1361,7 @@ ufs_mkdir(ap)
int error, dmode;
long blkoff;
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if ((cnp->cn_flags & HASBUF) == 0)
panic("ufs_mkdir: no name");
#endif
@ -2203,7 +2203,7 @@ ufs_makeinode(mode, dvp, vpp, cnp)
int error;
pdir = VTOI(dvp);
#ifdef DIAGNOSTIC
#ifdef INVARIANTS
if ((cnp->cn_flags & HASBUF) == 0)
panic("ufs_makeinode: no name");
#endif