diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c index be0fadde312c..daa897dfe032 100644 --- a/sys/ufs/ffs/ffs_balloc.c +++ b/sys/ufs/ffs/ffs_balloc.c @@ -172,9 +172,17 @@ ffs_balloc_ufs1(struct vnode *vp, off_t startoffset, int size, panic("ffs_balloc_ufs1: BA_METAONLY for direct block"); nb = dp->di_db[lbn]; if (nb != 0 && ip->i_size >= smalllblktosize(fs, lbn + 1)) { - error = bread(vp, lbn, fs->fs_bsize, NOCRED, &bp); - if (error) { - return (error); + if ((flags & BA_CLRBUF) != 0) { + error = bread(vp, lbn, fs->fs_bsize, NOCRED, + &bp); + if (error != 0) + return (error); + } else { + bp = getblk(vp, lbn, fs->fs_bsize, 0, 0, + gbflags); + if (bp == NULL) + return (EIO); + vfs_bio_clrbuf(bp); } bp->b_blkno = fsbtodb(fs, nb); *bpp = bp; @@ -768,10 +776,17 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size, panic("ffs_balloc_ufs2: BA_METAONLY for direct block"); nb = dp->di_db[lbn]; if (nb != 0 && ip->i_size >= smalllblktosize(fs, lbn + 1)) { - error = bread_gb(vp, lbn, fs->fs_bsize, NOCRED, - gbflags, &bp); - if (error) { - return (error); + if ((flags & BA_CLRBUF) != 0) { + error = bread_gb(vp, lbn, fs->fs_bsize, NOCRED, + gbflags, &bp); + if (error != 0) + return (error); + } else { + bp = getblk(vp, lbn, fs->fs_bsize, 0, 0, + gbflags); + if (bp == NULL) + return (EIO); + vfs_bio_clrbuf(bp); } bp->b_blkno = fsbtodb(fs, nb); *bpp = bp;