SET(bp->b_flags, B_WRITEINPROG);
bwrite(bp)	struct buf *bp;{	int rv, async, wasdelayed, s;	struct vnode *vp;	struct mount *mp;	/*	 * Remember buffer type, to switch on it later.  If the write was	 * synchronous, but the file system was mounted with MNT_ASYNC,	 * convert it to a delayed write.	 * XXX note that this relies on delayed tape writes being converted	 * to async, not sync writes (which is safe, but ugly).	 */	async = ISSET(bp->b_flags, B_ASYNC);	if (!async && bp->b_vp && bp->b_vp->v_mount &&	    ISSET(bp->b_vp->v_mount->mnt_flag, MNT_ASYNC)) {		bdwrite(bp);		return (0);	}	/*	 * Collect statistics on synchronous and asynchronous writes.	 * Writes to block devices are charged to their associated	 * filesystem (if any).	 */	if ((vp = bp->b_vp) != NULL) {		if (vp->v_type == VBLK)			mp = vp->v_specmountpoint;		else			mp = vp->v_mount;		if (mp != NULL) {			if (async)				mp->mnt_stat.f_asyncwrites++;			else				mp->mnt_stat.f_syncwrites++;		}	}	wasdelayed = ISSET(bp->b_flags, B_DELWRI);	CLR(bp->b_flags, (B_READ | B_DONE | B_ERROR | B_DELWRI));	s = splbio();	/*	 * If not synchronous, pay for the I/O operation and make	 * sure the buf is on the correct vnode queue.  We have	 * to do this now, because if we don't, the vnode may not	 * be properly notified that its I/O has completed.	 */	if (wasdelayed) {		reassignbuf(bp);	} else		curproc->p_stats->p_ru.ru_oublock++;		/* Initiate disk write.  Make sure the appropriate party is charged. */	bp->b_vp->v_numoutput++;	splx(s);	VOP_STRATEGY(bp);	if (async)		return (0);	/*	 * If I/O was synchronous, wait for it to complete.	 */	rv = biowait(bp);	/* Release the buffer. */	brelse(bp);	return (rv);}