/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License"). You may not use this file except in compliance with the
- * License. Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
*
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
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;
}