diff options
author | Thorsten Lockert <tholo@cvs.openbsd.org> | 1996-11-05 03:30:13 +0000 |
---|---|---|
committer | Thorsten Lockert <tholo@cvs.openbsd.org> | 1996-11-05 03:30:13 +0000 |
commit | 253ad551947513c787aca41b08b779878550b7fe (patch) | |
tree | b9d141bf45d4234c04d8df4eef18f80230c5a90d /sys/ufs | |
parent | b2e5fe90a986c9327ee74a88385b5b635dd0ac6d (diff) |
Patch from Kirk McKusick:
The following change eliminates an unnecessary synchronous write
from the filesystem. When freeing an indirect block, there is no
need to write it (synchronously, no less!) before tossing it.
Diffstat (limited to 'sys/ufs')
-rw-r--r-- | sys/ufs/ffs/ffs_inode.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 855966780a4..6c33e684cbc 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_inode.c,v 1.3 1996/05/22 11:47:18 deraadt Exp $ */ +/* $OpenBSD: ffs_inode.c,v 1.4 1996/11/05 03:30:12 tholo Exp $ */ /* $NetBSD: ffs_inode.c,v 1.10 1996/05/11 18:27:19 mycroft Exp $ */ /* @@ -459,16 +459,20 @@ 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)); + if ((vp->v_mount->mnt_flag & MNT_ASYNC) == 0) { + error = bwrite(bp); + if (error) + allerror = error; + } else { + bawrite(bp); + } + bap = copy; + } /* * Recursively free totally unused blocks. @@ -504,7 +508,13 @@ ffs_indirtrunc(ip, lbn, dbn, lastbn, level, countp) blocksreleased += blkcount; } } - FREE(copy, M_TEMP); + if (lastbn != -1) { + FREE(copy, M_TEMP); + } else { + bp->b_flags |= B_INVAL; + brelse(bp); + } + *countp = blocksreleased; return (allerror); } |