FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
/*
 * Adapt arc info given the number of bytes we are trying to add and
 * the state that we are comming from.  This function is only called
 * when we are adding new content to the cache.
 */
Adapt arc info given the number of bytes we are trying to add and
the state that we are comming from.  This function is only called
when we are adding new content to the cache.
Adapt arc info given the number of bytes we are trying to add and the state that we are comming from . This function is only called when we are adding new content to the cache .
static void
arc_adapt(int bytes, arc_state_t *state)
{
	int mult;
	uint64_t arc_p_min = (arc_c >> arc_p_min_shift);
	int64_t mrug_size = refcount_count(&arc_mru_ghost->arcs_size);
	int64_t mfug_size = refcount_count(&arc_mfu_ghost->arcs_size);
	if (state == arc_l2c_only)
		return;
	ASSERT(bytes > 0);
	if (state == arc_mru_ghost) {
		mult = (mrug_size >= mfug_size) ? 1 : (mfug_size / mrug_size);
		mult = MIN(mult, 10); 
		arc_p = MIN(arc_c - arc_p_min, arc_p + bytes * mult);
	} else if (state == arc_mfu_ghost) {
		uint64_t delta;
		mult = (mfug_size >= mrug_size) ? 1 : (mrug_size / mfug_size);
		mult = MIN(mult, 10);
		delta = MIN(bytes * mult, arc_p);
		arc_p = MAX(arc_p_min, arc_p - delta);
	}
	ASSERT((int64_t)arc_p >= 0);
	if (arc_reclaim_needed()) {
		cv_signal(&arc_reclaim_thread_cv);
		return;
	}
	if (arc_no_grow)
		return;
	if (arc_c >= arc_c_max)
		return;
	if (arc_size > arc_c - (2ULL << SPA_MAXBLOCKSHIFT)) {
		DTRACE_PROBE1(arc__inc_adapt, int, bytes);
		atomic_add_64(&arc_c, (int64_t)bytes);
		if (arc_c > arc_c_max)
			arc_c = arc_c_max;
		else if (state == arc_anon)
			atomic_add_64(&arc_p, (int64_t)bytes);
		if (arc_p > arc_c)
			arc_p = arc_c;
	}
	ASSERT((int64_t)arc_p >= 0);
}
static void arc_adapt ( int bytes , arc_state_t * state ) { int mult ; uint64_t arc_p_min = ( arc_c >> arc_p_min_shift ) ; int64_t mrug_size = refcount_count ( & arc_mru_ghost -> arcs_size ) ; int64_t mfug_size = refcount_count ( & arc_mfu_ghost -> arcs_size ) ; if ( state == arc_l2c_only ) return ; ASSERT ( bytes > 0 ) ; if ( state == arc_mru_ghost ) { mult = ( mrug_size >= mfug_size ) ? 1 : ( mfug_size / mrug_size ) ; mult = MIN ( mult , 10 ) ; arc_p = MIN ( arc_c - arc_p_min , arc_p + bytes * mult ) ; } else if ( state == arc_mfu_ghost ) { uint64_t delta ; mult = ( mfug_size >= mrug_size ) ? 1 : ( mrug_size / mfug_size ) ; mult = MIN ( mult , 10 ) ; delta = MIN ( bytes * mult , arc_p ) ; arc_p = MAX ( arc_p_min , arc_p - delta ) ; } ASSERT ( ( int64_t ) arc_p >= 0 ) ; if ( arc_reclaim_needed ( ) ) { cv_signal ( & arc_reclaim_thread_cv ) ; return ; } if ( arc_no_grow ) return ; if ( arc_c >= arc_c_max ) return ; if ( arc_size > arc_c - ( 2ULL << SPA_MAXBLOCKSHIFT ) ) { DTRACE_PROBE1 ( arc__inc_adapt , int , bytes ) ; atomic_add_64 ( & arc_c , ( int64_t ) bytes ) ; if ( arc_c > arc_c_max ) arc_c = arc_c_max ; else if ( state == arc_anon ) atomic_add_64 ( & arc_p , ( int64_t ) bytes ) ; if ( arc_p > arc_c ) arc_p = arc_c ; } ASSERT ( ( int64_t ) arc_p >= 0 ) ; }
Adapt arc info given the number of bytes we are trying to add and
 the state that we are comming from.
Adapt arc info given the number of bytes we are trying to add and the state that we are comming from .
/*
	 * Adapt the target size of the MRU list:
	 *	- if we just hit in the MRU ghost list, then increase
	 *	  the target size of the MRU list.
	 *	- if we just hit in the MFU ghost list, then increase
	 *	  the target size of the MFU list by decreasing the
	 *	  target size of the MRU list.
	 */ /* avoid wild arc_p adjustment */ /*
	 * If we're within (2 * maxblocksize) bytes of the target
	 * cache size, increment the target cache size
	 */