FreeBSD/sys/kern/vfs_bio.c
/*
 *	binsfree:
 *
 *	Insert the buffer into the appropriate free list.
 */
Insert the buffer into the appropriate free list.
Insert the buffer into the appropriate free list .
static void
binsfree(struct buf *bp, int qindex)
{
	struct mtx *olock, *nlock;
	if (qindex != QUEUE_EMPTY) {
		BUF_ASSERT_XLOCKED(bp);
	}
	if (qindex == QUEUE_CLEAN) {
		if (bqisclean(bp->b_qindex))
			qindex = bp->b_qindex;
		else
			qindex = bqcleanq();
	}
	nlock = bqlock(qindex);
	if (bp->b_flags & B_REMFREE) {
		olock = bqlock(bp->b_qindex);
		mtx_lock(olock);
		bremfreel(bp);
		if (olock != nlock) {
			mtx_unlock(olock);
			mtx_lock(nlock);
		}
	} else
		mtx_lock(nlock);
	if (bp->b_qindex != QUEUE_NONE)
		panic("binsfree: free buffer onto another queue???");
	bp->b_qindex = qindex;
	if (bp->b_flags & B_AGE)
		TAILQ_INSERT_HEAD(&bufqueues[bp->b_qindex], bp, b_freelist);
	else
		TAILQ_INSERT_TAIL(&bufqueues[bp->b_qindex], bp, b_freelist);
#ifdef INVARIANTS
	bq_len[bp->b_qindex]++;
#endif
	mtx_unlock(nlock);
}
static void binsfree ( struct buf * bp , int qindex ) { struct mtx * olock , * nlock ; if ( qindex != QUEUE_EMPTY ) { BUF_ASSERT_XLOCKED ( bp ) ; } if ( qindex == QUEUE_CLEAN ) { if ( bqisclean ( bp -> b_qindex ) ) qindex = bp -> b_qindex ; else qindex = bqcleanq ( ) ; } nlock = bqlock ( qindex ) ; if ( bp -> b_flags & B_REMFREE ) { olock = bqlock ( bp -> b_qindex ) ; mtx_lock ( olock ) ; bremfreel ( bp ) ; if ( olock != nlock ) { mtx_unlock ( olock ) ; mtx_lock ( nlock ) ; } } else mtx_lock ( nlock ) ; if ( bp -> b_qindex != QUEUE_NONE ) panic ( " " ) ; bp -> b_qindex = qindex ; if ( bp -> b_flags & B_AGE ) TAILQ_INSERT_HEAD ( & bufqueues [ bp -> b_qindex ] , bp , b_freelist ) ; else TAILQ_INSERT_TAIL ( & bufqueues [ bp -> b_qindex ] , bp , b_freelist ) ; #ifdef INVARIANTS bq_len [ bp -> b_qindex ] ++ ; #endif mtx_unlock ( nlock ) ; }
binsfree:
      Insert the buffer into the appropriate free list.
binsfree : Insert the buffer into the appropriate free list .
/*
	 * Stick to the same clean queue for the lifetime of the buf to
	 * limit locking below.  Otherwise pick ont sequentially.
	 */ /*
	 * Handle delayed bremfree() processing.
	 */