summaryrefslogtreecommitdiffstats
path: root/sys/ufs/ffs
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2016-08-23 07:30:20 +0000
committerkib <kib@FreeBSD.org>2016-08-23 07:30:20 +0000
commit80939eabfe188aa5ce1d91e8686b65f3ea2cdff6 (patch)
tree15af3a7c15dd922c0eb83edd3717bff2ed7e93ad /sys/ufs/ffs
parent189f21d92e8c84d1470bf4c6beab4d3f0661bc98 (diff)
downloadFreeBSD-src-80939eabfe188aa5ce1d91e8686b65f3ea2cdff6.zip
FreeBSD-src-80939eabfe188aa5ce1d91e8686b65f3ea2cdff6.tar.gz
MFC r304231:
On unwind after failed block allocation in ffs_balloc_ufs{1,2}, assert that recorded allocated blocks numbers match the physical block numbers of dandling buffers which are released. When finally freeing the blocks during unwind, assert that dandling buffers where not re-allocated.
Diffstat (limited to 'sys/ufs/ffs')
-rw-r--r--sys/ufs/ffs/ffs_balloc.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c
index 79df83d..73fa051 100644
--- a/sys/ufs/ffs/ffs_balloc.c
+++ b/sys/ufs/ffs/ffs_balloc.c
@@ -487,6 +487,11 @@ fail:
bp = getblk(vp, *lbns_remfree, fs->fs_bsize, 0, 0,
GB_NOCREAT | GB_UNMAPPED);
if (bp != NULL) {
+ KASSERT(bp->b_blkno == fsbtodb(fs, *blkp),
+ ("mismatch1 l %jd %jd b %ju %ju",
+ (intmax_t)bp->b_lblkno, (uintmax_t)*lbns_remfree,
+ (uintmax_t)bp->b_blkno,
+ (uintmax_t)fsbtodb(fs, *blkp)));
bp->b_flags |= (B_INVAL | B_RELBUF);
bp->b_flags &= ~B_ASYNC;
brelse(bp);
@@ -531,6 +536,18 @@ fail:
* cleared, free the blocks.
*/
for (blkp = allociblk; blkp < allocblk; blkp++) {
+#ifdef INVARIANTS
+ if (blkp == allociblk)
+ lbns_remfree = lbns;
+ bp = getblk(vp, *lbns_remfree, fs->fs_bsize, 0, 0,
+ GB_NOCREAT | GB_UNMAPPED);
+ if (bp != NULL) {
+ panic("zombie1 %jd %ju %ju",
+ (intmax_t)bp->b_lblkno, (uintmax_t)bp->b_blkno,
+ (uintmax_t)fsbtodb(fs, *blkp));
+ }
+ lbns_remfree++;
+#endif
ffs_blkfree(ump, fs, ip->i_devvp, *blkp, fs->fs_bsize,
ip->i_number, vp->v_type, NULL);
}
@@ -1065,6 +1082,11 @@ fail:
bp = getblk(vp, *lbns_remfree, fs->fs_bsize, 0, 0,
GB_NOCREAT | GB_UNMAPPED);
if (bp != NULL) {
+ KASSERT(bp->b_blkno == fsbtodb(fs, *blkp),
+ ("mismatch2 l %jd %jd b %ju %ju",
+ (intmax_t)bp->b_lblkno, (uintmax_t)*lbns_remfree,
+ (uintmax_t)bp->b_blkno,
+ (uintmax_t)fsbtodb(fs, *blkp)));
bp->b_flags |= (B_INVAL | B_RELBUF);
bp->b_flags &= ~B_ASYNC;
brelse(bp);
@@ -1109,6 +1131,18 @@ fail:
* cleared, free the blocks.
*/
for (blkp = allociblk; blkp < allocblk; blkp++) {
+#ifdef INVARIANTS
+ if (blkp == allociblk)
+ lbns_remfree = lbns;
+ bp = getblk(vp, *lbns_remfree, fs->fs_bsize, 0, 0,
+ GB_NOCREAT | GB_UNMAPPED);
+ if (bp != NULL) {
+ panic("zombie2 %jd %ju %ju",
+ (intmax_t)bp->b_lblkno, (uintmax_t)bp->b_blkno,
+ (uintmax_t)fsbtodb(fs, *blkp));
+ }
+ lbns_remfree++;
+#endif
ffs_blkfree(ump, fs, ip->i_devvp, *blkp, fs->fs_bsize,
ip->i_number, vp->v_type, NULL);
}
OpenPOWER on IntegriCloud