FreeBSD/sys/kern/vfs_bio.c
/*
 * Release a buffer back to the appropriate queue but do not try to free
 * it.  The buffer is expected to be used again soon.
 *
 * bqrelse() is used by bdwrite() to requeue a delayed write, and used by
 * biodone() to requeue an async I/O on completion.  It is also used when
 * known good buffers need to be requeued but we think we may need the data
 * again soon.
 *
 * XXX we should be able to leave the B_RELBUF hint set on completion.
 */
Release a buffer back to the appropriate queue but do not try to free
it.  The buffer is expected to be used again soon.

bqrelse() is used by bdwrite() to requeue a delayed write, and used by
biodone() to requeue an async I/O on completion.  It is also used when
known good buffers need to be requeued but we think we may need the data
again soon.

XXX we should be able to leave the B_RELBUF hint set on completion.
Release a buffer back to the appropriate queue but do not try to free it . The buffer is expected to be used again soon . bqrelse () is used by bdwrite () to requeue a delayed write and used by biodone () to requeue an async I / O on completion . It is also used when known good buffers need to be requeued but we think we may need the data again soon . XXX we should be able to leave the B_RELBUF hint set on completion .
void
bqrelse(struct buf *bp)
{
	int qindex;
	CTR3(KTR_BUF, "bqrelse(%p) vp %p flags %X", bp, bp->b_vp, bp->b_flags);
	KASSERT(!(bp->b_flags & (B_CLUSTER|B_PAGING)),
	    ("bqrelse: inappropriate B_PAGING or B_CLUSTER bp %p", bp));
	qindex = QUEUE_NONE;
	if (BUF_LOCKRECURSED(bp)) {
		BUF_UNLOCK(bp);
		return;
	}
	bp->b_flags &= ~(B_ASYNC | B_NOCACHE | B_AGE | B_RELBUF);
	if (bp->b_flags & B_MANAGED) {
		if (bp->b_flags & B_REMFREE)
			bremfreef(bp);
		goto out;
	}
	if ((bp->b_flags & B_DELWRI) != 0 || (bp->b_vflags & (BV_BKGRDINPROG |
	    BV_BKGRDERR)) == BV_BKGRDERR) {
		BO_LOCK(bp->b_bufobj);
		bp->b_vflags &= ~BV_BKGRDERR;
		BO_UNLOCK(bp->b_bufobj);
		qindex = QUEUE_DIRTY;
	} else {
		if ((bp->b_flags & B_DELWRI) == 0 &&
		    (bp->b_xflags & BX_VNDIRTY))
			panic("bqrelse: not dirty");
		if ((bp->b_flags & B_NOREUSE) != 0) {
			brelse(bp);
			return;
		}
		qindex = QUEUE_CLEAN;
	}
	binsfree(bp, qindex);
out:
	BUF_UNLOCK(bp);
	if (qindex == QUEUE_CLEAN)
		bufspace_wakeup();
}
void bqrelse ( struct buf * bp ) { int qindex ; CTR3 ( KTR_BUF , " " , bp , bp -> b_vp , bp -> b_flags ) ; KASSERT ( ! ( bp -> b_flags & ( B_CLUSTER | B_PAGING ) ) , ( " " , bp ) ) ; qindex = QUEUE_NONE ; if ( BUF_LOCKRECURSED ( bp ) ) { BUF_UNLOCK ( bp ) ; return ; } bp -> b_flags &= ~ ( B_ASYNC | B_NOCACHE | B_AGE | B_RELBUF ) ; if ( bp -> b_flags & B_MANAGED ) { if ( bp -> b_flags & B_REMFREE ) bremfreef ( bp ) ; goto out ; } if ( ( bp -> b_flags & B_DELWRI ) != 0 || ( bp -> b_vflags & ( BV_BKGRDINPROG | BV_BKGRDERR ) ) == BV_BKGRDERR ) { BO_LOCK ( bp -> b_bufobj ) ; bp -> b_vflags &= ~ BV_BKGRDERR ; BO_UNLOCK ( bp -> b_bufobj ) ; qindex = QUEUE_DIRTY ; } else { if ( ( bp -> b_flags & B_DELWRI ) == 0 && ( bp -> b_xflags & BX_VNDIRTY ) ) panic ( " " ) ; if ( ( bp -> b_flags & B_NOREUSE ) != 0 ) { brelse ( bp ) ; return ; } qindex = QUEUE_CLEAN ; } binsfree ( bp , qindex ) ; out : BUF_UNLOCK ( bp ) ; if ( qindex == QUEUE_CLEAN ) bufspace_wakeup ( ) ; }
Release a buffer back to the appropriate queue but do not try to free
 it.
Release a buffer back to the appropriate queue but do not try to free it .
/* do not release to free list */ /* buffers with stale but valid contents */ /* unlock */