summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1995-08-25 21:15:41 +0000
committerMichael I. Bushnell <mib@gnu.org>1995-08-25 21:15:41 +0000
commit02c679f4d19c6fe8d9692779fe9c573efac307cc (patch)
tree66eda65f68d97cbbfb657967906c868d5df78186
parent186b89d7a3aa71471a7652a9d159da7fc475ad65 (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.
-rw-r--r--ufs/sizes.c20
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);
}
}