numfreebufs = 0; numcleanbufs = 0; numemptybufs = 0;
bufinit(){	register struct buf *bp;	struct bqueues *dp;	register int i;	int base, residual;	numfreebufs = 0;	numcleanbufs = 0;	numemptybufs = 0;	for (dp = bufqueues; dp < &bufqueues[BQUEUES]; dp++)		TAILQ_INIT(dp);	bufhashtbl = hashinit(nbuf, M_CACHE, M_WAITOK, &bufhash);	base = bufpages / nbuf;	residual = bufpages % nbuf;	for (i = 0; i < nbuf; i++) {		bp = &buf[i];		bzero((char *)bp, sizeof *bp);		bp->b_dev = NODEV;		bp->b_rcred = NOCRED;		bp->b_wcred = NOCRED;		bp->b_vnbufs.le_next = NOLIST;		bp->b_data = buffers + i * MAXBSIZE;		LIST_INIT(&bp->b_dep);		if (i < residual)			bp->b_bufsize = (base + 1) * PAGE_SIZE;		else			bp->b_bufsize = base * PAGE_SIZE;		bp->b_flags = B_INVAL;		if (bp->b_bufsize) {			dp = &bufqueues[BQ_AGE];			numfreebufs++;			numcleanbufs++;		} else {			dp = &bufqueues[BQ_EMPTY];			numemptybufs++;		}		binsheadfree(bp, dp);		binshash(bp, &invalhash);	}	hidirtybufs = nbuf / 4 + 20;	numdirtybufs = 0;	lodirtybufs = hidirtybufs / 2;	/*	 * Reserve 5% of bufs for syncer's needs,	 * but not more than 25% and if possible	 * not less then 16 bufs. locleanbufs	 * value must be not too small, but probably	 * there are no reason to set it more than 32.	 */	locleanbufs = nbuf / 20;	if (locleanbufs < 16)		locleanbufs = 16;	if (locleanbufs > nbuf/4)		locleanbufs = nbuf / 4;#ifdef DEBUG	mincleanbufs = locleanbufs;#endif}