{
int tmp;
- /* if the next block is actually what we thought it is,
- then set the goal to what we thought it should be
- */
- if(ip->i_next_alloc_block == lbn)
+ /*
+ * if the next block is actually what we thought it is,
+ * then set the goal to what we thought it should be
+ */
+ if (ip->i_next_alloc_block == lbn && ip->i_next_alloc_goal != 0)
return ip->i_next_alloc_goal;
/* now check whether we were provided with an array that basically
if (bap[tmp])
return bap[tmp];
- /* else let's fall back to the blocknr, or, if there is none,
- follow the rule that a block should be allocated near its inode
- */
+ /*
+ * else let's fall back to the blocknr, or, if there is none,
+ * follow the rule that a block should be allocated near its inode
+ */
return blocknr ? blocknr :
(daddr_t)(ip->i_block_group *
EXT2_BLOCKS_PER_GROUP(ip->i_e2fs)) +
/*
* Lengthen the size of the file. We must ensure that the
* last byte of the file is allocated. Since the smallest
- * value of oszie is 0, length will be at least 1.
+ * value of osize is 0, length will be at least 1.
*/
if (osize < length) {
offset = blkoff(fs, length - 1);
if (flags & IO_SYNC)
aflags |= B_SYNC;
vnode_pager_setsize(ovp, length);
- if ((error = ext2_balloc(oip, lbn, offset + 1, cred, &bp,
- aflags)) != 0)
+ error = ext2_balloc(oip, lbn, offset + 1, cred, &bp, aflags);
+ if (error) {
+ vnode_pager_setsize(ovp, osize);
return (error);
+ }
oip->i_size = length;
if (aflags & IO_SYNC)
bwrite(bp);
aflags = B_CLRBUF;
if (flags & IO_SYNC)
aflags |= B_SYNC;
- if ((error = ext2_balloc(oip, lbn, offset, cred, &bp,
- aflags)) != 0)
+ error = ext2_balloc(oip, lbn, offset, cred, &bp, aflags);
+ if (error)
return (error);
oip->i_size = length;
size = blksize(fs, oip, lbn);
break;
xfersize = size;
}
- error =
- uiomove((char *)bp->b_data + blkoffset, (int)xfersize, uio);
+ error = uiomove((char *)bp->b_data + blkoffset,
+ (int)xfersize, uio);
if (error)
break;
* version.
*/
flags |= B_CLRBUF;
- error = ext2_balloc(ip,
- lbn, blkoffset + xfersize, ap->a_cred, &bp, flags);
+ error = ext2_balloc(ip, lbn, blkoffset + xfersize,
+ ap->a_cred, &bp, flags);
if (error)
break;
if (size < xfersize)
xfersize = size;
- error =
- uiomove((char *)bp->b_data + blkoffset, (int)xfersize, uio);
+ error = uiomove((char *)bp->b_data + blkoffset,
+ (int)xfersize, uio);
if ((ioflag & IO_VMIO) &&
- (LIST_FIRST(&bp->b_dep) == NULL)) /* in ext2fs? */
+ LIST_FIRST(&bp->b_dep) == NULL) /* in ext2fs? */
bp->b_flags |= B_RELBUF;
if (ioflag & IO_SYNC) {
* still zero, it will be unlinked and returned to the free
* list by vput().
*/
- vx_put(vp);
brelse(bp);
+ vx_put(vp);
*vpp = NULL;
return (error);
}
#if 0
ext2_print_inode(ip);
#endif
- brelse(bp);
+ bqrelse(bp);
/*
* Initialize the vnode from the inode, check for aliases.