bin/varnishd/storage/storage_file.c
static void
insfree(struct smf_sc *sc, struct smf *sp)
{
	off_t b, ns;
	struct smf *sp2;

	AZ(sp->alloc);
	assert(sp->flist == NULL);
	Lck_AssertHeld(&sc->mtx);
	b = sp->size / sc->pagesize;
	if (b >= NBUCKET) {
		b = NBUCKET - 1;
		sc->stats->g_smf_large++;
	} else {
		sc->stats->g_smf_frag++;
	}
	sp->flist = &sc->free[b];
	ns = b * sc->pagesize;
	VTAILQ_FOREACH(sp2, sp->flist, status) {
		assert(sp2->size >= ns);
		AZ(sp2->alloc);
		assert(sp2->flist == sp->flist);
		if (sp->offset < sp2->offset)
			break;
	}
	if (sp2 == NULL)
		VTAILQ_INSERT_TAIL(sp->flist, sp, status);
	else
		VTAILQ_INSERT_BEFORE(sp2, sp, status);
}
/*--------------------------------------------------------------------
 * Insert/Remove from correct freelist
 */
Insert/Remove from correct freelist
Insert / Remove from correct freelist
static void
insfree(struct smf_sc *sc, struct smf *sp)
{
	off_t b, ns;
	struct smf *sp2;
	AZ(sp->alloc);
	assert(sp->flist == NULL);
	Lck_AssertHeld(&sc->mtx);
	b = sp->size / sc->pagesize;
	if (b >= NBUCKET) {
		b = NBUCKET - 1;
		sc->stats->g_smf_large++;
	} else {
		sc->stats->g_smf_frag++;
	}
	sp->flist = &sc->free[b];
	ns = b * sc->pagesize;
	VTAILQ_FOREACH(sp2, sp->flist, status) {
		assert(sp2->size >= ns);
		AZ(sp2->alloc);
		assert(sp2->flist == sp->flist);
		if (sp->offset < sp2->offset)
			break;
	}
	if (sp2 == NULL)
		VTAILQ_INSERT_TAIL(sp->flist, sp, status);
	else
		VTAILQ_INSERT_BEFORE(sp2, sp, status);
}
static void insfree ( struct smf_sc * sc , struct smf * sp ) { off_t b , ns ; struct smf * sp2 ; AZ ( sp -> alloc ) ; assert ( sp -> flist == NULL ) ; Lck_AssertHeld ( & sc -> mtx ) ; b = sp -> size / sc -> pagesize ; if ( b >= NBUCKET ) { b = NBUCKET - 1 ; sc -> stats -> g_smf_large ++ ; } else { sc -> stats -> g_smf_frag ++ ; } sp -> flist = & sc -> free [ b ] ; ns = b * sc -> pagesize ; VTAILQ_FOREACH ( sp2 , sp -> flist , status ) { assert ( sp2 -> size >= ns ) ; AZ ( sp2 -> alloc ) ; assert ( sp2 -> flist == sp -> flist ) ; if ( sp -> offset < sp2 -> offset ) break ; } if ( sp2 == NULL ) VTAILQ_INSERT_TAIL ( sp -> flist , sp , status ) ; else VTAILQ_INSERT_BEFORE ( sp2 , sp , status ) ; }
Insert/Remove from correct freelist
Insert / Remove from correct freelist