Performance enhancement from Kirk McKusick <mckusick@McKusick.COM>:
When freeing an indirect block, there is no need to write it (synchronously, no less!) before tossing it.
This commit is contained in:
parent
ccce082dd2
commit
34e2fb3bb6
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ffs_inode.c,v 1.11 1996/09/01 23:49:21 mycroft Exp $ */
|
||||
/* $NetBSD: ffs_inode.c,v 1.12 1996/11/06 03:02:59 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1993
|
||||
|
@ -397,7 +397,7 @@ ffs_indirtrunc(ip, lbn, dbn, lastbn, level, countp)
|
|||
register struct fs *fs = ip->i_fs;
|
||||
register daddr_t *bap;
|
||||
struct vnode *vp;
|
||||
daddr_t *copy, nb, nlbn, last;
|
||||
daddr_t *copy = NULL, nb, nlbn, last;
|
||||
long blkcount, factor;
|
||||
int nblocks, blocksreleased = 0;
|
||||
int error = 0, allerror = 0;
|
||||
|
@ -444,16 +444,16 @@ ffs_indirtrunc(ip, lbn, dbn, lastbn, level, countp)
|
|||
}
|
||||
|
||||
bap = (daddr_t *)bp->b_data;
|
||||
MALLOC(copy, daddr_t *, fs->fs_bsize, M_TEMP, M_WAITOK);
|
||||
bcopy((caddr_t)bap, (caddr_t)copy, (u_int)fs->fs_bsize);
|
||||
bzero((caddr_t)&bap[last + 1],
|
||||
(u_int)(NINDIR(fs) - (last + 1)) * sizeof (daddr_t));
|
||||
if (last == -1)
|
||||
bp->b_flags |= B_INVAL;
|
||||
error = bwrite(bp);
|
||||
if (error)
|
||||
allerror = error;
|
||||
bap = copy;
|
||||
if (lastbn != -1) {
|
||||
MALLOC(copy, daddr_t *, fs->fs_bsize, M_TEMP, M_WAITOK);
|
||||
bcopy((caddr_t)bap, (caddr_t)copy, (u_int)fs->fs_bsize);
|
||||
bzero((caddr_t)&bap[last + 1],
|
||||
(u_int)(NINDIR(fs) - (last + 1)) * sizeof (daddr_t));
|
||||
error = bwrite(bp);
|
||||
if (error)
|
||||
allerror = error;
|
||||
bap = copy;
|
||||
}
|
||||
|
||||
/*
|
||||
* Recursively free totally unused blocks.
|
||||
|
@ -489,7 +489,14 @@ ffs_indirtrunc(ip, lbn, dbn, lastbn, level, countp)
|
|||
blocksreleased += blkcount;
|
||||
}
|
||||
}
|
||||
FREE(copy, M_TEMP);
|
||||
|
||||
if (copy != NULL) {
|
||||
FREE(copy, M_TEMP);
|
||||
} else {
|
||||
bp->b_flags |= B_INVAL;
|
||||
brelse(bp);
|
||||
}
|
||||
|
||||
*countp = blocksreleased;
|
||||
return (allerror);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue