10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*1623Stw21770 * Common Development and Distribution License (the "License"). 6*1623Stw21770 * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*1623Stw21770 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 270Sstevel@tonic-gate 280Sstevel@tonic-gate /* 290Sstevel@tonic-gate * change metadevice parameters 300Sstevel@tonic-gate */ 310Sstevel@tonic-gate 320Sstevel@tonic-gate #include <meta.h> 330Sstevel@tonic-gate 340Sstevel@tonic-gate #include <sdssc.h> 350Sstevel@tonic-gate 360Sstevel@tonic-gate /* 370Sstevel@tonic-gate * print usage message 380Sstevel@tonic-gate */ 390Sstevel@tonic-gate static void 400Sstevel@tonic-gate usage( 410Sstevel@tonic-gate mdsetname_t *sp, 420Sstevel@tonic-gate int eval 430Sstevel@tonic-gate ) 440Sstevel@tonic-gate { 450Sstevel@tonic-gate (void) fprintf(stderr, gettext("\ 460Sstevel@tonic-gate usage: %s [-s setname] [options] concat/stripe | RAID\n\ 470Sstevel@tonic-gate %s [-s setname] [options] mirror\n\ 480Sstevel@tonic-gate \n\ 490Sstevel@tonic-gate Concat/Stripe or RAID options:\n\ 500Sstevel@tonic-gate -h hotspare_pool | \"none\"\n\ 510Sstevel@tonic-gate \n\ 520Sstevel@tonic-gate Mirror options:\n\ 530Sstevel@tonic-gate -r roundrobin | geometric | first\n\ 540Sstevel@tonic-gate -w parallel | serial\n\ 550Sstevel@tonic-gate -p 0-%d\n"), myname, myname, MD_PASS_MAX); 560Sstevel@tonic-gate 570Sstevel@tonic-gate md_exit(sp, eval); 580Sstevel@tonic-gate } 590Sstevel@tonic-gate 600Sstevel@tonic-gate /* 610Sstevel@tonic-gate * do mirror parameters 620Sstevel@tonic-gate */ 630Sstevel@tonic-gate static int 640Sstevel@tonic-gate mirror_params( 650Sstevel@tonic-gate mdsetname_t *sp, 660Sstevel@tonic-gate mdname_t *mirnp, 670Sstevel@tonic-gate int argc, 680Sstevel@tonic-gate char *argv[], 690Sstevel@tonic-gate md_error_t *ep 700Sstevel@tonic-gate ) 710Sstevel@tonic-gate { 720Sstevel@tonic-gate mm_params_t mmp; 730Sstevel@tonic-gate int modified = 0; 740Sstevel@tonic-gate int c; 750Sstevel@tonic-gate 760Sstevel@tonic-gate /* we must have a set */ 770Sstevel@tonic-gate assert(sp != NULL); 780Sstevel@tonic-gate assert(sp->setno == MD_MIN2SET(meta_getminor(mirnp->dev))); 790Sstevel@tonic-gate 800Sstevel@tonic-gate /* initialize */ 810Sstevel@tonic-gate (void) memset(&mmp, '\0', sizeof (mmp)); 820Sstevel@tonic-gate 830Sstevel@tonic-gate /* reset and parse args */ 840Sstevel@tonic-gate optind = 1; 850Sstevel@tonic-gate opterr = 1; 860Sstevel@tonic-gate while ((c = getopt(argc, argv, "s:r:w:p:")) != -1) { 870Sstevel@tonic-gate switch (c) { 880Sstevel@tonic-gate case 's': 890Sstevel@tonic-gate break; 900Sstevel@tonic-gate 910Sstevel@tonic-gate case 'r': 920Sstevel@tonic-gate if (name_to_rd_opt(mirnp->cname, optarg, 930Sstevel@tonic-gate &mmp.read_option, ep) != 0) { 940Sstevel@tonic-gate return (-1); 950Sstevel@tonic-gate } 960Sstevel@tonic-gate mmp.change_read_option = 1; 970Sstevel@tonic-gate modified = 1; 980Sstevel@tonic-gate break; 990Sstevel@tonic-gate 1000Sstevel@tonic-gate case 'w': 1010Sstevel@tonic-gate if (name_to_wr_opt(mirnp->cname, optarg, 1020Sstevel@tonic-gate &mmp.write_option, ep) != 0) { 1030Sstevel@tonic-gate return (-1); 1040Sstevel@tonic-gate } 1050Sstevel@tonic-gate mmp.change_write_option = 1; 1060Sstevel@tonic-gate modified = 1; 1070Sstevel@tonic-gate break; 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate case 'p': 1100Sstevel@tonic-gate if (name_to_pass_num(mirnp->cname, optarg, 1110Sstevel@tonic-gate &mmp.pass_num, ep) != 0) { 1120Sstevel@tonic-gate return (-1); 1130Sstevel@tonic-gate } 1140Sstevel@tonic-gate mmp.change_pass_num = 1; 1150Sstevel@tonic-gate modified = 1; 1160Sstevel@tonic-gate break; 1170Sstevel@tonic-gate 1180Sstevel@tonic-gate default: 1190Sstevel@tonic-gate usage(sp, 1); 1200Sstevel@tonic-gate /*NOTREACHED*/ 1210Sstevel@tonic-gate break; 1220Sstevel@tonic-gate } 1230Sstevel@tonic-gate } 1240Sstevel@tonic-gate 1250Sstevel@tonic-gate argc -= optind; 1260Sstevel@tonic-gate argv += optind; 1270Sstevel@tonic-gate if (argc != 1) 1280Sstevel@tonic-gate usage(sp, 1); 1290Sstevel@tonic-gate 1300Sstevel@tonic-gate /* if just printing */ 1310Sstevel@tonic-gate if (! modified) { 1320Sstevel@tonic-gate if (meta_mirror_get_params(sp, mirnp, &mmp, ep) != 0) 1330Sstevel@tonic-gate return (-1); 1340Sstevel@tonic-gate (void) printf( 1350Sstevel@tonic-gate gettext( 1360Sstevel@tonic-gate "%s: Mirror current parameters are:\n"), 1370Sstevel@tonic-gate mirnp->cname); 1380Sstevel@tonic-gate if (meta_print_mirror_options(mmp.read_option, 1390Sstevel@tonic-gate mmp.write_option, mmp.pass_num, 0, NULL, 1400Sstevel@tonic-gate sp, stdout, ep) != 0) { 1410Sstevel@tonic-gate return (-1); 1420Sstevel@tonic-gate } 1430Sstevel@tonic-gate } 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate /* otherwise, change parameters */ 1460Sstevel@tonic-gate else { 1470Sstevel@tonic-gate if (meta_mirror_set_params(sp, mirnp, &mmp, ep) != 0) 1480Sstevel@tonic-gate return (-1); 1490Sstevel@tonic-gate 1500Sstevel@tonic-gate /* update md.cf */ 1510Sstevel@tonic-gate if (meta_update_md_cf(sp, ep) != 0) 1520Sstevel@tonic-gate return (-1); 1530Sstevel@tonic-gate } 1540Sstevel@tonic-gate 1550Sstevel@tonic-gate /* return success */ 1560Sstevel@tonic-gate return (0); 1570Sstevel@tonic-gate } 1580Sstevel@tonic-gate 1590Sstevel@tonic-gate /* 1600Sstevel@tonic-gate * do stripe parameters 1610Sstevel@tonic-gate */ 1620Sstevel@tonic-gate static int 1630Sstevel@tonic-gate stripe_params( 1640Sstevel@tonic-gate mdsetname_t *sp, 1650Sstevel@tonic-gate mdname_t *stripenp, 1660Sstevel@tonic-gate int argc, 1670Sstevel@tonic-gate char *argv[], 1680Sstevel@tonic-gate md_error_t *ep 1690Sstevel@tonic-gate ) 1700Sstevel@tonic-gate { 1710Sstevel@tonic-gate ms_params_t msp; 1720Sstevel@tonic-gate int modified = 0; 1730Sstevel@tonic-gate mdhspname_t *hspnp; 1740Sstevel@tonic-gate int c; 1750Sstevel@tonic-gate 1760Sstevel@tonic-gate /* we must have a set */ 1770Sstevel@tonic-gate assert(sp != NULL); 1780Sstevel@tonic-gate assert(sp->setno == MD_MIN2SET(meta_getminor(stripenp->dev))); 1790Sstevel@tonic-gate 1800Sstevel@tonic-gate /* initialize */ 1810Sstevel@tonic-gate (void) memset(&msp, '\0', sizeof (msp)); 1820Sstevel@tonic-gate 1830Sstevel@tonic-gate /* reset and parse args */ 1840Sstevel@tonic-gate optind = 1; 1850Sstevel@tonic-gate opterr = 1; 1860Sstevel@tonic-gate while ((c = getopt(argc, argv, "s:h:")) != -1) { 1870Sstevel@tonic-gate switch (c) { 1880Sstevel@tonic-gate case 's': 1890Sstevel@tonic-gate break; 1900Sstevel@tonic-gate 1910Sstevel@tonic-gate case 'h': 192*1623Stw21770 if (meta_is_none(optarg)) { 1930Sstevel@tonic-gate msp.hsp_id = MD_HSP_NONE; 1940Sstevel@tonic-gate } else if ((hspnp = metahspname(&sp, optarg, 1950Sstevel@tonic-gate ep)) == NULL) { 1960Sstevel@tonic-gate return (-1); 1970Sstevel@tonic-gate } else if (metachkhsp(sp, hspnp, ep) != 0) { 1980Sstevel@tonic-gate return (-1); 1990Sstevel@tonic-gate } else { 2000Sstevel@tonic-gate msp.hsp_id = hspnp->hsp; 2010Sstevel@tonic-gate } 2020Sstevel@tonic-gate msp.change_hsp_id = 1; 2030Sstevel@tonic-gate modified = 1; 2040Sstevel@tonic-gate break; 2050Sstevel@tonic-gate 2060Sstevel@tonic-gate default: 2070Sstevel@tonic-gate usage(sp, 1); 2080Sstevel@tonic-gate /*NOTREACHED*/ 2090Sstevel@tonic-gate break; 2100Sstevel@tonic-gate } 2110Sstevel@tonic-gate } 2120Sstevel@tonic-gate argc -= optind; 2130Sstevel@tonic-gate argv += optind; 2140Sstevel@tonic-gate if (argc != 1) 2150Sstevel@tonic-gate usage(sp, 1); 2160Sstevel@tonic-gate 2170Sstevel@tonic-gate /* if just printing */ 2180Sstevel@tonic-gate if (! modified) { 2190Sstevel@tonic-gate if (meta_stripe_get_params(sp, stripenp, &msp, ep) != 0) 2200Sstevel@tonic-gate return (-1); 2210Sstevel@tonic-gate if (msp.hsp_id == MD_HSP_NONE) 2220Sstevel@tonic-gate hspnp = NULL; 2230Sstevel@tonic-gate else if ((hspnp = metahsphspname(&sp, msp.hsp_id, ep)) == NULL) 2240Sstevel@tonic-gate return (-1); 2250Sstevel@tonic-gate (void) printf(gettext( 2260Sstevel@tonic-gate "%s: Concat/Stripe current parameters are:\n"), 2270Sstevel@tonic-gate stripenp->cname); 2280Sstevel@tonic-gate if (meta_print_stripe_options(hspnp, NULL, stdout, ep) != 0) 2290Sstevel@tonic-gate return (-1); 2300Sstevel@tonic-gate } 2310Sstevel@tonic-gate 2320Sstevel@tonic-gate /* otherwise, change parameters */ 2330Sstevel@tonic-gate else { 2340Sstevel@tonic-gate if (meta_stripe_set_params(sp, stripenp, &msp, ep) != 0) 2350Sstevel@tonic-gate return (-1); 2360Sstevel@tonic-gate 2370Sstevel@tonic-gate /* update md.cf */ 2380Sstevel@tonic-gate if (meta_update_md_cf(sp, ep) != 0) 2390Sstevel@tonic-gate return (-1); 2400Sstevel@tonic-gate } 2410Sstevel@tonic-gate 2420Sstevel@tonic-gate /* return success */ 2430Sstevel@tonic-gate return (0); 2440Sstevel@tonic-gate } 2450Sstevel@tonic-gate 2460Sstevel@tonic-gate /* 2470Sstevel@tonic-gate * do raid parameters 2480Sstevel@tonic-gate */ 2490Sstevel@tonic-gate static int 2500Sstevel@tonic-gate raid_params( 2510Sstevel@tonic-gate mdsetname_t *sp, 2520Sstevel@tonic-gate mdname_t *raidnp, 2530Sstevel@tonic-gate int argc, 2540Sstevel@tonic-gate char *argv[], 2550Sstevel@tonic-gate md_error_t *ep 2560Sstevel@tonic-gate ) 2570Sstevel@tonic-gate { 2580Sstevel@tonic-gate mr_params_t msp; 2590Sstevel@tonic-gate int modified = 0; 2600Sstevel@tonic-gate mdhspname_t *hspnp; 2610Sstevel@tonic-gate int c; 2620Sstevel@tonic-gate 2630Sstevel@tonic-gate /* we must have a set */ 2640Sstevel@tonic-gate assert(sp != NULL); 2650Sstevel@tonic-gate assert(sp->setno == MD_MIN2SET(meta_getminor(raidnp->dev))); 2660Sstevel@tonic-gate 2670Sstevel@tonic-gate /* initialize */ 2680Sstevel@tonic-gate (void) memset(&msp, '\0', sizeof (msp)); 2690Sstevel@tonic-gate 2700Sstevel@tonic-gate /* reset and parse args */ 2710Sstevel@tonic-gate optind = 1; 2720Sstevel@tonic-gate opterr = 1; 2730Sstevel@tonic-gate while ((c = getopt(argc, argv, "s:h:")) != -1) { 2740Sstevel@tonic-gate switch (c) { 2750Sstevel@tonic-gate case 's': 2760Sstevel@tonic-gate break; 2770Sstevel@tonic-gate 2780Sstevel@tonic-gate case 'h': 279*1623Stw21770 if (meta_is_none(optarg)) { 2800Sstevel@tonic-gate msp.hsp_id = MD_HSP_NONE; 2810Sstevel@tonic-gate } else if ((hspnp = metahspname(&sp, optarg, 2820Sstevel@tonic-gate ep)) == NULL) { 2830Sstevel@tonic-gate return (-1); 2840Sstevel@tonic-gate } else if (metachkhsp(sp, hspnp, ep) != 0) { 2850Sstevel@tonic-gate return (-1); 2860Sstevel@tonic-gate } else { 2870Sstevel@tonic-gate msp.hsp_id = hspnp->hsp; 2880Sstevel@tonic-gate } 2890Sstevel@tonic-gate msp.change_hsp_id = 1; 2900Sstevel@tonic-gate modified = 1; 2910Sstevel@tonic-gate break; 2920Sstevel@tonic-gate 2930Sstevel@tonic-gate default: 2940Sstevel@tonic-gate usage(sp, 1); 2950Sstevel@tonic-gate /*NOTREACHED*/ 2960Sstevel@tonic-gate break; 2970Sstevel@tonic-gate } 2980Sstevel@tonic-gate } 2990Sstevel@tonic-gate argc -= optind; 3000Sstevel@tonic-gate argv += optind; 3010Sstevel@tonic-gate if (argc != 1) 3020Sstevel@tonic-gate usage(sp, 1); 3030Sstevel@tonic-gate 3040Sstevel@tonic-gate /* if just printing */ 3050Sstevel@tonic-gate if (! modified) { 3060Sstevel@tonic-gate if (meta_raid_get_params(sp, raidnp, &msp, ep) != 0) 3070Sstevel@tonic-gate return (-1); 3080Sstevel@tonic-gate if (msp.hsp_id == MD_HSP_NONE) 3090Sstevel@tonic-gate hspnp = NULL; 3100Sstevel@tonic-gate else if ((hspnp = metahsphspname(&sp, msp.hsp_id, ep)) == NULL) 3110Sstevel@tonic-gate return (-1); 3120Sstevel@tonic-gate (void) printf(gettext( 3130Sstevel@tonic-gate "%s: RAID current parameters are:\n"), 3140Sstevel@tonic-gate raidnp->cname); 3150Sstevel@tonic-gate if (meta_print_raid_options(hspnp, NULL, stdout, ep) != 0) 3160Sstevel@tonic-gate return (-1); 3170Sstevel@tonic-gate } 3180Sstevel@tonic-gate 3190Sstevel@tonic-gate /* otherwise, change parameters */ 3200Sstevel@tonic-gate else { 3210Sstevel@tonic-gate if (meta_raid_set_params(sp, raidnp, &msp, ep) != 0) 3220Sstevel@tonic-gate return (-1); 3230Sstevel@tonic-gate 3240Sstevel@tonic-gate /* update md.cf */ 3250Sstevel@tonic-gate if (meta_update_md_cf(sp, ep) != 0) 3260Sstevel@tonic-gate return (-1); 3270Sstevel@tonic-gate } 3280Sstevel@tonic-gate 3290Sstevel@tonic-gate /* return success */ 3300Sstevel@tonic-gate return (0); 3310Sstevel@tonic-gate } 3320Sstevel@tonic-gate 3330Sstevel@tonic-gate /* 3340Sstevel@tonic-gate * parse args and doit 3350Sstevel@tonic-gate */ 3360Sstevel@tonic-gate int 3370Sstevel@tonic-gate main( 3380Sstevel@tonic-gate int argc, 3390Sstevel@tonic-gate char **argv 3400Sstevel@tonic-gate ) 3410Sstevel@tonic-gate { 3420Sstevel@tonic-gate char *sname = NULL; 3430Sstevel@tonic-gate mdsetname_t *sp = NULL; 3440Sstevel@tonic-gate mdname_t *np; 3450Sstevel@tonic-gate char *miscname; 3460Sstevel@tonic-gate int c; 3470Sstevel@tonic-gate md_error_t status = mdnullerror; 3480Sstevel@tonic-gate md_error_t *ep = &status; 3490Sstevel@tonic-gate int error; 3500Sstevel@tonic-gate bool_t called_thru_rpc = FALSE; 3510Sstevel@tonic-gate char *cp; 3520Sstevel@tonic-gate char *firstarg = NULL; 3530Sstevel@tonic-gate 3540Sstevel@tonic-gate 3550Sstevel@tonic-gate /* 3560Sstevel@tonic-gate * Get the locale set up before calling any other routines 3570Sstevel@tonic-gate * with messages to ouput. Just in case we're not in a build 3580Sstevel@tonic-gate * environment, make sure that TEXT_DOMAIN gets set to 3590Sstevel@tonic-gate * something. 3600Sstevel@tonic-gate */ 3610Sstevel@tonic-gate #if !defined(TEXT_DOMAIN) 3620Sstevel@tonic-gate #define TEXT_DOMAIN "SYS_TEST" 3630Sstevel@tonic-gate #endif 3640Sstevel@tonic-gate (void) setlocale(LC_ALL, ""); 3650Sstevel@tonic-gate (void) textdomain(TEXT_DOMAIN); 3660Sstevel@tonic-gate 3670Sstevel@tonic-gate if ((cp = strstr(argv[0], ".rpc_call")) == NULL) { 3680Sstevel@tonic-gate if (sdssc_bind_library() == SDSSC_OKAY) 3690Sstevel@tonic-gate if (sdssc_cmd_proxy(argc, argv, SDSSC_PROXY_PRIMARY, 3700Sstevel@tonic-gate &error) == SDSSC_PROXY_DONE) 3710Sstevel@tonic-gate exit(error); 3720Sstevel@tonic-gate } else { 3730Sstevel@tonic-gate *cp = '\0'; /* cut off ".rpc_call" */ 3740Sstevel@tonic-gate called_thru_rpc = TRUE; 3750Sstevel@tonic-gate } 3760Sstevel@tonic-gate 3770Sstevel@tonic-gate 3780Sstevel@tonic-gate /* initialize */ 3790Sstevel@tonic-gate if (md_init(argc, argv, 0, 1, ep) != 0 || 3800Sstevel@tonic-gate meta_check_root(ep) != 0) { 3810Sstevel@tonic-gate mde_perror(ep, ""); 3820Sstevel@tonic-gate md_exit(sp, 1); 3830Sstevel@tonic-gate } 3840Sstevel@tonic-gate 3850Sstevel@tonic-gate /* find set and metadevice first */ 3860Sstevel@tonic-gate optind = 1; 3870Sstevel@tonic-gate opterr = 1; 3880Sstevel@tonic-gate while ((c = getopt(argc, argv, "s:h:p:r:w:o:?")) != -1) { 3890Sstevel@tonic-gate switch (c) { 3900Sstevel@tonic-gate case 's': 3910Sstevel@tonic-gate sname = optarg; 3920Sstevel@tonic-gate break; 3930Sstevel@tonic-gate case 'h': 3940Sstevel@tonic-gate firstarg = optarg; 3950Sstevel@tonic-gate break; 3960Sstevel@tonic-gate case '?': 3970Sstevel@tonic-gate if (optopt == '?') 3980Sstevel@tonic-gate usage(sp, 0); 3990Sstevel@tonic-gate break; 4000Sstevel@tonic-gate } 4010Sstevel@tonic-gate } 4020Sstevel@tonic-gate if ((argc - optind) <= 0) 4030Sstevel@tonic-gate usage(sp, 1); 4040Sstevel@tonic-gate 4050Sstevel@tonic-gate if (sname != NULL) { 4060Sstevel@tonic-gate if ((sp = metasetname(sname, ep)) == NULL) { 4070Sstevel@tonic-gate mde_perror(ep, ""); 4080Sstevel@tonic-gate md_exit(sp, 1); 4090Sstevel@tonic-gate } 4100Sstevel@tonic-gate } 4110Sstevel@tonic-gate if (firstarg == NULL) 4120Sstevel@tonic-gate firstarg = argv[optind]; 4130Sstevel@tonic-gate if ((called_thru_rpc == FALSE) && 4140Sstevel@tonic-gate meta_is_mn_name(&sp, firstarg, ep)) { 4150Sstevel@tonic-gate /* 4160Sstevel@tonic-gate * If we are dealing with a MN set and we were not 4170Sstevel@tonic-gate * called thru an rpc call, we are just to send this 4180Sstevel@tonic-gate * command string to the master of the set and let it 4190Sstevel@tonic-gate * deal with it. 4200Sstevel@tonic-gate * Note that if sp is NULL, meta_is_mn_name() derives sp 4210Sstevel@tonic-gate * from firstarg which is the metadevice arg 4220Sstevel@tonic-gate * If this fails, the master must panic as the mddb may be 4230Sstevel@tonic-gate * inconsistent 4240Sstevel@tonic-gate */ 4250Sstevel@tonic-gate int result; 4260Sstevel@tonic-gate result = meta_mn_send_command(sp, argc, argv, MD_DISP_STDERR | 4270Sstevel@tonic-gate MD_PANIC_WHEN_INCONSISTENT, NO_CONTEXT_STRING, ep); 4280Sstevel@tonic-gate /* No further action required */ 4290Sstevel@tonic-gate md_exit(sp, result); 4300Sstevel@tonic-gate } 4310Sstevel@tonic-gate 432*1623Stw21770 if ((np = metaname(&sp, argv[optind], META_DEVICE, ep)) == NULL) { 4330Sstevel@tonic-gate mde_perror(ep, ""); 4340Sstevel@tonic-gate md_exit(sp, 1); 4350Sstevel@tonic-gate } 4360Sstevel@tonic-gate assert(sp != NULL); 4370Sstevel@tonic-gate /* grab set lock */ 4380Sstevel@tonic-gate if (meta_lock(sp, TRUE, ep)) { 4390Sstevel@tonic-gate mde_perror(ep, ""); 4400Sstevel@tonic-gate md_exit(sp, 1); 4410Sstevel@tonic-gate } 4420Sstevel@tonic-gate 4430Sstevel@tonic-gate if (meta_check_ownership(sp, ep) != 0) { 4440Sstevel@tonic-gate mde_perror(ep, ""); 4450Sstevel@tonic-gate md_exit(sp, 1); 4460Sstevel@tonic-gate } 4470Sstevel@tonic-gate if ((miscname = metagetmiscname(np, ep)) == NULL) { 4480Sstevel@tonic-gate mde_perror(ep, ""); 4490Sstevel@tonic-gate md_exit(sp, 1); 4500Sstevel@tonic-gate } 4510Sstevel@tonic-gate 4520Sstevel@tonic-gate /* dispatch based on device type */ 4530Sstevel@tonic-gate if (strcmp(miscname, MD_STRIPE) == 0) { 4540Sstevel@tonic-gate if (stripe_params(sp, np, argc, argv, ep) != 0) { 4550Sstevel@tonic-gate mde_perror(ep, ""); 4560Sstevel@tonic-gate md_exit(sp, 1); 4570Sstevel@tonic-gate } 4580Sstevel@tonic-gate } else if (strcmp(miscname, MD_MIRROR) == 0) { 4590Sstevel@tonic-gate if (mirror_params(sp, np, argc, argv, ep) != 0) { 4600Sstevel@tonic-gate mde_perror(ep, ""); 4610Sstevel@tonic-gate md_exit(sp, 1); 4620Sstevel@tonic-gate } 4630Sstevel@tonic-gate } else if (strcmp(miscname, MD_RAID) == 0) { 4640Sstevel@tonic-gate if (raid_params(sp, np, argc, argv, ep) != 0) { 4650Sstevel@tonic-gate mde_perror(ep, ""); 4660Sstevel@tonic-gate md_exit(sp, 1); 4670Sstevel@tonic-gate } 4680Sstevel@tonic-gate } else { 4690Sstevel@tonic-gate md_eprintf(gettext( 4700Sstevel@tonic-gate "%s: invalid metadevice type %s\n"), 4710Sstevel@tonic-gate np->cname, miscname); 4720Sstevel@tonic-gate md_exit(sp, 1); 4730Sstevel@tonic-gate } 4740Sstevel@tonic-gate 4750Sstevel@tonic-gate /* return success */ 4760Sstevel@tonic-gate md_exit(sp, 0); 4770Sstevel@tonic-gate /*NOTREACHED*/ 4780Sstevel@tonic-gate return (0); 4790Sstevel@tonic-gate } 480