FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
/*
 * Update the allocatable flag and the metaslab group's capacity.
 * The allocatable flag is set to true if the capacity is below
 * the zfs_mg_noalloc_threshold. If a metaslab group transitions
 * from allocatable to non-allocatable or vice versa then the metaslab
 * group's class is updated to reflect the transition.
 */
Update the allocatable flag and the metaslab group's capacity.
The allocatable flag is set to true if the capacity is below
the zfs_mg_noalloc_threshold. If a metaslab group transitions
from allocatable to non-allocatable or vice versa then the metaslab
group's class is updated to reflect the transition.
Update the allocatable flag and the metaslab group ' s capacity . The allocatable flag is set to true if the capacity is below the zfs_mg_noalloc_threshold . If a metaslab group transitions from allocatable to non - allocatable or vice versa then the metaslab group ' s class is updated to reflect the transition .
static void
metaslab_group_alloc_update(metaslab_group_t *mg)
{
	vdev_t *vd = mg->mg_vd;
	metaslab_class_t *mc = mg->mg_class;
	vdev_stat_t *vs = &vd->vdev_stat;
	boolean_t was_allocatable;
	ASSERT(vd == vd->vdev_top);
	mutex_enter(&mg->mg_lock);
	was_allocatable = mg->mg_allocatable;
	mg->mg_free_capacity = ((vs->vs_space - vs->vs_alloc) * 100) /
	    (vs->vs_space + 1);
	mg->mg_allocatable = (mg->mg_free_capacity > zfs_mg_noalloc_threshold &&
	    (mg->mg_fragmentation == ZFS_FRAG_INVALID ||
	    mg->mg_fragmentation <= zfs_mg_fragmentation_threshold));
	if (was_allocatable && !mg->mg_allocatable)
		mc->mc_alloc_groups--;
	else if (!was_allocatable && mg->mg_allocatable)
		mc->mc_alloc_groups++;
	mutex_exit(&mg->mg_lock);
}
static void metaslab_group_alloc_update ( metaslab_group_t * mg ) { vdev_t * vd = mg -> mg_vd ; metaslab_class_t * mc = mg -> mg_class ; vdev_stat_t * vs = & vd -> vdev_stat ; boolean_t was_allocatable ; ASSERT ( vd == vd -> vdev_top ) ; mutex_enter ( & mg -> mg_lock ) ; was_allocatable = mg -> mg_allocatable ; mg -> mg_free_capacity = ( ( vs -> vs_space - vs -> vs_alloc ) * 100 ) / ( vs -> vs_space + 1 ) ; mg -> mg_allocatable = ( mg -> mg_free_capacity > zfs_mg_noalloc_threshold && ( mg -> mg_fragmentation == ZFS_FRAG_INVALID || mg -> mg_fragmentation <= zfs_mg_fragmentation_threshold ) ) ; if ( was_allocatable && ! mg -> mg_allocatable ) mc -> mc_alloc_groups -- ; else if ( ! was_allocatable && mg -> mg_allocatable ) mc -> mc_alloc_groups ++ ; mutex_exit ( & mg -> mg_lock ) ; }
Update the allocatable flag and the metaslab group's capacity.
Update the allocatable flag and the metaslab group ' s capacity .
/*
	 * A metaslab group is considered allocatable if it has plenty
	 * of free space or is not heavily fragmented. We only take
	 * fragmentation into account if the metaslab group has a valid
	 * fragmentation metric (i.e. a value between 0 and 100).
	 */ /*
	 * The mc_alloc_groups maintains a count of the number of
	 * groups in this metaslab class that are still above the
	 * zfs_mg_noalloc_threshold. This is used by the allocating
	 * threads to determine if they should avoid allocations to
	 * a given group. The allocator will avoid allocations to a group
	 * if that group has reached or is below the zfs_mg_noalloc_threshold
	 * and there are still other groups that are above the threshold.
	 * When a group transitions from allocatable to non-allocatable or
	 * vice versa we update the metaslab class to reflect that change.
	 * When the mc_alloc_groups value drops to 0 that means that all
	 * groups have reached the zfs_mg_noalloc_threshold making all groups
	 * eligible for allocations. This effectively means that all devices
	 * are balanced again.
	 */