/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
ip->i_flag |= IN_CHANGE | IN_UPDATE;
if ((flags & B_SYNC) || (!alloc_buffer)) {
if (!alloc_buffer)
- SET(bp->b_flags, B_INVAL);
+ SET(bp->b_flags, B_NOCACHE);
bwrite(bp);
} else
- bawrite(bp);
+ bdwrite(bp);
/* note that bp is already released here */
}
}
return (error);
ip->i_db[lbn] = dbtofsb(fs, bp->b_blkno);
ip->i_flag |= IN_CHANGE | IN_UPDATE;
- if(!alloc_buffer) {
- SET(bp->b_flags, B_INVAL);
- bwrite(bp);
+ if(!alloc_buffer) {
+ SET(bp->b_flags, B_NOCACHE);
+ if (flags & B_SYNC)
+ bwrite(bp);
+ else
+ bdwrite(bp);
} else
*bpp = bp;
return (0);
return(error);
#if DIAGNOSTIC
if (num < 1)
- panic ("ffs_balloc: ufs_bmaparray returned indirect block\n");
+ panic ("ffs_balloc: ufs_bmaparray returned indirect block");
#endif
/*
* Fetch the first indirect block allocating if necessary.
bp->b_blkno = fsbtodb(fs, nb);
clrbuf(bp);
/*
- * Write synchronously so that indirect blocks
- * never point at garbage.
+ * Write synchronously conditional on mount flags.
*/
- if (error = bwrite(bp))
+ if ((vp)->v_mount->mnt_flag & MNT_ASYNC) {
+ error = 0;
+ bdwrite(bp);
+ } else if ((error = bwrite(bp)) != 0) {
goto fail;
+ }
allocib = &ip->i_ib[indirs[0].in_off];
*allocib = nb;
ip->i_flag |= IN_CHANGE | IN_UPDATE;
nbp->b_blkno = fsbtodb(fs, nb);
clrbuf(nbp);
/*
- * Write synchronously so that indirect blocks
- * never point at garbage.
+ * Write synchronously conditional on mount flags.
*/
- if (error = bwrite(nbp)) {
+ if ((vp)->v_mount->mnt_flag & MNT_ASYNC) {
+ error = 0;
+ bdwrite(nbp);
+ } else if (error = bwrite(nbp)) {
brelse(bp);
goto fail;
}
fs = ip->i_fs;
if(size > fs->fs_bsize)
- panic("ffs_blkalloc: too large for allocation\n");
+ panic("ffs_blkalloc: too large for allocation");
/*
* If the next write will extend the file into a new block,
*/
nb = lblkno(fs, ip->i_size);
if (nb < NDADDR && nb < lbn) {
- panic("ffs_blkalloc():cannot extend file: i_size %d, lbn %d\n", ip->i_size, lbn);
+ panic("ffs_blkalloc():cannot extend file: i_size %d, lbn %d", ip->i_size, lbn);
}
/*
* The first NDADDR blocks are direct blocks
osize = fragroundup(fs, blkoff(fs, ip->i_size));
nsize = fragroundup(fs, size);
if (nsize > osize) {
- panic("ffs_allocblk: trying to extend
- a fragment \n");
+ panic("ffs_allocblk: trying to extend a fragment");
}
return(0);
} else {
return(error);
if(num == 0) {
- panic("ffs_blkalloc: file with direct blocks only\n");
+ panic("ffs_blkalloc: file with direct blocks only");
}
/*
bp->b_blkno = fsbtodb(fs, nb);
clrbuf(bp);
/*
- * Write synchronously so that indirect blocks
- * never point at garbage.
+ * Write synchronously conditional on mount flags.
*/
- if (error = bwrite(bp))
+ if ((vp)->v_mount->mnt_flag & MNT_ASYNC) {
+ error = 0;
+ bdwrite(bp);
+ } else if (error = bwrite(bp)) {
goto fail;
+ }
allocib = &ip->i_ib[indirs[0].in_off];
*allocib = nb;
ip->i_flag |= IN_CHANGE | IN_UPDATE;
nbp->b_blkno = fsbtodb(fs, nb);
clrbuf(nbp);
/*
- * Write synchronously so that indirect blocks
- * never point at garbage.
+ * Write synchronously conditional on mount flags.
*/
- if (error = bwrite(nbp)) {
+ if ((vp)->v_mount->mnt_flag & MNT_ASYNC) {
+ error = 0;
+ bdwrite(nbp);
+ } else if (error = bwrite(nbp)) {
brelse(bp);
goto fail;
}