bin/varnishd/storage/storage_file.c
static void
smf_open_chunk(struct smf_sc *sc, off_t sz, off_t off, off_t *fail, off_t *sum)
{
	void *p;
	off_t h;

	AN(sz);
	AZ(sz % sc->pagesize);

	if (*fail < (off_t)sc->pagesize * MINPAGES)
		return;

	if (sz > 0 && sz < *fail && sz < SSIZE_MAX) {
		p = mmap(NULL, sz, PROT_READ|PROT_WRITE,
		    MAP_NOCORE | MAP_NOSYNC | MAP_SHARED, sc->fd, off);
		if (p != MAP_FAILED) {
			(void)madvise(p, sz, sc->advice);
			(*sum) += sz;
			new_smf(sc, p, off, sz);
			return;
		}
	}

	if (sz < *fail)
		*fail = sz;

	h = sz / 2;
	h -= (h % sc->pagesize);

	smf_open_chunk(sc, h, off, fail, sum);
	smf_open_chunk(sc, sz - h, off + h, fail, sum);
}
/*
 * XXX: This may be too aggressive and soak up too much address room.
 * XXX: On the other hand, the user, directly or implicitly asked us to
 * XXX: use this much storage, so we should make a decent effort.
 * XXX: worst case (I think), malloc will fail.
 */
This may be too aggressive and soak up too much address room.
XXX: On the other hand, the user, directly or implicitly asked us to
XXX: use this much storage, so we should make a decent effort.
XXX: worst case (I think), malloc will fail.
This may be too aggressive and soak up too much address room . XXX : On the other hand the user directly or implicitly asked us to XXX : use this much storage so we should make a decent effort . XXX : worst case ( I think ) malloc will fail .
static void
smf_open_chunk(struct smf_sc *sc, off_t sz, off_t off, off_t *fail, off_t *sum)
{
	void *p;
	off_t h;
	AN(sz);
	AZ(sz % sc->pagesize);
	if (*fail < (off_t)sc->pagesize * MINPAGES)
		return;
	if (sz > 0 && sz < *fail && sz < SSIZE_MAX) {
		p = mmap(NULL, sz, PROT_READ|PROT_WRITE,
		    MAP_NOCORE | MAP_NOSYNC | MAP_SHARED, sc->fd, off);
		if (p != MAP_FAILED) {
			(void)madvise(p, sz, sc->advice);
			(*sum) += sz;
			new_smf(sc, p, off, sz);
			return;
		}
	}
	if (sz < *fail)
		*fail = sz;
	h = sz / 2;
	h -= (h % sc->pagesize);
	smf_open_chunk(sc, h, off, fail, sum);
	smf_open_chunk(sc, sz - h, off + h, fail, sum);
}
static void smf_open_chunk ( struct smf_sc * sc , off_t sz , off_t off , off_t * fail , off_t * sum ) { void * p ; off_t h ; AN ( sz ) ; AZ ( sz % sc -> pagesize ) ; if ( * fail < ( off_t ) sc -> pagesize * MINPAGES ) return ; if ( sz > 0 && sz < * fail && sz < SSIZE_MAX ) { p = mmap ( NULL , sz , PROT_READ | PROT_WRITE , MAP_NOCORE | MAP_NOSYNC | MAP_SHARED , sc -> fd , off ) ; if ( p != MAP_FAILED ) { ( void ) madvise ( p , sz , sc -> advice ) ; ( * sum ) += sz ; new_smf ( sc , p , off , sz ) ; return ; } } if ( sz < * fail ) * fail = sz ; h = sz / 2 ; h -= ( h % sc -> pagesize ) ; smf_open_chunk ( sc , h , off , fail , sum ) ; smf_open_chunk ( sc , sz - h , off + h , fail , sum ) ; }
XXX: This may be too aggressive and soak up too much address room.
XXX : This may be too aggressive and soak up too much address room .