diff options
author | Michael I. Bushnell <mib@gnu.org> | 1995-08-25 21:15:41 +0000 |
---|---|---|
committer | Michael I. Bushnell <mib@gnu.org> | 1995-08-25 21:15:41 +0000 |
commit | 4d67eb6e36ed6ebf0dcd8a2b8eecfe29f1b4f4f4 (patch) | |
tree | 06728fa04f3eb985b8c33a7bdc21bd97cf3bd71a /ufs/sizes.c | |
parent | f6063d391372b19a07b85ae240384ac40e11742a (diff) |
(indir_release): When freeing direct blocks mentioned in a single
indirect block, or single indirect blocks mentioned in a double, only
call the free routine (ffs_blkfree or indir_release, respectively) if
the block is actually allocated.
Diffstat (limited to 'ufs/sizes.c')
-rw-r--r-- | ufs/sizes.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/ufs/sizes.c b/ufs/sizes.c index 0e6b893e..8fc0b029 100644 --- a/ufs/sizes.c +++ b/ufs/sizes.c @@ -153,11 +153,12 @@ diskfs_truncate (struct node *np, { daddr_t *sindir = indir_block (indirs[1].bno); for (i = indirs[0].offset + 1; i < NINDIR (sblock); i++) - { - ffs_blkfree (np, sindir[i], sblock->fs_bsize); - sindir[i] = 0; - blocksfreed += btodb (sblock->fs_bsize); - } + if (sindir[i]) + { + ffs_blkfree (np, sindir[i], sblock->fs_bsize); + sindir[i] = 0; + blocksfreed += btodb (sblock->fs_bsize); + } record_poke (sindir, sblock->fs_bsize); } } @@ -180,10 +181,11 @@ diskfs_truncate (struct node *np, { daddr_t *dindir = indir_block (indirs[2].bno); for (i = indirs[1].offset + 1; i < NINDIR (sblock); i++) - { - blocksfreed += indir_release (np, dindir[i], INDIR_SINGLE); - dindir[i] = 0; - } + if (dindir[i]) + { + blocksfreed += indir_release (np, dindir[i], INDIR_SINGLE); + dindir[i] = 0; + } record_poke (dindir, sblock->fs_bsize); } } |