Fix a bug introduced in Lite2 with block allocation and full disk
conditions. Reported by Ian Dowse <iedowse@maths.tcd.ie>, based on patch in FreeBSD reviewed by Kirk McKusick.
This commit is contained in:
parent
21243f6205
commit
89670eb646
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ffs_balloc.c,v 1.16 2000/02/14 22:00:22 fvdl Exp $ */
|
||||
/* $NetBSD: ffs_balloc.c,v 1.17 2000/02/25 19:58:25 fvdl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1993
|
||||
@ -91,6 +91,7 @@ ffs_balloc(v)
|
||||
ufs_daddr_t newb, *bap, pref;
|
||||
int deallocated, osize, nsize, num, i, error;
|
||||
ufs_daddr_t *allocib, *blkp, *allocblk, allociblk[NIADDR + 1];
|
||||
int unwindidx = -1;
|
||||
#ifdef FFS_EI
|
||||
const int needswap = UFS_FSNEEDSWAP(fs);
|
||||
#endif
|
||||
@ -319,6 +320,8 @@ ffs_balloc(v)
|
||||
softdep_setup_allocindir_page(ip, lbn, bp,
|
||||
indirs[i].in_off, nb, 0, nbp);
|
||||
bap[indirs[i].in_off] = ufs_rw32(nb, needswap);
|
||||
if (allocib == NULL && unwindidx < 0)
|
||||
unwindidx = i - 1;
|
||||
/*
|
||||
* If required, write synchronously, otherwise use
|
||||
* delayed write.
|
||||
@ -361,8 +364,25 @@ fail:
|
||||
ffs_blkfree(ip, *blkp, fs->fs_bsize);
|
||||
deallocated += fs->fs_bsize;
|
||||
}
|
||||
if (allocib != NULL)
|
||||
if (allocib != NULL) {
|
||||
*allocib = 0;
|
||||
} else if (unwindidx >= 0) {
|
||||
int r;
|
||||
|
||||
r = bread(vp, indirs[unwindidx].in_lbn,
|
||||
(int)fs->fs_bsize, NOCRED, &bp);
|
||||
if (r) {
|
||||
panic("Could not unwind indirect block, error %d", r);
|
||||
brelse(bp);
|
||||
} else {
|
||||
bap = (ufs_daddr_t *)bp->b_data;
|
||||
bap[indirs[unwindidx].in_off] = 0;
|
||||
if (flags & B_SYNC)
|
||||
bwrite(bp);
|
||||
else
|
||||
bdwrite(bp);
|
||||
}
|
||||
}
|
||||
if (deallocated) {
|
||||
#ifdef QUOTA
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user