+ if (nb == 0) {
+ pref = blkpref(ip, lbn, i, &bap[0]);
+ if (error = alloc(ip, lbn, pref, (int)fs->fs_bsize, &newb)) {
+ brelse(bp);
+ return (error);
+ }
+ nb = newb;
+ nbp = getblk(vp, lbn, fs->fs_bsize);
+ nbp->b_blkno = fsbtodb(fs, nb);
+ if (flags & B_CLRBUF)
+ clrbuf(nbp);
+ bap[i] = nb;
+ /*
+ * If required, write synchronously, otherwise use
+ * delayed write. If this is the first instance of
+ * the delayed write, reassociate the buffer with the
+ * file so it will be written if the file is sync'ed.
+ */
+ if (flags & B_SYNC) {
+ bwrite(bp);
+ } else if (bp->b_flags & B_DELWRI) {
+ bdwrite(bp);
+ } else {
+ bdwrite(bp);
+ reassignbuf(bp, vp);
+ }
+ *bpp = nbp;
+ return (0);
+ }
+ brelse(bp);
+ if (flags & B_CLRBUF) {
+ error = bread(vp, lbn, (int)fs->fs_bsize, NOCRED, &nbp);
+ if (error) {
+ brelse(nbp);
+ return (error);
+ }
+ } else {
+ nbp = getblk(vp, lbn, fs->fs_bsize);
+ nbp->b_blkno = fsbtodb(fs, nb);