FreeBSD/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c
/*
 * Check the replication level of the vdev spec against the current pool.  Calls
 * get_replication() to make sure the new spec is self-consistent.  If the pool
 * has a consistent replication level, then we ignore any errors.  Otherwise,
 * report any difference between the two.
 */
Check the replication level of the vdev spec against the current pool.  Calls
get_replication() to make sure the new spec is self-consistent.  If the pool
has a consistent replication level, then we ignore any errors.  Otherwise,
report any difference between the two.
Check the replication level of the vdev spec against the current pool . Calls get_replication () to make sure the new spec is self - consistent . If the pool has a consistent replication level then we ignore any errors . Otherwise report any difference between the two .
static int
check_replication(nvlist_t *config, nvlist_t *newroot)
{
	nvlist_t **child;
	uint_t	children;
	replication_level_t *current = NULL, *new;
	int ret;
	if (config != NULL) {
		nvlist_t *nvroot;
		verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
		    &nvroot) == 0);
		if ((current = get_replication(nvroot, B_FALSE)) == NULL)
			return (0);
	}
	if ((nvlist_lookup_nvlist_array(newroot, ZPOOL_CONFIG_CHILDREN,
	    &child, &children) != 0) || (children == 0)) {
		free(current);
		return (0);
	}
	if (num_logs(newroot) == children) {
		free(current);
		return (0);
	}
	if ((new = get_replication(newroot, B_TRUE)) == NULL) {
		free(current);
		return (-1);
	}
	ret = 0;
	if (current != NULL) {
		if (strcmp(current->zprl_type, new->zprl_type) != 0) {
			vdev_error(gettext(
			    "mismatched replication level: pool uses %s "
			    "and new vdev is %s\n"),
			    current->zprl_type, new->zprl_type);
			ret = -1;
		} else if (current->zprl_parity != new->zprl_parity) {
			vdev_error(gettext(
			    "mismatched replication level: pool uses %llu "
			    "device parity and new vdev uses %llu\n"),
			    current->zprl_parity, new->zprl_parity);
			ret = -1;
		} else if (current->zprl_children != new->zprl_children) {
			vdev_error(gettext(
			    "mismatched replication level: pool uses %llu-way "
			    "%s and new vdev uses %llu-way %s\n"),
			    current->zprl_children, current->zprl_type,
			    new->zprl_children, new->zprl_type);
			ret = -1;
		}
	}
	free(new);
	if (current != NULL)
		free(current);
	return (ret);
}
static int check_replication ( nvlist_t * config , nvlist_t * newroot ) { nvlist_t * * child ; uint_t children ; replication_level_t * current = NULL , * new ; int ret ; if ( config != NULL ) { nvlist_t * nvroot ; verify ( nvlist_lookup_nvlist ( config , ZPOOL_CONFIG_VDEV_TREE , & nvroot ) == 0 ) ; if ( ( current = get_replication ( nvroot , B_FALSE ) ) == NULL ) return ( 0 ) ; } if ( ( nvlist_lookup_nvlist_array ( newroot , ZPOOL_CONFIG_CHILDREN , & child , & children ) != 0 ) || ( children == 0 ) ) { free ( current ) ; return ( 0 ) ; } if ( num_logs ( newroot ) == children ) { free ( current ) ; return ( 0 ) ; } if ( ( new = get_replication ( newroot , B_TRUE ) ) == NULL ) { free ( current ) ; return ( -1 ) ; } ret = 0 ; if ( current != NULL ) { if ( strcmp ( current -> zprl_type , new -> zprl_type ) != 0 ) { vdev_error ( gettext ( " " " \n " ) , current -> zprl_type , new -> zprl_type ) ; ret = -1 ; } else if ( current -> zprl_parity != new -> zprl_parity ) { vdev_error ( gettext ( " " " \n " ) , current -> zprl_parity , new -> zprl_parity ) ; ret = -1 ; } else if ( current -> zprl_children != new -> zprl_children ) { vdev_error ( gettext ( " " " \n " ) , current -> zprl_children , current -> zprl_type , new -> zprl_children , new -> zprl_type ) ; ret = -1 ; } } free ( new ) ; if ( current != NULL ) free ( current ) ; return ( ret ) ; }
Check the replication level of the vdev spec against the current pool.
Check the replication level of the vdev spec against the current pool .
/*
	 * If we have a current pool configuration, check to see if it's
	 * self-consistent.  If not, simply return success.
	 */ /*
	 * for spares there may be no children, and therefore no
	 * replication level to check
	 */ /*
	 * If all we have is logs then there's no replication level to check.
	 */ /*
	 * Get the replication level of the new vdev spec, reporting any
	 * inconsistencies found.
	 */ /*
	 * Check to see if the new vdev spec matches the replication level of
	 * the current pool.
	 */