sys/dev/disk/dm/targets/striped/dm_target_striped.c
static int
dm_target_stripe_init(dm_dev_t *dmv, void **target_config, char *params)
{
	dm_target_stripe_config_t *tsc;
	int n;
	char *ap;

	if (params == NULL)
		return EINVAL;

	/*
	 * nstripes
	 */
	ap = strsep(&params, " \t");
	if (ap == NULL)
		return EINVAL;
	n = (int)atoi64(ap);
	if (n < 0 || n > MAX_STRIPES) {
		kprintf("dm: Error %d stripes not supported (%d max)\n",
			n, MAX_STRIPES);
		return ENOTSUP;
	}

	tsc = kmalloc(sizeof(dm_target_stripe_config_t),
		      M_DMSTRIPE, M_WAITOK | M_ZERO);
	tsc->stripe_num = n;

	ap = strsep(&params, " \t");
	if (ap == NULL)
		return EINVAL;
	tsc->stripe_chunksize = atoi64(ap);
	if (tsc->stripe_chunksize < 1 ||
	    tsc->stripe_chunksize * DEV_BSIZE > MAXPHYS) {
		kprintf("dm: Error unsupported chunk size %jdKB\n",
			(intmax_t)tsc->stripe_chunksize * DEV_BSIZE / 1024);
		dm_target_stripe_destroy_config(tsc);
		return EINVAL;
	}

	/*
	 * Parse the devices
	 */

	kprintf("dm: Stripe %d devices chunk size %dKB\n",
		(int)tsc->stripe_num,
		(int)tsc->stripe_chunksize
	);

	for (n = 0; n < tsc->stripe_num; ++n) {
		ap = strsep(&params, " \t");
		if (ap == NULL)
			break;
		tsc->stripe_devs[n].pdev = dm_pdev_insert(ap);
		if (tsc->stripe_devs[n].pdev == NULL)
			break;
		ap = strsep(&params, " \t");
		if (ap == NULL)
			break;
		tsc->stripe_devs[n].offset = atoi64(ap);
	}
	if (n != tsc->stripe_num) {
		dm_target_stripe_destroy_config(tsc);
		return (ENOENT);
	}

	*target_config = tsc;

	dmv->dev_type = DM_STRIPE_DEV;

	return 0;
}
/*
 * Init function called from dm_table_load_ioctl.
 *
 * Example line sent to dm from lvm tools when using striped target.
 * start length striped #stripes chunk_size device1 offset1 ... deviceN offsetN
 * 0 65536 striped 2 512 /dev/hda 0 /dev/hdb 0
 */
Init function called from dm_table_load_ioctl.
Example line sent to dm from lvm tools when using striped target.
start length striped #stripes chunk_size device1 offset1 ... deviceN offsetN
0 65536 striped 2 512 /dev/hda 0 /dev/hdb 0
Init function called from dm_table_load_ioctl . Example line sent to dm from lvm tools when using striped target . start length striped #stripes chunk_size device1 offset1 ... deviceN offsetN 0 65536 striped 2 512 / dev / hda 0 / dev / hdb 0
static int
dm_target_stripe_init(dm_dev_t *dmv, void **target_config, char *params)
{
	dm_target_stripe_config_t *tsc;
	int n;
	char *ap;
	if (params == NULL)
		return EINVAL;
	ap = strsep(&params, " \t");
	if (ap == NULL)
		return EINVAL;
	n = (int)atoi64(ap);
	if (n < 0 || n > MAX_STRIPES) {
		kprintf("dm: Error %d stripes not supported (%d max)\n",
			n, MAX_STRIPES);
		return ENOTSUP;
	}
	tsc = kmalloc(sizeof(dm_target_stripe_config_t),
		      M_DMSTRIPE, M_WAITOK | M_ZERO);
	tsc->stripe_num = n;
	ap = strsep(&params, " \t");
	if (ap == NULL)
		return EINVAL;
	tsc->stripe_chunksize = atoi64(ap);
	if (tsc->stripe_chunksize < 1 ||
	    tsc->stripe_chunksize * DEV_BSIZE > MAXPHYS) {
		kprintf("dm: Error unsupported chunk size %jdKB\n",
			(intmax_t)tsc->stripe_chunksize * DEV_BSIZE / 1024);
		dm_target_stripe_destroy_config(tsc);
		return EINVAL;
	}
	kprintf("dm: Stripe %d devices chunk size %dKB\n",
		(int)tsc->stripe_num,
		(int)tsc->stripe_chunksize
	);
	for (n = 0; n < tsc->stripe_num; ++n) {
		ap = strsep(&params, " \t");
		if (ap == NULL)
			break;
		tsc->stripe_devs[n].pdev = dm_pdev_insert(ap);
		if (tsc->stripe_devs[n].pdev == NULL)
			break;
		ap = strsep(&params, " \t");
		if (ap == NULL)
			break;
		tsc->stripe_devs[n].offset = atoi64(ap);
	}
	if (n != tsc->stripe_num) {
		dm_target_stripe_destroy_config(tsc);
		return (ENOENT);
	}
	*target_config = tsc;
	dmv->dev_type = DM_STRIPE_DEV;
	return 0;
}
static int dm_target_stripe_init ( dm_dev_t * dmv , void * * target_config , char * params ) { dm_target_stripe_config_t * tsc ; int n ; char * ap ; if ( params == NULL ) return EINVAL ; ap = strsep ( & params , " \t " ) ; if ( ap == NULL ) return EINVAL ; n = ( int ) atoi64 ( ap ) ; if ( n < 0 || n > MAX_STRIPES ) { kprintf ( " \n " , n , MAX_STRIPES ) ; return ENOTSUP ; } tsc = kmalloc ( sizeof ( dm_target_stripe_config_t ) , M_DMSTRIPE , M_WAITOK | M_ZERO ) ; tsc -> stripe_num = n ; ap = strsep ( & params , " \t " ) ; if ( ap == NULL ) return EINVAL ; tsc -> stripe_chunksize = atoi64 ( ap ) ; if ( tsc -> stripe_chunksize < 1 || tsc -> stripe_chunksize * DEV_BSIZE > MAXPHYS ) { kprintf ( " \n " , ( intmax_t ) tsc -> stripe_chunksize * DEV_BSIZE / 1024 ) ; dm_target_stripe_destroy_config ( tsc ) ; return EINVAL ; } kprintf ( " \n " , ( int ) tsc -> stripe_num , ( int ) tsc -> stripe_chunksize ) ; for ( n = 0 ; n < tsc -> stripe_num ; ++ n ) { ap = strsep ( & params , " \t " ) ; if ( ap == NULL ) break ; tsc -> stripe_devs [ n ] . pdev = dm_pdev_insert ( ap ) ; if ( tsc -> stripe_devs [ n ] . pdev == NULL ) break ; ap = strsep ( & params , " \t " ) ; if ( ap == NULL ) break ; tsc -> stripe_devs [ n ] . offset = atoi64 ( ap ) ; } if ( n != tsc -> stripe_num ) { dm_target_stripe_destroy_config ( tsc ) ; return ( ENOENT ) ; } * target_config = tsc ; dmv -> dev_type = DM_STRIPE_DEV ; return 0 ; }
Init function called from dm_table_load_ioctl.
Init function called from dm_table_load_ioctl .
/*
	 * nstripes
	 */ /*
	 * Parse the devices
	 */