FreeBSD/sys/kern/vfs_bio.c
/*
 *	bdirty:
 *
 *	Turn buffer into delayed write request.  We must clear BIO_READ and
 *	B_RELBUF, and we must set B_DELWRI.  We reassign the buffer to 
 *	itself to properly update it in the dirty/clean lists.  We mark it
 *	B_DONE to ensure that any asynchronization of the buffer properly
 *	clears B_DONE ( else a panic will occur later ).  
 *
 *	bdirty() is kinda like bdwrite() - we have to clear B_INVAL which
 *	might have been set pre-getblk().  Unlike bwrite/bdwrite, bdirty()
 *	should only be called if the buffer is known-good.
 *
 *	Since the buffer is not on a queue, we do not update the numfreebuffers
 *	count.
 *
 *	The buffer must be on QUEUE_NONE.
 */
Turn buffer into delayed write request.  We must clear BIO_READ and
B_RELBUF, and we must set B_DELWRI.  We reassign the buffer to
itself to properly update it in the dirty/clean lists.  We mark it
B_DONE to ensure that any asynchronization of the buffer properly
clears B_DONE ( else a panic will occur later ).

bdirty() is kinda like bdwrite() - we have to clear B_INVAL which
might have been set pre-getblk().  Unlike bwrite/bdwrite, bdirty()
should only be called if the buffer is known-good.

Since the buffer is not on a queue, we do not update the numfreebuffers
count.

The buffer must be on QUEUE_NONE.
Turn buffer into delayed write request . We must clear BIO_READ and B_RELBUF and we must set B_DELWRI . We reassign the buffer to itself to properly update it in the dirty / clean lists . We mark it B_DONE to ensure that any asynchronization of the buffer properly clears B_DONE ( else a panic will occur later ) . bdirty () is kinda like bdwrite () - we have to clear B_INVAL which might have been set pre - getblk () . Unlike bwrite / bdwrite bdirty () should only be called if the buffer is known - good . Since the buffer is not on a queue we do not update the numfreebuffers count . The buffer must be on QUEUE_NONE .
void
bdirty(struct buf *bp)
{
	CTR3(KTR_BUF, "bdirty(%p) vp %p flags %X",
	    bp, bp->b_vp, bp->b_flags);
	KASSERT(bp->b_bufobj != NULL, ("No b_bufobj %p", bp));
	KASSERT(bp->b_flags & B_REMFREE || bp->b_qindex == QUEUE_NONE,
	    ("bdirty: buffer %p still on queue %d", bp, bp->b_qindex));
	BUF_ASSERT_HELD(bp);
	bp->b_flags &= ~(B_RELBUF);
	bp->b_iocmd = BIO_WRITE;
	if ((bp->b_flags & B_DELWRI) == 0) {
		bp->b_flags |=  B_DELWRI;
		reassignbuf(bp);
		bdirtyadd();
	}
}
void bdirty ( struct buf * bp ) { CTR3 ( KTR_BUF , " " , bp , bp -> b_vp , bp -> b_flags ) ; KASSERT ( bp -> b_bufobj != NULL , ( " " , bp ) ) ; KASSERT ( bp -> b_flags & B_REMFREE || bp -> b_qindex == QUEUE_NONE , ( " " , bp , bp -> b_qindex ) ) ; BUF_ASSERT_HELD ( bp ) ; bp -> b_flags &= ~ ( B_RELBUF ) ; bp -> b_iocmd = BIO_WRITE ; if ( ( bp -> b_flags & B_DELWRI ) == 0 ) { bp -> b_flags |= B_DELWRI ; reassignbuf ( bp ) ; bdirtyadd ( ) ; } }
bdirty:
      Turn buffer into delayed write request.
bdirty : Turn buffer into delayed write request .
/* XXX B_DONE | */