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 51623Stw21770 * Common Development and Distribution License (the "License"). 61623Stw21770 * 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 220Sstevel@tonic-gate /* 231623Stw21770 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 280Sstevel@tonic-gate 290Sstevel@tonic-gate #include <meta.h> 300Sstevel@tonic-gate #include <sdssc.h> 310Sstevel@tonic-gate #include <signal.h> 320Sstevel@tonic-gate #include <syslog.h> 330Sstevel@tonic-gate #include <sys/types.h> 340Sstevel@tonic-gate #include <sys/wait.h> 350Sstevel@tonic-gate #include <sys/lvm/md_mirror.h> 360Sstevel@tonic-gate #include <metad.h> 370Sstevel@tonic-gate 380Sstevel@tonic-gate #define MY_VERSION "1.0" /* the highest supported version */ 390Sstevel@tonic-gate #define MAX_DEBUG_LEVEL 5 /* maximum verbosity level */ 400Sstevel@tonic-gate 410Sstevel@tonic-gate #define RESET_OWNER 0x0001 420Sstevel@tonic-gate #define CHOOSE_OWNER 0x0002 430Sstevel@tonic-gate #define RESET_ABR 0x0004 440Sstevel@tonic-gate #define UPDATE_ABR 0x0008 450Sstevel@tonic-gate #define GET_MIRROR_STATE 0x0010 460Sstevel@tonic-gate 470Sstevel@tonic-gate #define SET_INFO_NO_WR 0x0002 480Sstevel@tonic-gate #define SET_INFO_MN 0x0004 490Sstevel@tonic-gate 500Sstevel@tonic-gate /* 510Sstevel@tonic-gate * This table defines all the metaclust reconfig steps we understand 520Sstevel@tonic-gate */ 530Sstevel@tonic-gate typedef enum stpnum { 540Sstevel@tonic-gate MC_UNK = 0, 550Sstevel@tonic-gate MC_START, 560Sstevel@tonic-gate MC_STOP, 570Sstevel@tonic-gate MC_ABORT, 580Sstevel@tonic-gate MC_RETURN, 590Sstevel@tonic-gate MC_STEP1, 600Sstevel@tonic-gate MC_STEP2, 610Sstevel@tonic-gate MC_STEP3, 620Sstevel@tonic-gate MC_STEP4 630Sstevel@tonic-gate } stepnum_t; 640Sstevel@tonic-gate 650Sstevel@tonic-gate /* 660Sstevel@tonic-gate * Structure for step_name -> step_number mapping 670Sstevel@tonic-gate */ 680Sstevel@tonic-gate struct step_t { 690Sstevel@tonic-gate char *step_nam; 700Sstevel@tonic-gate stepnum_t step_num; 710Sstevel@tonic-gate }; 720Sstevel@tonic-gate 730Sstevel@tonic-gate /* 740Sstevel@tonic-gate * Step name to step number mapping table 750Sstevel@tonic-gate * This table MUST be sorted alphabetically in ascending order of step name 760Sstevel@tonic-gate */ 770Sstevel@tonic-gate static struct step_t step_table[] = { 780Sstevel@tonic-gate { "abort", MC_ABORT }, 790Sstevel@tonic-gate { "return", MC_RETURN }, 800Sstevel@tonic-gate { "start", MC_START }, 810Sstevel@tonic-gate { "step1", MC_STEP1 }, 820Sstevel@tonic-gate { "step2", MC_STEP2 }, 830Sstevel@tonic-gate { "step3", MC_STEP3 }, 840Sstevel@tonic-gate { "step4", MC_STEP4 }, 850Sstevel@tonic-gate { "stop", MC_STOP } 860Sstevel@tonic-gate }; 870Sstevel@tonic-gate 880Sstevel@tonic-gate /* 890Sstevel@tonic-gate * If support for a different version is added, the new version number should 900Sstevel@tonic-gate * be appended to the version_table below. This list will be searched to 910Sstevel@tonic-gate * determine if a version requested via the -V option is supported or not. 920Sstevel@tonic-gate */ 930Sstevel@tonic-gate static char *version_table[] = { 940Sstevel@tonic-gate MY_VERSION 950Sstevel@tonic-gate }; 960Sstevel@tonic-gate 970Sstevel@tonic-gate uint_t timeout = 0; /* disable timeout by default */ 980Sstevel@tonic-gate char *version = MY_VERSION; /* use latest version by default */ 990Sstevel@tonic-gate int stepnum = MC_UNK; /* reconfiguration step number */ 1000Sstevel@tonic-gate pid_t c_pid; /* child process id */ 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate /* 1030Sstevel@tonic-gate * Binary search comparison routine 1040Sstevel@tonic-gate */ 1050Sstevel@tonic-gate static int 1060Sstevel@tonic-gate mc_compare(const void *stp1, const void *stp2) 1070Sstevel@tonic-gate { 1080Sstevel@tonic-gate return (strcmp((const char *)stp1, 1090Sstevel@tonic-gate ((const struct step_t *)stp2)->step_nam)); 1100Sstevel@tonic-gate } 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate /* 1130Sstevel@tonic-gate * Timeout expiry alarm signal handler 1140Sstevel@tonic-gate */ 1150Sstevel@tonic-gate /*ARGSUSED*/ 1160Sstevel@tonic-gate static void 1170Sstevel@tonic-gate sigalarmhandler(int sig) 1180Sstevel@tonic-gate { 1190Sstevel@tonic-gate int i, n, ret, stat_loc = 0; 1200Sstevel@tonic-gate 1210Sstevel@tonic-gate n = sizeof (step_table) / sizeof (step_table[0]); 1220Sstevel@tonic-gate for (i = 0; i < n; i++) { 1230Sstevel@tonic-gate if (stepnum == step_table[i].step_num) 1240Sstevel@tonic-gate break; 1250Sstevel@tonic-gate } 1260Sstevel@tonic-gate 1270Sstevel@tonic-gate assert(i != n); 1280Sstevel@tonic-gate 1290Sstevel@tonic-gate meta_mc_log(MC_LOG1, gettext("Timeout expired in %s: %s"), 1300Sstevel@tonic-gate step_table[i].step_nam, 1310Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate if ((ret = kill(c_pid, SIGKILL)) == 0) { 1340Sstevel@tonic-gate /* 1350Sstevel@tonic-gate * The child will wait forever until the status is retrieved 1360Sstevel@tonic-gate * so get it now. Keep retrying if the call is interrupted. 1370Sstevel@tonic-gate * 1380Sstevel@tonic-gate * The possible results are, 1390Sstevel@tonic-gate * 1400Sstevel@tonic-gate * - child killed successfully 1410Sstevel@tonic-gate * - signal sent but child not killed 1420Sstevel@tonic-gate * - waitpid failed/interrupted 1430Sstevel@tonic-gate */ 1440Sstevel@tonic-gate sleep(2); 1450Sstevel@tonic-gate while ((ret = waitpid(c_pid, &stat_loc, WNOHANG)) < 0) { 1460Sstevel@tonic-gate if (errno != EINTR) { 1470Sstevel@tonic-gate break; 1480Sstevel@tonic-gate } 1490Sstevel@tonic-gate } 1500Sstevel@tonic-gate if ((ret == c_pid) || (errno == ECHILD)) { 1510Sstevel@tonic-gate ret = 0; 1520Sstevel@tonic-gate } else { 1530Sstevel@tonic-gate ret = 1; 1540Sstevel@tonic-gate } 1550Sstevel@tonic-gate } else if (errno == ESRCH) { 1560Sstevel@tonic-gate /* 1570Sstevel@tonic-gate * If the kill did not catch the child then it means the child 1580Sstevel@tonic-gate * exited immediately after the timeout occured. 1590Sstevel@tonic-gate */ 1600Sstevel@tonic-gate ret = 0; 1610Sstevel@tonic-gate } 1620Sstevel@tonic-gate 1630Sstevel@tonic-gate /* 1640Sstevel@tonic-gate * make sure not to exit with 205 for any steps other than step1-step4. 1650Sstevel@tonic-gate * Suncluster reconfiguration can't handle it otherwise. 1660Sstevel@tonic-gate */ 1670Sstevel@tonic-gate switch (stepnum) { 1680Sstevel@tonic-gate case MC_STEP1: 1690Sstevel@tonic-gate case MC_STEP2: 1700Sstevel@tonic-gate case MC_STEP3: 1710Sstevel@tonic-gate case MC_STEP4: 1720Sstevel@tonic-gate /* 1730Sstevel@tonic-gate * If the child was killed successfully return 205 for a 1740Sstevel@tonic-gate * new reconfig cycle otherwise send 1 to panic the node. 1750Sstevel@tonic-gate */ 1760Sstevel@tonic-gate if (ret != 0) { 1770Sstevel@tonic-gate md_eprintf(gettext("Could not kill child\n")); 1780Sstevel@tonic-gate exit(1); 1790Sstevel@tonic-gate } else { 1800Sstevel@tonic-gate exit(205); 1810Sstevel@tonic-gate } 1820Sstevel@tonic-gate break; 1830Sstevel@tonic-gate case MC_START: 1840Sstevel@tonic-gate case MC_STOP: 1850Sstevel@tonic-gate case MC_ABORT: 1860Sstevel@tonic-gate case MC_RETURN: 1870Sstevel@tonic-gate default: 1880Sstevel@tonic-gate exit(1); 1890Sstevel@tonic-gate break; 1900Sstevel@tonic-gate } 1910Sstevel@tonic-gate } 1920Sstevel@tonic-gate 1930Sstevel@tonic-gate /* 1940Sstevel@tonic-gate * Attempt to load local set. 1950Sstevel@tonic-gate * Returns: 1960Sstevel@tonic-gate * pointer to mdsetname_t for local set (local_sp) is successful. 1970Sstevel@tonic-gate * 0 if failure 1980Sstevel@tonic-gate * if there are no local set mddbs, no error message is printed. 1990Sstevel@tonic-gate * Otherwise, error message is printed so that user 2000Sstevel@tonic-gate * can determine why the local set didn't start. 2010Sstevel@tonic-gate */ 2020Sstevel@tonic-gate mdsetname_t * 2030Sstevel@tonic-gate load_local_set(md_error_t *ep) 2040Sstevel@tonic-gate { 2050Sstevel@tonic-gate mdsetname_t *local_sp = NULL; 2060Sstevel@tonic-gate 2070Sstevel@tonic-gate /* Does local set exist? If not, give no error */ 2080Sstevel@tonic-gate if ((local_sp = metasetname(MD_LOCAL_NAME, ep)) == NULL) { 2090Sstevel@tonic-gate return (0); 2100Sstevel@tonic-gate } 2110Sstevel@tonic-gate 2120Sstevel@tonic-gate /* 2130Sstevel@tonic-gate * snarf local set 2140Sstevel@tonic-gate * If fails with MDE_DB_NODB, then just return 1 printing 2150Sstevel@tonic-gate * no failure. 2160Sstevel@tonic-gate * Otherwise, print error message, and return 1. 2170Sstevel@tonic-gate */ 2180Sstevel@tonic-gate if (meta_setup_db_locations(ep) != 0) { 2190Sstevel@tonic-gate if (!(mdismddberror(ep, MDE_DB_NODB))) 2200Sstevel@tonic-gate mde_perror(ep, ""); 2210Sstevel@tonic-gate return (0); 2220Sstevel@tonic-gate } 2230Sstevel@tonic-gate 2240Sstevel@tonic-gate /* local set loaded successfully */ 2250Sstevel@tonic-gate return (local_sp); 2260Sstevel@tonic-gate } 2270Sstevel@tonic-gate 2280Sstevel@tonic-gate /* 2290Sstevel@tonic-gate * Purpose: Compose a full path name for a metadevice 2300Sstevel@tonic-gate * 2310Sstevel@tonic-gate * On entry: sp - setname pointer 2320Sstevel@tonic-gate * mnum - minor number of metadevice 2330Sstevel@tonic-gate * pathname - pointer to array to return path string 2340Sstevel@tonic-gate * pathlen - max length of pathname array 2350Sstevel@tonic-gate */ 2360Sstevel@tonic-gate static int 2370Sstevel@tonic-gate compose_path(mdsetname_t *sp, int mnum, char *pathname, int pathlen) 2380Sstevel@tonic-gate { 2390Sstevel@tonic-gate int rtn; 2401623Stw21770 mdname_t *np; 2411623Stw21770 md_error_t status = mdnullerror; 2420Sstevel@tonic-gate 2430Sstevel@tonic-gate if (MD_MIN2SET(mnum) != sp->setno) { 2440Sstevel@tonic-gate md_eprintf(gettext("minor number 0x%x invalid for set %d\n"), 2450Sstevel@tonic-gate mnum, sp->setno); 2460Sstevel@tonic-gate return (-1); 2470Sstevel@tonic-gate } 2481623Stw21770 2491623Stw21770 if ((np = metamnumname(&sp, mnum, 0, &status)) == NULL) { 2501623Stw21770 return (-1); 2511623Stw21770 } 2521623Stw21770 2531623Stw21770 rtn = snprintf(pathname, pathlen, "%s", np->rname); 2540Sstevel@tonic-gate 2550Sstevel@tonic-gate if ((pathname[0] == '\0') || (rtn >= pathlen)) { 2560Sstevel@tonic-gate md_eprintf(gettext( 2571623Stw21770 "Could not create path for device %s\n"), 2581623Stw21770 get_mdname(sp, mnum)); 2590Sstevel@tonic-gate return (-1); 2600Sstevel@tonic-gate } 2610Sstevel@tonic-gate return (0); 2620Sstevel@tonic-gate } 2630Sstevel@tonic-gate 2640Sstevel@tonic-gate /* 2650Sstevel@tonic-gate * Purpose: Walk through all the devices specified for the given set 2660Sstevel@tonic-gate * and do the action specified in mode 2670Sstevel@tonic-gate */ 2680Sstevel@tonic-gate static int 2690Sstevel@tonic-gate reset_state(uint_t mode, mdsetname_t *sp, char *drivername, md_error_t *ep) 2700Sstevel@tonic-gate { 2710Sstevel@tonic-gate mdnamelist_t *devnlp = NULL; 2720Sstevel@tonic-gate mdnamelist_t *p; 2730Sstevel@tonic-gate mdname_t *devnp = NULL; 2740Sstevel@tonic-gate md_set_mmown_params_t ownpar_p; 2750Sstevel@tonic-gate md_set_mmown_params_t *ownpar = &ownpar_p; 2760Sstevel@tonic-gate md_unit_t *mm; 2770Sstevel@tonic-gate int mirror_dev = 0; 2780Sstevel@tonic-gate mndiskset_membershiplist_t *nl; 2790Sstevel@tonic-gate int cnt; 2800Sstevel@tonic-gate int has_parent; 2810Sstevel@tonic-gate md_mn_get_mir_state_t mir_state_p; 2820Sstevel@tonic-gate md_mn_get_mir_state_t *mir_state = &mir_state_p; 2830Sstevel@tonic-gate 2840Sstevel@tonic-gate /* 2850Sstevel@tonic-gate * if we are choosing or resetting the owners then make sure 2860Sstevel@tonic-gate * we are only doing it for mirror devices 2870Sstevel@tonic-gate */ 2880Sstevel@tonic-gate mirror_dev = (strcmp(MD_MIRROR, drivername) == 0); 2890Sstevel@tonic-gate if ((mode & (RESET_OWNER | CHOOSE_OWNER)) && !mirror_dev) { 2900Sstevel@tonic-gate return (-1); 2910Sstevel@tonic-gate } 2920Sstevel@tonic-gate 2930Sstevel@tonic-gate /* get a list of all the metadevices for current set */ 2940Sstevel@tonic-gate if (mirror_dev && meta_get_mirror_names(sp, &devnlp, 0, ep) < 0) { 2950Sstevel@tonic-gate mde_perror(ep, gettext("Could not get mirrors for set %s"), 2960Sstevel@tonic-gate sp->setname); 2970Sstevel@tonic-gate return (-1); 2980Sstevel@tonic-gate } else if (meta_get_sp_names(sp, &devnlp, 0, ep) < 0) { 2990Sstevel@tonic-gate mde_perror(ep, gettext( 3000Sstevel@tonic-gate "Could not get soft partitions for set %s"), sp->setname); 3010Sstevel@tonic-gate return (-1); 3020Sstevel@tonic-gate } 3030Sstevel@tonic-gate 3040Sstevel@tonic-gate /* If resetting the owner, get the known membership list */ 3050Sstevel@tonic-gate if (mode & RESET_OWNER) { 3060Sstevel@tonic-gate if (meta_read_nodelist(&cnt, &nl, ep)) { 3070Sstevel@tonic-gate mde_perror(ep, "Could not get nodelist"); 3080Sstevel@tonic-gate return (-1); 3090Sstevel@tonic-gate } 3100Sstevel@tonic-gate } 3110Sstevel@tonic-gate 3120Sstevel@tonic-gate /* for each metadevice */ 3130Sstevel@tonic-gate for (p = devnlp; (p != NULL); p = p->next) { 3140Sstevel@tonic-gate devnp = p->namep; 3150Sstevel@tonic-gate 3160Sstevel@tonic-gate /* 3170Sstevel@tonic-gate * Get the current setting for mirror ABR state and all of the 3180Sstevel@tonic-gate * submirror state and flags from the master node. We only 3190Sstevel@tonic-gate * perform this when going through a 'start' cycle. 3200Sstevel@tonic-gate */ 3210Sstevel@tonic-gate if ((mode & GET_MIRROR_STATE) && mirror_dev) { 3220Sstevel@tonic-gate char *miscname; 3230Sstevel@tonic-gate 3240Sstevel@tonic-gate /* 3250Sstevel@tonic-gate * Ensure that we ignore soft-parts that are returned 3260Sstevel@tonic-gate * from the meta_get_mirror_names() call 3270Sstevel@tonic-gate */ 3280Sstevel@tonic-gate if ((miscname = metagetmiscname(devnp, ep)) == NULL) 3290Sstevel@tonic-gate goto out; 3300Sstevel@tonic-gate if (strcmp(miscname, MD_MIRROR) != 0) 3310Sstevel@tonic-gate continue; 3320Sstevel@tonic-gate 3330Sstevel@tonic-gate mir_state->mnum = meta_getminor(devnp->dev); 3340Sstevel@tonic-gate MD_SETDRIVERNAME(mir_state, MD_MIRROR, sp->setno); 3350Sstevel@tonic-gate meta_mc_log(MC_LOG4, gettext("Getting mirror state" 3361623Stw21770 " for %s: %s"), get_mdname(sp, mir_state->mnum), 3370Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 3380Sstevel@tonic-gate 3390Sstevel@tonic-gate if (metaioctl(MD_MN_GET_MIRROR_STATE, mir_state, ep, 3400Sstevel@tonic-gate "MD_MN_GET_MIRROR_STATE") != 0) { 3410Sstevel@tonic-gate mde_perror(ep, gettext("Unable to get " 3421623Stw21770 "mirror state for %s"), 3431623Stw21770 get_mdname(sp, mir_state->mnum)); 3440Sstevel@tonic-gate goto out; 3450Sstevel@tonic-gate } else { 3460Sstevel@tonic-gate continue; 3470Sstevel@tonic-gate } 3480Sstevel@tonic-gate } 3490Sstevel@tonic-gate 3500Sstevel@tonic-gate /* check if this is a top level metadevice */ 3510Sstevel@tonic-gate if ((mm = meta_get_mdunit(sp, devnp, ep)) == NULL) 3520Sstevel@tonic-gate goto out; 3530Sstevel@tonic-gate if (MD_HAS_PARENT(MD_PARENT(mm))) { 3540Sstevel@tonic-gate has_parent = 1; 3550Sstevel@tonic-gate } else { 3560Sstevel@tonic-gate has_parent = 0; 3570Sstevel@tonic-gate } 3580Sstevel@tonic-gate Free(mm); 3590Sstevel@tonic-gate 3600Sstevel@tonic-gate if (mode & (RESET_OWNER | CHOOSE_OWNER)) { 3610Sstevel@tonic-gate char *miscname; 3620Sstevel@tonic-gate 3630Sstevel@tonic-gate /* 3640Sstevel@tonic-gate * we can only do these for mirrors so make sure we 3650Sstevel@tonic-gate * really have a mirror device and not a softpartition 3660Sstevel@tonic-gate * imitating one. meta_get_mirror_names seems to think 3670Sstevel@tonic-gate * softparts on top of a mirror are mirrors! 3680Sstevel@tonic-gate */ 3690Sstevel@tonic-gate if ((miscname = metagetmiscname(devnp, ep)) == NULL) 3700Sstevel@tonic-gate goto out; 3710Sstevel@tonic-gate if (strcmp(miscname, MD_MIRROR) != 0) 3720Sstevel@tonic-gate continue; 3730Sstevel@tonic-gate 3740Sstevel@tonic-gate (void) memset(ownpar, 0, sizeof (*ownpar)); 3750Sstevel@tonic-gate ownpar->d.mnum = meta_getminor(devnp->dev); 3760Sstevel@tonic-gate MD_SETDRIVERNAME(ownpar, MD_MIRROR, sp->setno); 3770Sstevel@tonic-gate 3780Sstevel@tonic-gate meta_mc_log(MC_LOG4, gettext("Setting owner " 3791623Stw21770 "for %s: %s"), get_mdname(sp, ownpar->d.mnum), 3800Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 3810Sstevel@tonic-gate 3820Sstevel@tonic-gate /* get the current owner id */ 3830Sstevel@tonic-gate if (metaioctl(MD_MN_GET_MM_OWNER, ownpar, ep, 3840Sstevel@tonic-gate "MD_MN_GET_MM_OWNER") != 0) { 3850Sstevel@tonic-gate mde_perror(ep, gettext("Unable to get " 3861623Stw21770 "mirror owner for %s"), 3871623Stw21770 get_mdname(sp, ownpar->d.mnum)); 3880Sstevel@tonic-gate goto out; 3890Sstevel@tonic-gate } 3900Sstevel@tonic-gate } 3910Sstevel@tonic-gate 3920Sstevel@tonic-gate if (mode & RESET_OWNER) { 3930Sstevel@tonic-gate if (ownpar->d.owner == MD_MN_MIRROR_UNOWNED) { 3940Sstevel@tonic-gate mdclrerror(ep); 3950Sstevel@tonic-gate continue; 3960Sstevel@tonic-gate } 3970Sstevel@tonic-gate 3980Sstevel@tonic-gate /* 3990Sstevel@tonic-gate * reset owner only if the current owner is 4000Sstevel@tonic-gate * not in the membership list 4010Sstevel@tonic-gate * Also kill the resync thread so that when the resync 4020Sstevel@tonic-gate * is started, it will perform an optimized resync 4030Sstevel@tonic-gate * for any resync regions that were dirty when the 4040Sstevel@tonic-gate * current owner left the membership. 4050Sstevel@tonic-gate */ 4060Sstevel@tonic-gate if (meta_is_member(NULL, ownpar->d.owner, nl) != 1) { 4070Sstevel@tonic-gate if (meta_mn_change_owner(&ownpar, 4080Sstevel@tonic-gate sp->setno, ownpar->d.mnum, 4090Sstevel@tonic-gate MD_MN_MIRROR_UNOWNED, 4100Sstevel@tonic-gate MD_MN_MM_ALLOW_CHANGE) == -1) { 4110Sstevel@tonic-gate md_eprintf(gettext( 4120Sstevel@tonic-gate "Unable to reset mirror owner " 4131623Stw21770 "for %s\n"), 4141623Stw21770 get_mdname(sp, ownpar->d.mnum)); 4150Sstevel@tonic-gate goto out; 4160Sstevel@tonic-gate } 4170Sstevel@tonic-gate if (meta_mirror_resync(sp, devnp, 0, ep, 4180Sstevel@tonic-gate MD_RESYNC_KILL_NO_WAIT) != 0) { 4190Sstevel@tonic-gate md_eprintf(gettext( 4200Sstevel@tonic-gate "Unable to kill resync for" 4211623Stw21770 " %s\n"), 4221623Stw21770 get_mdname(sp, ownpar->d.mnum)); 4230Sstevel@tonic-gate goto out; 4240Sstevel@tonic-gate } 4250Sstevel@tonic-gate } 4260Sstevel@tonic-gate } 4270Sstevel@tonic-gate 4280Sstevel@tonic-gate if (mode & CHOOSE_OWNER) { 4290Sstevel@tonic-gate /* 4300Sstevel@tonic-gate * only orphaned resyncs will have no owner. 4310Sstevel@tonic-gate * if that is the case choose a new owner. Otherwise 4320Sstevel@tonic-gate * re-establish the existing owner. This covers the 4330Sstevel@tonic-gate * case where a node that owned the mirror 4340Sstevel@tonic-gate * reboots/panics and comes back into the cluster before 4350Sstevel@tonic-gate * the reconfig cycle has completed. In this case the 4360Sstevel@tonic-gate * other cluster nodes will have the mirror owner marked 4370Sstevel@tonic-gate * as the rebooted node while it has the owner marked 4380Sstevel@tonic-gate * as 'None'. We have to reestablish the ownership so 4390Sstevel@tonic-gate * that the subsequent resync can continue. 4400Sstevel@tonic-gate */ 4410Sstevel@tonic-gate if (meta_mn_change_owner(&ownpar, sp->setno, 4420Sstevel@tonic-gate ownpar->d.mnum, ownpar->d.owner, 4430Sstevel@tonic-gate MD_MN_MM_CHOOSE_OWNER) == -1) { 4440Sstevel@tonic-gate md_eprintf(gettext("Unable to choose " 4451623Stw21770 "mirror owner for %s\n"), 4461623Stw21770 get_mdname(sp, ownpar->d.mnum)); 4470Sstevel@tonic-gate goto out; 4480Sstevel@tonic-gate } 4490Sstevel@tonic-gate } 4500Sstevel@tonic-gate 4510Sstevel@tonic-gate /* 4520Sstevel@tonic-gate * For RESET_ABR and UPDATE_ABR - only handle top 4530Sstevel@tonic-gate * level metadevices. 4540Sstevel@tonic-gate */ 4550Sstevel@tonic-gate if (has_parent) 4560Sstevel@tonic-gate continue; 4570Sstevel@tonic-gate 4580Sstevel@tonic-gate if (mode & RESET_ABR) { 4590Sstevel@tonic-gate /* 4600Sstevel@tonic-gate * Reset the ABR (application based recovery) 4610Sstevel@tonic-gate * value on all nodes. We are dealing with 4620Sstevel@tonic-gate * the possibility that we have ABR set but the 4630Sstevel@tonic-gate * only node that had the device open with ABR has 4640Sstevel@tonic-gate * left the cluster. We simply open and close the 4650Sstevel@tonic-gate * device and if this is the last close in the 4660Sstevel@tonic-gate * cluster, ABR will be cleared on all nodes. 4670Sstevel@tonic-gate */ 4680Sstevel@tonic-gate char *miscname; 4691623Stw21770 char name[MAXPATHLEN]; 4700Sstevel@tonic-gate int mnum, fd; 4710Sstevel@tonic-gate 4720Sstevel@tonic-gate name[0] = '\0'; 4730Sstevel@tonic-gate mnum = meta_getminor(devnp->dev); 4740Sstevel@tonic-gate 4750Sstevel@tonic-gate /* 4760Sstevel@tonic-gate * Ensure that we don't include soft-parts in the 4770Sstevel@tonic-gate * mirror-only call to RESET_ABR. meta_get_mirror_names 4780Sstevel@tonic-gate * returns a bogus list that includes all soft-parts 4790Sstevel@tonic-gate * built on mirrors. 4800Sstevel@tonic-gate */ 4810Sstevel@tonic-gate if ((miscname = metagetmiscname(devnp, ep)) == NULL) 4820Sstevel@tonic-gate goto out; 4830Sstevel@tonic-gate if (mirror_dev && (strcmp(miscname, MD_MIRROR) != 0)) 4840Sstevel@tonic-gate continue; 4850Sstevel@tonic-gate 4860Sstevel@tonic-gate meta_mc_log(MC_LOG4, gettext("Re-setting ABR state " 4871623Stw21770 "for %s: %s"), get_mdname(sp, mnum), 4880Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 4890Sstevel@tonic-gate 4900Sstevel@tonic-gate /* compose the absolute device path and open it */ 4910Sstevel@tonic-gate if (compose_path(sp, mnum, &name[0], 4920Sstevel@tonic-gate sizeof (name)) != 0) 4930Sstevel@tonic-gate goto out; 4940Sstevel@tonic-gate if ((fd = open(name, O_RDWR, 0)) < 0) { 4950Sstevel@tonic-gate md_perror(gettext("Could not open device %s"), 4960Sstevel@tonic-gate name); 4970Sstevel@tonic-gate continue; 4980Sstevel@tonic-gate } 4990Sstevel@tonic-gate 5000Sstevel@tonic-gate (void) close(fd); 5010Sstevel@tonic-gate } 5020Sstevel@tonic-gate 5030Sstevel@tonic-gate if (mode & UPDATE_ABR) { 5040Sstevel@tonic-gate /* 5050Sstevel@tonic-gate * Update the ABR value on this node. We obtain the 5060Sstevel@tonic-gate * current ABR state from the master node. 5070Sstevel@tonic-gate */ 5080Sstevel@tonic-gate 5090Sstevel@tonic-gate char *miscname; 5101623Stw21770 char name[MAXPATHLEN]; 5110Sstevel@tonic-gate int mnum, fd; 5120Sstevel@tonic-gate volcap_t vc; 5130Sstevel@tonic-gate uint_t tstate; 5140Sstevel@tonic-gate 5150Sstevel@tonic-gate name[0] = '\0'; 5160Sstevel@tonic-gate mnum = meta_getminor(devnp->dev); 5170Sstevel@tonic-gate 5180Sstevel@tonic-gate /* 5190Sstevel@tonic-gate * Ensure that we don't include soft-parts in the 5200Sstevel@tonic-gate * mirror-only call to UPDATE_ABR. meta_get_mirror_names 5210Sstevel@tonic-gate * returns a bogus list that includes all soft-parts 5220Sstevel@tonic-gate * built on mirrors. 5230Sstevel@tonic-gate */ 5240Sstevel@tonic-gate if ((miscname = metagetmiscname(devnp, ep)) == NULL) 5250Sstevel@tonic-gate goto out; 5260Sstevel@tonic-gate if (mirror_dev && (strcmp(miscname, MD_MIRROR) != 0)) 5270Sstevel@tonic-gate continue; 5280Sstevel@tonic-gate 5290Sstevel@tonic-gate /* Get tstate from Master */ 5300Sstevel@tonic-gate if (meta_mn_send_get_tstate(devnp->dev, &tstate, ep) 5310Sstevel@tonic-gate != 0) 5320Sstevel@tonic-gate continue; 5330Sstevel@tonic-gate /* If not set on the master, nothing to do */ 5340Sstevel@tonic-gate if (!(tstate & MD_ABR_CAP)) 5350Sstevel@tonic-gate continue; 5360Sstevel@tonic-gate 5370Sstevel@tonic-gate meta_mc_log(MC_LOG4, gettext("Updating ABR state " 5381623Stw21770 "for %s: %s"), get_mdname(sp, mnum), 5390Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 5400Sstevel@tonic-gate 5410Sstevel@tonic-gate /* compose the absolute device path and open it */ 5420Sstevel@tonic-gate if (compose_path(sp, mnum, &name[0], 5430Sstevel@tonic-gate sizeof (name)) != 0) 5440Sstevel@tonic-gate goto out; 5450Sstevel@tonic-gate if ((fd = open(name, O_RDWR, 0)) < 0) { 5460Sstevel@tonic-gate md_perror(gettext("Could not open device %s"), 5470Sstevel@tonic-gate name); 5480Sstevel@tonic-gate continue; 5490Sstevel@tonic-gate } 5500Sstevel@tonic-gate 5510Sstevel@tonic-gate /* set ABR state */ 5520Sstevel@tonic-gate vc.vc_info = 0; 5530Sstevel@tonic-gate vc.vc_set = 0; 5540Sstevel@tonic-gate if (ioctl(fd, DKIOCGETVOLCAP, &vc) < 0) { 5550Sstevel@tonic-gate /* 5560Sstevel@tonic-gate * Ignore if device does not support this 5570Sstevel@tonic-gate * ioctl 5580Sstevel@tonic-gate */ 5590Sstevel@tonic-gate if ((errno != ENOTTY) && (errno != ENOTSUP)) { 5600Sstevel@tonic-gate md_perror(gettext("Could not get " 5610Sstevel@tonic-gate "ABR/DMR state for device %s"), 5620Sstevel@tonic-gate name); 5630Sstevel@tonic-gate } 5640Sstevel@tonic-gate (void) close(fd); 5650Sstevel@tonic-gate continue; 5660Sstevel@tonic-gate } 5670Sstevel@tonic-gate if (!(vc.vc_info & (DKV_ABR_CAP | DKV_DMR_CAP))) { 5680Sstevel@tonic-gate (void) close(fd); 5690Sstevel@tonic-gate continue; 5700Sstevel@tonic-gate } 5710Sstevel@tonic-gate 5720Sstevel@tonic-gate vc.vc_set = DKV_ABR_CAP; 5730Sstevel@tonic-gate if (ioctl(fd, DKIOCSETVOLCAP, &vc) < 0) { 5740Sstevel@tonic-gate md_perror(gettext( 5750Sstevel@tonic-gate "Could not set ABR state for " 5760Sstevel@tonic-gate "device %s"), name); 5770Sstevel@tonic-gate (void) close(fd); 5780Sstevel@tonic-gate goto out; 5790Sstevel@tonic-gate } else { 5800Sstevel@tonic-gate md_eprintf(gettext( 5810Sstevel@tonic-gate "Setting ABR state on device %s\n"), name); 5820Sstevel@tonic-gate } 5830Sstevel@tonic-gate 5840Sstevel@tonic-gate (void) close(fd); 5850Sstevel@tonic-gate } 5860Sstevel@tonic-gate } 5870Sstevel@tonic-gate 5880Sstevel@tonic-gate /* cleanup */ 5890Sstevel@tonic-gate if (mode & RESET_OWNER) { 5900Sstevel@tonic-gate meta_free_nodelist(nl); 5910Sstevel@tonic-gate } 5920Sstevel@tonic-gate metafreenamelist(devnlp); 5930Sstevel@tonic-gate return (0); 5940Sstevel@tonic-gate 5950Sstevel@tonic-gate out: 5960Sstevel@tonic-gate /* cleanup */ 5970Sstevel@tonic-gate if (mode & RESET_OWNER) { 5980Sstevel@tonic-gate meta_free_nodelist(nl); 5990Sstevel@tonic-gate } 6000Sstevel@tonic-gate metafreenamelist(devnlp); 6010Sstevel@tonic-gate return (-1); 6020Sstevel@tonic-gate } 6030Sstevel@tonic-gate 6040Sstevel@tonic-gate /* 6050Sstevel@tonic-gate * Print usage message 6060Sstevel@tonic-gate */ 6070Sstevel@tonic-gate static void 6080Sstevel@tonic-gate usage(mdsetname_t *sp, int eval) 6090Sstevel@tonic-gate { 6100Sstevel@tonic-gate (void) fprintf(stderr, gettext("usage:" 6110Sstevel@tonic-gate "\t%s [-V version] [-t timeout] [-d level] start localnodeid\n" 6120Sstevel@tonic-gate "\t%s [-V version] [-t timeout] [-d level] step nodelist...\n" 6130Sstevel@tonic-gate "\t%s [-V version] [-t timeout] [-d level] abort | stop\n" 6140Sstevel@tonic-gate "\t%s [-V | -? | -h]\n"), 6150Sstevel@tonic-gate myname, myname, myname, myname); 6160Sstevel@tonic-gate if (!eval) { 6170Sstevel@tonic-gate fprintf(stderr, gettext("\n" 6180Sstevel@tonic-gate "\tValid debug (-d) levels are 1-%d for increasing " 6190Sstevel@tonic-gate "verbosity.\n\tDefault is -d 3.\n\n" 6200Sstevel@tonic-gate "\tValid step values are: return | step1 | step2 | " 6210Sstevel@tonic-gate "step3 | step4\n\n" 6220Sstevel@tonic-gate "\tNodelist is a space-separated list of node id's\n\n"), 6230Sstevel@tonic-gate MAX_DEBUG_LEVEL); 6240Sstevel@tonic-gate } 6250Sstevel@tonic-gate md_exit(sp, eval); 6260Sstevel@tonic-gate } 6270Sstevel@tonic-gate 6280Sstevel@tonic-gate /* 6290Sstevel@tonic-gate * Input: Input takes a config step name followed by a list of 6300Sstevel@tonic-gate * possible node id's. 6310Sstevel@tonic-gate * 6320Sstevel@tonic-gate * Returns: 0 - Success 6330Sstevel@tonic-gate * 1 - Fail 6340Sstevel@tonic-gate * Node will be removed from cluster membership 6350Sstevel@tonic-gate * by forcing node to panic. 6360Sstevel@tonic-gate * 205 - Unsuccessful. Start another reconfig cycle. 6370Sstevel@tonic-gate * Problem was encountered that could be fixed by 6380Sstevel@tonic-gate * running another reconfig cycle. 6390Sstevel@tonic-gate * Problem could be a result of a failure to read 6400Sstevel@tonic-gate * the nodelist file or that all work could not be 6410Sstevel@tonic-gate * accomplished in a reconfig step in the amount of 6420Sstevel@tonic-gate * time given so another reconfig cycle is needed in 6430Sstevel@tonic-gate * order to finish the current step. 6440Sstevel@tonic-gate */ 6450Sstevel@tonic-gate int 6460Sstevel@tonic-gate main(int argc, char **argv) 6470Sstevel@tonic-gate { 6480Sstevel@tonic-gate mdsetname_t *sp = NULL; 6490Sstevel@tonic-gate md_error_t status = mdnullerror; 6500Sstevel@tonic-gate md_error_t *ep = &status; 6510Sstevel@tonic-gate set_t max_sets, setno; 6520Sstevel@tonic-gate int c, clust = 0; 6530Sstevel@tonic-gate struct sigaction nsa, osa; 6540Sstevel@tonic-gate struct step_t *step_ptr; 6550Sstevel@tonic-gate mdsetname_t *local_sp = NULL; 6560Sstevel@tonic-gate md_drive_desc *dd; 6570Sstevel@tonic-gate int rval = 0; 6580Sstevel@tonic-gate md_set_desc *sd; 6590Sstevel@tonic-gate mddb_block_parm_t mbp; 6600Sstevel@tonic-gate uint_t debug = 3; /* log upto MC_LOG3 by default */ 6610Sstevel@tonic-gate int version_table_size; 6620Sstevel@tonic-gate mddb_setflags_config_t sf; 6630Sstevel@tonic-gate int ret_val; 6640Sstevel@tonic-gate mddb_config_t cfg; 6650Sstevel@tonic-gate int set_info[MD_MAXSETS]; 666*3073Sjkennedy long commd_timeout = 0; 6670Sstevel@tonic-gate 6680Sstevel@tonic-gate /* 6690Sstevel@tonic-gate * Get the locale set up before calling any other routines 6700Sstevel@tonic-gate * with messages to ouput. Just in case we're not in a build 6710Sstevel@tonic-gate * environment, make sure that TEXT_DOMAIN gets set to 6720Sstevel@tonic-gate * something. 6730Sstevel@tonic-gate */ 6740Sstevel@tonic-gate #if !defined(TEXT_DOMAIN) 6750Sstevel@tonic-gate #define TEXT_DOMAIN "SYS_TEST" 6760Sstevel@tonic-gate #endif 6770Sstevel@tonic-gate (void) setlocale(LC_ALL, ""); 6780Sstevel@tonic-gate (void) textdomain(TEXT_DOMAIN); 6790Sstevel@tonic-gate 6800Sstevel@tonic-gate if ((clust = sdssc_bind_library()) == SDSSC_ERROR) { 6810Sstevel@tonic-gate md_eprintf(gettext("Interface error with libsds_sc.so\n")); 6820Sstevel@tonic-gate exit(1); 6830Sstevel@tonic-gate } 6840Sstevel@tonic-gate 6850Sstevel@tonic-gate if (md_init(argc, argv, 1, 1, ep) != 0 || meta_check_root(ep) != 0) { 6860Sstevel@tonic-gate mde_perror(ep, ""); 6870Sstevel@tonic-gate md_exit(sp, 1); 6880Sstevel@tonic-gate } 6890Sstevel@tonic-gate 6900Sstevel@tonic-gate /* 6910Sstevel@tonic-gate * open log and enable libmeta logging. Do it here explicitly 6920Sstevel@tonic-gate * rather than letting md_init() do it because we are not really 6930Sstevel@tonic-gate * a daemon and that is what md_init() opens the log as. 6940Sstevel@tonic-gate */ 6950Sstevel@tonic-gate openlog("metaclust", LOG_CONS, LOG_USER); 6960Sstevel@tonic-gate 6970Sstevel@tonic-gate version_table_size = sizeof (version_table) / sizeof (version_table[0]); 6980Sstevel@tonic-gate 6990Sstevel@tonic-gate optind = 1; 7000Sstevel@tonic-gate opterr = 0; 7010Sstevel@tonic-gate while ((c = getopt(argc, argv, "hd:V:t:?")) != -1) { 7020Sstevel@tonic-gate switch (c) { 7030Sstevel@tonic-gate case 'h': 7040Sstevel@tonic-gate usage(sp, 0); 7050Sstevel@tonic-gate break; 7060Sstevel@tonic-gate 7070Sstevel@tonic-gate case 'd': 7080Sstevel@tonic-gate if (sscanf(optarg, "%u", &debug) != 1) { 7090Sstevel@tonic-gate md_eprintf(gettext("Invalid debug level\n")); 7100Sstevel@tonic-gate md_exit(sp, 1); 7110Sstevel@tonic-gate } else if ((debug < 1) || (debug > MAX_DEBUG_LEVEL)) { 7120Sstevel@tonic-gate debug = min(max(debug, 1), MAX_DEBUG_LEVEL); 7130Sstevel@tonic-gate md_eprintf(gettext("Debug level must be " 7140Sstevel@tonic-gate "between 1 and %d inclusive.\n"), 7150Sstevel@tonic-gate MAX_DEBUG_LEVEL); 7160Sstevel@tonic-gate md_eprintf(gettext("Debug level set to %d.\n"), 7170Sstevel@tonic-gate debug); 7180Sstevel@tonic-gate } 7190Sstevel@tonic-gate break; 7200Sstevel@tonic-gate 7210Sstevel@tonic-gate case 'V': 7220Sstevel@tonic-gate version = Strdup(optarg); 7230Sstevel@tonic-gate break; 7240Sstevel@tonic-gate 7250Sstevel@tonic-gate case 't': 7260Sstevel@tonic-gate if (sscanf(optarg, "%u", &timeout) != 1) { 7270Sstevel@tonic-gate md_eprintf(gettext("Invalid timeout value\n")); 7280Sstevel@tonic-gate md_exit(sp, 1); 7290Sstevel@tonic-gate } 7300Sstevel@tonic-gate break; 7310Sstevel@tonic-gate 7320Sstevel@tonic-gate case '?': 7330Sstevel@tonic-gate if (optopt == '?') { 7340Sstevel@tonic-gate usage(sp, 0); 7350Sstevel@tonic-gate } else if (optopt == 'V') { 7360Sstevel@tonic-gate int i; 7370Sstevel@tonic-gate 7380Sstevel@tonic-gate fprintf(stdout, gettext( 7390Sstevel@tonic-gate "%s: Versions Supported:"), myname); 7400Sstevel@tonic-gate for (i = 0; i < version_table_size; i++) { 7410Sstevel@tonic-gate fprintf(stdout, " %s", 7420Sstevel@tonic-gate version_table[i]); 7430Sstevel@tonic-gate } 7440Sstevel@tonic-gate fprintf(stdout, "\n"); 7450Sstevel@tonic-gate md_exit(sp, 0); 7460Sstevel@tonic-gate } 7470Sstevel@tonic-gate /*FALLTHROUGH*/ 7480Sstevel@tonic-gate 7490Sstevel@tonic-gate default: 7500Sstevel@tonic-gate usage(sp, 1); 7510Sstevel@tonic-gate break; 7520Sstevel@tonic-gate } 7530Sstevel@tonic-gate } 7540Sstevel@tonic-gate 7550Sstevel@tonic-gate /* initialise the debug level and start time */ 7560Sstevel@tonic-gate setup_mc_log(debug); 7570Sstevel@tonic-gate 7580Sstevel@tonic-gate /* 7590Sstevel@tonic-gate * check that the version specified (if any) is supported. 7600Sstevel@tonic-gate */ 7610Sstevel@tonic-gate if (version != NULL) { 7620Sstevel@tonic-gate int i, found = 0; 7630Sstevel@tonic-gate 7640Sstevel@tonic-gate for (i = 0; i < version_table_size; i++) { 7650Sstevel@tonic-gate if (strcmp(version, version_table[i]) == 0) { 7660Sstevel@tonic-gate found = 1; 7670Sstevel@tonic-gate break; 7680Sstevel@tonic-gate } 7690Sstevel@tonic-gate } 7700Sstevel@tonic-gate if (!found) { 7710Sstevel@tonic-gate md_eprintf(gettext("Version %s not supported\n"), 7720Sstevel@tonic-gate version); 7730Sstevel@tonic-gate md_exit(sp, 1); 7740Sstevel@tonic-gate } 7750Sstevel@tonic-gate } 7760Sstevel@tonic-gate 7770Sstevel@tonic-gate argc -= optind; 7780Sstevel@tonic-gate argv += optind; 7790Sstevel@tonic-gate 7800Sstevel@tonic-gate /* parse arguments */ 7810Sstevel@tonic-gate if (argc <= 0) { 7820Sstevel@tonic-gate usage(sp, 1); 7830Sstevel@tonic-gate } 7840Sstevel@tonic-gate 7850Sstevel@tonic-gate /* convert the step name to the corresponding number */ 7860Sstevel@tonic-gate step_ptr = bsearch(argv[0], step_table, (sizeof (step_table) / 7870Sstevel@tonic-gate sizeof (step_table[0])), sizeof (step_table[0]), mc_compare); 7880Sstevel@tonic-gate if (step_ptr != NULL) { 7890Sstevel@tonic-gate stepnum = step_ptr->step_num; 7900Sstevel@tonic-gate } 7910Sstevel@tonic-gate 7920Sstevel@tonic-gate --argc; 7930Sstevel@tonic-gate ++argv; 7940Sstevel@tonic-gate 7950Sstevel@tonic-gate /* set timeout alarm signal, a value of 0 will disable timeout */ 7960Sstevel@tonic-gate if (timeout > 0) { 7970Sstevel@tonic-gate int stat_loc = 0; 798*3073Sjkennedy commd_timeout = timeout * .75; 7990Sstevel@tonic-gate 8000Sstevel@tonic-gate c_pid = fork(); 8010Sstevel@tonic-gate 8020Sstevel@tonic-gate if (c_pid == (pid_t)-1) { 8030Sstevel@tonic-gate md_perror(gettext("Unable to fork")); 8040Sstevel@tonic-gate md_exit(sp, 1); 8050Sstevel@tonic-gate } else if (c_pid) { 8060Sstevel@tonic-gate /* parent */ 8070Sstevel@tonic-gate nsa.sa_flags = 0; 8080Sstevel@tonic-gate if (sigfillset(&nsa.sa_mask) < 0) { 8090Sstevel@tonic-gate md_perror(gettext("Unable to set signal mask")); 8100Sstevel@tonic-gate md_exit(sp, 1); 8110Sstevel@tonic-gate } 8120Sstevel@tonic-gate 8130Sstevel@tonic-gate nsa.sa_handler = sigalarmhandler; 8140Sstevel@tonic-gate if (sigaction(SIGALRM, &nsa, &osa) == -1) { 8150Sstevel@tonic-gate md_perror(gettext("Unable to set alarm " 8160Sstevel@tonic-gate "handler")); 8170Sstevel@tonic-gate md_exit(sp, 1); 8180Sstevel@tonic-gate } 8190Sstevel@tonic-gate 8200Sstevel@tonic-gate (void) alarm(timeout); 8210Sstevel@tonic-gate 8220Sstevel@tonic-gate /* 8230Sstevel@tonic-gate * wait for child to exit or timeout to expire. 8240Sstevel@tonic-gate * keep retrying if the call is interrupted 8250Sstevel@tonic-gate */ 8260Sstevel@tonic-gate while ((ret_val = waitpid(c_pid, &stat_loc, 0)) < 0) { 8270Sstevel@tonic-gate if (errno != EINTR) { 8280Sstevel@tonic-gate break; 8290Sstevel@tonic-gate } 8300Sstevel@tonic-gate } 8310Sstevel@tonic-gate if (ret_val == c_pid) { 8320Sstevel@tonic-gate /* exit with the childs exit value */ 8330Sstevel@tonic-gate exit(WEXITSTATUS(stat_loc)); 8340Sstevel@tonic-gate } else if (errno == ECHILD) { 8350Sstevel@tonic-gate md_exit(sp, 0); 8360Sstevel@tonic-gate } else { 8370Sstevel@tonic-gate perror(myname); 8380Sstevel@tonic-gate md_exit(sp, 1); 8390Sstevel@tonic-gate } 8400Sstevel@tonic-gate } 8410Sstevel@tonic-gate } 8420Sstevel@tonic-gate 8430Sstevel@tonic-gate /* 8440Sstevel@tonic-gate * If a timeout value is given, everything from this point onwards is 8450Sstevel@tonic-gate * executed in the child process. 8460Sstevel@tonic-gate */ 8470Sstevel@tonic-gate 8480Sstevel@tonic-gate switch (stepnum) { 8490Sstevel@tonic-gate case MC_START: 8500Sstevel@tonic-gate /* 8510Sstevel@tonic-gate * Start Step 8520Sstevel@tonic-gate * 8530Sstevel@tonic-gate * - Suspend all rpc.mdcommd messages 8540Sstevel@tonic-gate */ 8550Sstevel@tonic-gate 8560Sstevel@tonic-gate /* expect the local node id to be given only */ 8570Sstevel@tonic-gate if (argc != 1) 8580Sstevel@tonic-gate usage(sp, 1); 8590Sstevel@tonic-gate 8600Sstevel@tonic-gate meta_mc_log(MC_LOG2, gettext("Starting Start step: %s"), 8610Sstevel@tonic-gate meta_print_hrtime(0)); 8620Sstevel@tonic-gate 8630Sstevel@tonic-gate /* 8640Sstevel@tonic-gate * Does local set exist? If not, exit with 0 8650Sstevel@tonic-gate * since there's no reason to have this node panic if 8660Sstevel@tonic-gate * the local set cannot be started. 8670Sstevel@tonic-gate */ 8680Sstevel@tonic-gate if ((local_sp = load_local_set(ep)) == NULL) { 8690Sstevel@tonic-gate md_exit(local_sp, 0); 8700Sstevel@tonic-gate } 8710Sstevel@tonic-gate 8720Sstevel@tonic-gate if ((max_sets = get_max_sets(ep)) == 0) { 8730Sstevel@tonic-gate mde_perror(ep, ""); 8740Sstevel@tonic-gate md_exit(sp, 1); 8750Sstevel@tonic-gate } 8760Sstevel@tonic-gate 8770Sstevel@tonic-gate /* start walking through all possible disksets */ 8780Sstevel@tonic-gate for (setno = 1; setno < max_sets; setno++) { 8790Sstevel@tonic-gate if ((sp = metasetnosetname(setno, ep)) == NULL) { 8800Sstevel@tonic-gate if (mdiserror(ep, MDE_NO_SET)) { 8810Sstevel@tonic-gate /* No set for this setno - continue */ 8820Sstevel@tonic-gate mdclrerror(ep); 8830Sstevel@tonic-gate continue; 8840Sstevel@tonic-gate } else { 8850Sstevel@tonic-gate mde_perror(ep, gettext("Unable to " 8860Sstevel@tonic-gate "get set %d information"), setno); 8870Sstevel@tonic-gate md_exit(sp, 1); 8880Sstevel@tonic-gate } 8890Sstevel@tonic-gate } 8900Sstevel@tonic-gate 8910Sstevel@tonic-gate /* only check multi-node disksets */ 8920Sstevel@tonic-gate if (!meta_is_mn_set(sp, ep)) { 8930Sstevel@tonic-gate mdclrerror(ep); 8940Sstevel@tonic-gate continue; 8950Sstevel@tonic-gate } 8960Sstevel@tonic-gate 8970Sstevel@tonic-gate meta_mc_log(MC_LOG3, gettext("Start - block parse " 8980Sstevel@tonic-gate "messages for set %s: %s"), sp->setname, 8990Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 9000Sstevel@tonic-gate 9010Sstevel@tonic-gate /* 9020Sstevel@tonic-gate * Mddb parse messages are sent amongst the nodes 9030Sstevel@tonic-gate * in a diskset whenever the locator block or 9040Sstevel@tonic-gate * locator names structure has been changed. 9050Sstevel@tonic-gate * A locator block change could occur as a result 9060Sstevel@tonic-gate * of a disk failure during the reconfig cycle, 9070Sstevel@tonic-gate * so block the mddb parse messages while the 9080Sstevel@tonic-gate * rpc.mdcommd is suspended during the reconfig cycle. 9090Sstevel@tonic-gate */ 9100Sstevel@tonic-gate if (s_ownset(sp->setno, ep) == MD_SETOWNER_YES) { 9110Sstevel@tonic-gate (void) memset(&mbp, 0, sizeof (mbp)); 9120Sstevel@tonic-gate mbp.c_setno = setno; 9130Sstevel@tonic-gate mbp.c_blk_flags = MDDB_BLOCK_PARSE; 9140Sstevel@tonic-gate if (metaioctl(MD_MN_MDDB_BLOCK, &mbp, 9150Sstevel@tonic-gate &mbp.c_mde, NULL)) { 9160Sstevel@tonic-gate mdstealerror(ep, &mbp.c_mde); 9170Sstevel@tonic-gate mde_perror(ep, gettext("Could not " 9180Sstevel@tonic-gate "block set %s"), sp->setname); 9190Sstevel@tonic-gate md_exit(sp, 1); 9200Sstevel@tonic-gate } 9210Sstevel@tonic-gate } 9220Sstevel@tonic-gate 9230Sstevel@tonic-gate /* suspend commd and spin waiting for drain */ 9240Sstevel@tonic-gate while ((ret_val = mdmn_suspend(setno, 925*3073Sjkennedy MD_COMM_ALL_CLASSES, commd_timeout)) == 9260Sstevel@tonic-gate MDE_DS_COMMDCTL_SUSPEND_NYD) { 9270Sstevel@tonic-gate sleep(1); 9280Sstevel@tonic-gate } 9290Sstevel@tonic-gate 9300Sstevel@tonic-gate if (ret_val) { 9310Sstevel@tonic-gate md_eprintf(gettext("Could not suspend " 9320Sstevel@tonic-gate "rpc.mdcommd for set %s\n"), sp->setname); 9330Sstevel@tonic-gate md_exit(sp, 1); 9340Sstevel@tonic-gate } 9350Sstevel@tonic-gate 9360Sstevel@tonic-gate /* 9370Sstevel@tonic-gate * Set start step flag for set. This is set to indicate 93846Sskamm * that this node entered the reconfig cycle through 93946Sskamm * the start step. This is used during the reconfig 94046Sskamm * cycle to determine whether the node had entered 94146Sskamm * through the start step or the return step. 9420Sstevel@tonic-gate */ 9430Sstevel@tonic-gate (void) memset(&sf, 0, sizeof (sf)); 9440Sstevel@tonic-gate sf.sf_setno = sp->setno; 9450Sstevel@tonic-gate sf.sf_setflags = MD_SET_MN_START_RC; 9460Sstevel@tonic-gate sf.sf_flags = MDDB_NM_SET; 9470Sstevel@tonic-gate /* Use magic to help protect ioctl against attack. */ 9480Sstevel@tonic-gate sf.sf_magic = MDDB_SETFLAGS_MAGIC; 9490Sstevel@tonic-gate if (metaioctl(MD_MN_SET_SETFLAGS, &sf, 9500Sstevel@tonic-gate &sf.sf_mde, NULL)) { 9510Sstevel@tonic-gate mdstealerror(ep, &sf.sf_mde); 9520Sstevel@tonic-gate mde_perror(ep, gettext("Could not set " 9530Sstevel@tonic-gate "start_step flag for set %s"), sp->setname); 9540Sstevel@tonic-gate md_exit(sp, 1); 9550Sstevel@tonic-gate } 9560Sstevel@tonic-gate 9570Sstevel@tonic-gate } 9580Sstevel@tonic-gate 9590Sstevel@tonic-gate meta_mc_log(MC_LOG2, gettext("Start step completed: %s"), 9600Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 9610Sstevel@tonic-gate 9620Sstevel@tonic-gate break; 9630Sstevel@tonic-gate 9640Sstevel@tonic-gate case MC_STOP: 9650Sstevel@tonic-gate /* 9660Sstevel@tonic-gate * Stop Step 9670Sstevel@tonic-gate * 9680Sstevel@tonic-gate * - ??? 9690Sstevel@tonic-gate */ 9700Sstevel@tonic-gate 9710Sstevel@tonic-gate /* don't expect any more arguments to follow the step name */ 9720Sstevel@tonic-gate if (argc != 0) 9730Sstevel@tonic-gate usage(sp, 1); 9740Sstevel@tonic-gate 9750Sstevel@tonic-gate break; 9760Sstevel@tonic-gate 9770Sstevel@tonic-gate case MC_ABORT: 9780Sstevel@tonic-gate /* 9790Sstevel@tonic-gate * Abort Step 9800Sstevel@tonic-gate * 9810Sstevel@tonic-gate * - Abort rpc.mdcommd 9820Sstevel@tonic-gate */ 9830Sstevel@tonic-gate 9840Sstevel@tonic-gate /* don't expect any more arguments to follow the step name */ 9850Sstevel@tonic-gate if (argc != 0) 9860Sstevel@tonic-gate usage(sp, 1); 9870Sstevel@tonic-gate 9880Sstevel@tonic-gate meta_mc_log(MC_LOG2, gettext("Starting Abort step: %s"), 9890Sstevel@tonic-gate meta_print_hrtime(0)); 9900Sstevel@tonic-gate 9910Sstevel@tonic-gate /* 9920Sstevel@tonic-gate * Does local set exist? If not, exit with 0 9930Sstevel@tonic-gate * since there's no reason to have this node panic if 9940Sstevel@tonic-gate * the local set cannot be started. 9950Sstevel@tonic-gate */ 9960Sstevel@tonic-gate if ((local_sp = load_local_set(ep)) == NULL) { 9970Sstevel@tonic-gate md_exit(local_sp, 0); 9980Sstevel@tonic-gate } 9990Sstevel@tonic-gate 10000Sstevel@tonic-gate /* 10010Sstevel@tonic-gate * abort the rpc.mdcommd. The abort is only issued on this node 10020Sstevel@tonic-gate * meaning that the abort reconfig step is called on this 10030Sstevel@tonic-gate * node before a panic while the rest of the cluster will 10040Sstevel@tonic-gate * undergo a reconfig cycle. 10050Sstevel@tonic-gate * There is no time relation between this node running a 10060Sstevel@tonic-gate * reconfig abort and the the rest of the cluster 10070Sstevel@tonic-gate * running a reconfig cycle meaning that this node may 10080Sstevel@tonic-gate * panic before, during or after the cluster has run 10090Sstevel@tonic-gate * a reconfig cycle. 10100Sstevel@tonic-gate */ 10110Sstevel@tonic-gate mdmn_abort(); 10120Sstevel@tonic-gate 10130Sstevel@tonic-gate meta_mc_log(MC_LOG2, gettext("Abort step completed: %s"), 10140Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 10150Sstevel@tonic-gate 10160Sstevel@tonic-gate break; 10170Sstevel@tonic-gate 10180Sstevel@tonic-gate case MC_RETURN: 10190Sstevel@tonic-gate /* 10200Sstevel@tonic-gate * Return Step 10210Sstevel@tonic-gate * 10220Sstevel@tonic-gate * - Grab local set lock, issue rpc.mdcommd DRAIN ALL 10230Sstevel@tonic-gate * and release local set lock. Grabbing the local set 10240Sstevel@tonic-gate * lock allows any active metaset/metadb commands to 10250Sstevel@tonic-gate * terminate gracefully and will keep a metaset/metadb 10260Sstevel@tonic-gate * command from starting until the DRAIN ALL is issued. 10270Sstevel@tonic-gate * The metaset/metadb commands can issue 10280Sstevel@tonic-gate * DRAIN ALL/RESUME ALL commands to rpc.mdcommd, 10290Sstevel@tonic-gate * so the return step must not issue the DRAIN ALL command 10300Sstevel@tonic-gate * until metaset/metadb have finished or metaset may issue 10310Sstevel@tonic-gate * a RESUME ALL after this return reconfig step has issued 10320Sstevel@tonic-gate * the DRAIN ALL command. 10330Sstevel@tonic-gate * After this reconfig step has issued the DRAIN_ALL and 10340Sstevel@tonic-gate * released the local set lock, metaset/metadb will fail 10350Sstevel@tonic-gate * when attempting to contact the rpc.mdcommd and will 10360Sstevel@tonic-gate * terminate without making any configuration changes. 10370Sstevel@tonic-gate * The DRAIN ALL command will keep all other meta* commands 10380Sstevel@tonic-gate * from running during the reconfig cycle (these commands 10390Sstevel@tonic-gate * will wait until the rpc.mdcommd is resumed) since the 10400Sstevel@tonic-gate * reconfig cycle may be changing the diskset configuration. 10410Sstevel@tonic-gate */ 10420Sstevel@tonic-gate 10430Sstevel@tonic-gate /* expect the nodelist to follow the step name */ 10440Sstevel@tonic-gate if (argc < 1) 10450Sstevel@tonic-gate usage(sp, 1); 10460Sstevel@tonic-gate 10470Sstevel@tonic-gate meta_mc_log(MC_LOG2, gettext("Starting Return step: %s"), 10480Sstevel@tonic-gate meta_print_hrtime(0)); 10490Sstevel@tonic-gate 10500Sstevel@tonic-gate /* 10510Sstevel@tonic-gate * Does local set exist? If not, exit with 0 10520Sstevel@tonic-gate * since there's no reason to have this node panic if 10530Sstevel@tonic-gate * the local set cannot be started. 10540Sstevel@tonic-gate */ 10550Sstevel@tonic-gate if ((local_sp = load_local_set(ep)) == NULL) { 10560Sstevel@tonic-gate md_exit(local_sp, 0); 10570Sstevel@tonic-gate } 10580Sstevel@tonic-gate 10590Sstevel@tonic-gate /* 10600Sstevel@tonic-gate * Suspend any mirror resyncs that are in progress. This 10610Sstevel@tonic-gate * stops unnecessary timeouts. 10620Sstevel@tonic-gate */ 10630Sstevel@tonic-gate meta_mirror_resync_block_all(); 10640Sstevel@tonic-gate 10650Sstevel@tonic-gate if (meta_lock(local_sp, TRUE, ep) != 0) { 10660Sstevel@tonic-gate mde_perror(ep, ""); 10670Sstevel@tonic-gate md_exit(local_sp, 1); 10680Sstevel@tonic-gate } 10690Sstevel@tonic-gate 10700Sstevel@tonic-gate /* 10710Sstevel@tonic-gate * All metaset and metadb commands on this node have now 10720Sstevel@tonic-gate * terminated gracefully. Now, issue a drain all to 10730Sstevel@tonic-gate * the rpc.mdcommd. Any meta command issued after the 10740Sstevel@tonic-gate * drain all will either spin sending the command to the 10750Sstevel@tonic-gate * master until after the reconfig cycle has finished OR 10760Sstevel@tonic-gate * will terminate gracefully (metaset/metadb). 10770Sstevel@tonic-gate */ 10780Sstevel@tonic-gate if ((max_sets = get_max_sets(ep)) == 0) { 10790Sstevel@tonic-gate mde_perror(ep, ""); 10800Sstevel@tonic-gate md_exit(sp, 1); 10810Sstevel@tonic-gate } 10820Sstevel@tonic-gate 10830Sstevel@tonic-gate /* start walking through all possible disksets */ 10840Sstevel@tonic-gate for (setno = 1; setno < max_sets; setno++) { 10850Sstevel@tonic-gate if ((sp = metasetnosetname(setno, ep)) == NULL) { 10860Sstevel@tonic-gate if (mdiserror(ep, MDE_NO_SET)) { 10870Sstevel@tonic-gate /* No set for this setno - continue */ 10880Sstevel@tonic-gate mdclrerror(ep); 10890Sstevel@tonic-gate continue; 10900Sstevel@tonic-gate } else { 10910Sstevel@tonic-gate mde_perror(ep, gettext("Unable to " 10920Sstevel@tonic-gate "get set %d information"), setno); 10930Sstevel@tonic-gate md_exit(sp, 1); 10940Sstevel@tonic-gate } 10950Sstevel@tonic-gate } 10960Sstevel@tonic-gate 10970Sstevel@tonic-gate /* only check multi-node disksets */ 10980Sstevel@tonic-gate if (!meta_is_mn_set(sp, ep)) { 10990Sstevel@tonic-gate mdclrerror(ep); 11000Sstevel@tonic-gate continue; 11010Sstevel@tonic-gate } 11020Sstevel@tonic-gate 11030Sstevel@tonic-gate meta_mc_log(MC_LOG3, gettext("Return - block parse " 11040Sstevel@tonic-gate "messages for set %s: %s"), sp->setname, 11050Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 11060Sstevel@tonic-gate 11070Sstevel@tonic-gate /* 11080Sstevel@tonic-gate * Mddb parse messages are sent amongst the nodes 11090Sstevel@tonic-gate * in a diskset whenever the locator block or 11100Sstevel@tonic-gate * locator names structure has been changed. 11110Sstevel@tonic-gate * A locator block change could occur as a result 11120Sstevel@tonic-gate * of a disk failure during the reconfig cycle, 11130Sstevel@tonic-gate * so block the mddb parse messages while the 11140Sstevel@tonic-gate * rpc.commd is suspended during the reconfig cycle. 11150Sstevel@tonic-gate */ 11160Sstevel@tonic-gate if (s_ownset(sp->setno, ep) == MD_SETOWNER_YES) { 11170Sstevel@tonic-gate (void) memset(&mbp, 0, sizeof (mbp)); 11180Sstevel@tonic-gate mbp.c_setno = setno; 11190Sstevel@tonic-gate mbp.c_blk_flags = MDDB_BLOCK_PARSE; 11200Sstevel@tonic-gate if (metaioctl(MD_MN_MDDB_BLOCK, &mbp, 11210Sstevel@tonic-gate &mbp.c_mde, NULL)) { 11220Sstevel@tonic-gate mdstealerror(ep, &mbp.c_mde); 11230Sstevel@tonic-gate mde_perror(ep, gettext("Could not " 11240Sstevel@tonic-gate "block set %s"), sp->setname); 11250Sstevel@tonic-gate md_exit(sp, 1); 11260Sstevel@tonic-gate } 11270Sstevel@tonic-gate } 11280Sstevel@tonic-gate 11290Sstevel@tonic-gate /* suspend commd and spin waiting for drain */ 11300Sstevel@tonic-gate while ((ret_val = mdmn_suspend(setno, 1131*3073Sjkennedy MD_COMM_ALL_CLASSES, commd_timeout)) == 11320Sstevel@tonic-gate MDE_DS_COMMDCTL_SUSPEND_NYD) { 11330Sstevel@tonic-gate sleep(1); 11340Sstevel@tonic-gate } 11350Sstevel@tonic-gate 11360Sstevel@tonic-gate if (ret_val) { 11370Sstevel@tonic-gate md_eprintf(gettext("Could not suspend " 11380Sstevel@tonic-gate "rpc.mdcommd for set %s\n"), sp->setname); 11390Sstevel@tonic-gate md_exit(sp, 1); 11400Sstevel@tonic-gate } 11410Sstevel@tonic-gate } 11420Sstevel@tonic-gate /* 11430Sstevel@tonic-gate * Resume all I/Os for this node for all MN sets in 11440Sstevel@tonic-gate * case master node had suspended I/Os but panic'd 11450Sstevel@tonic-gate * before resuming I/Os. In case of failure, exit 11460Sstevel@tonic-gate * with a 1 since unable to resume I/Os on this node. 11470Sstevel@tonic-gate */ 11480Sstevel@tonic-gate if (clnt_mn_susp_res_io(mynode(), 0, MN_RES_IO, ep)) { 11490Sstevel@tonic-gate mde_perror(ep, gettext( 11500Sstevel@tonic-gate "Unable to resume I/O on node %s for all sets"), 11510Sstevel@tonic-gate mynode()); 11520Sstevel@tonic-gate md_exit(sp, 1); 11530Sstevel@tonic-gate } 11540Sstevel@tonic-gate 11550Sstevel@tonic-gate 11560Sstevel@tonic-gate /* 11570Sstevel@tonic-gate * Can now unlock local set lock. New metaset/metadb 11580Sstevel@tonic-gate * commands are now held off using drain all. 11590Sstevel@tonic-gate */ 11600Sstevel@tonic-gate (void) meta_unlock(local_sp, ep); 11610Sstevel@tonic-gate 11620Sstevel@tonic-gate meta_mc_log(MC_LOG2, gettext("Return step completed: %s"), 11630Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 11640Sstevel@tonic-gate 11650Sstevel@tonic-gate break; 11660Sstevel@tonic-gate 11670Sstevel@tonic-gate case MC_STEP1: 11680Sstevel@tonic-gate /* 11690Sstevel@tonic-gate * Step 1 11700Sstevel@tonic-gate * 11710Sstevel@tonic-gate * - Populate nodelist file if we are on clustering 11720Sstevel@tonic-gate * and pick a master node for each MN diskset. 11730Sstevel@tonic-gate */ 11740Sstevel@tonic-gate 11750Sstevel@tonic-gate /* expect the nodelist to follow the step name */ 11760Sstevel@tonic-gate if (argc < 1) 11770Sstevel@tonic-gate usage(sp, 1); 11780Sstevel@tonic-gate 11790Sstevel@tonic-gate meta_mc_log(MC_LOG2, gettext("Starting Step1: %s"), 11800Sstevel@tonic-gate meta_print_hrtime(0)); 11810Sstevel@tonic-gate 11820Sstevel@tonic-gate /* Always write nodelist file even if no local set exists */ 11830Sstevel@tonic-gate if (clust == SDSSC_OKAY) { 11840Sstevel@tonic-gate /* skip to the nodelist args */ 11850Sstevel@tonic-gate if (meta_write_nodelist(argc, argv, ep) != 0) { 11860Sstevel@tonic-gate mde_perror(ep, gettext( 11870Sstevel@tonic-gate "Could not populate nodelist file")); 11880Sstevel@tonic-gate md_exit(sp, 1); 11890Sstevel@tonic-gate } 11900Sstevel@tonic-gate } 11910Sstevel@tonic-gate 11920Sstevel@tonic-gate /* 11930Sstevel@tonic-gate * Does local set exist? If not, exit with 0 11940Sstevel@tonic-gate * since there's no reason to have this node panic if 11950Sstevel@tonic-gate * the local set cannot be started. 11960Sstevel@tonic-gate */ 11970Sstevel@tonic-gate if ((local_sp = load_local_set(ep)) == NULL) { 11980Sstevel@tonic-gate md_exit(local_sp, 0); 11990Sstevel@tonic-gate } 12000Sstevel@tonic-gate 12010Sstevel@tonic-gate /* 12020Sstevel@tonic-gate * At this point, all meta* commands are blocked across 12030Sstevel@tonic-gate * all disksets since the master rpc.mdcommd has drained or 12040Sstevel@tonic-gate * the master node has died. 12050Sstevel@tonic-gate * If a metaset or metadb command had been in progress 12060Sstevel@tonic-gate * at the start of the reconfig cycle, this command has 12070Sstevel@tonic-gate * either completed or it has been terminated due to 12080Sstevel@tonic-gate * the death of the master node. 12090Sstevel@tonic-gate * 12100Sstevel@tonic-gate * This means that that it is now ok to remove any 12110Sstevel@tonic-gate * outstanding clnt_locks associated with multinode 12120Sstevel@tonic-gate * disksets on this node due to a node panic during 12130Sstevel@tonic-gate * a metaset operation. This allows the routines that 12140Sstevel@tonic-gate * choose the master to use rpc.metad to determine the 12150Sstevel@tonic-gate * master of the diskset. 12160Sstevel@tonic-gate */ 12170Sstevel@tonic-gate if (clnt_clr_mnsetlock(mynode(), ep) != 0) { 12180Sstevel@tonic-gate meta_mc_log(MC_LOG2, gettext("Step1 aborted:" 12190Sstevel@tonic-gate "clear locks failed %s"), 12200Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 12210Sstevel@tonic-gate md_exit(local_sp, 1); 12220Sstevel@tonic-gate } 12230Sstevel@tonic-gate 12240Sstevel@tonic-gate /* 12250Sstevel@tonic-gate * Call reconfig_choose_master to choose a master for 12260Sstevel@tonic-gate * each MN diskset, update the nodelist for each diskset 12270Sstevel@tonic-gate * given the member information and send a reinit message 12280Sstevel@tonic-gate * to rpc.mdcommd to reload the nodelist. 12290Sstevel@tonic-gate */ 1230*3073Sjkennedy rval = meta_reconfig_choose_master(commd_timeout, ep); 12310Sstevel@tonic-gate if (rval == 205) { 12320Sstevel@tonic-gate /* 12330Sstevel@tonic-gate * NOTE: Should issue call to reboot remote host that 12340Sstevel@tonic-gate * is causing the RPC failure. Clustering to 12350Sstevel@tonic-gate * provide interface in the future. This should 12360Sstevel@tonic-gate * stop a never-ending set of 205 reconfig cycles. 12370Sstevel@tonic-gate * Remote host causing failure is stored in 12380Sstevel@tonic-gate * ep->host if ep is an RPC error. 12390Sstevel@tonic-gate * if (mdanyrpcerror(ep)) 12400Sstevel@tonic-gate * reboot (ep->host); 12410Sstevel@tonic-gate */ 12420Sstevel@tonic-gate meta_mc_log(MC_LOG2, gettext("Step1 aborted:" 12430Sstevel@tonic-gate "choose master failure of 205 %s"), 12440Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 12450Sstevel@tonic-gate md_exit(local_sp, 205); 12460Sstevel@tonic-gate } else if (rval != 0) { 12470Sstevel@tonic-gate meta_mc_log(MC_LOG2, gettext("Step1 failure: " 12480Sstevel@tonic-gate "choose master failure %s"), 12490Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 12500Sstevel@tonic-gate md_exit(local_sp, 1); 12510Sstevel@tonic-gate } 12520Sstevel@tonic-gate 12530Sstevel@tonic-gate meta_mc_log(MC_LOG2, gettext("Step1 completed: %s"), 12540Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 12550Sstevel@tonic-gate 12560Sstevel@tonic-gate md_exit(local_sp, rval); 12570Sstevel@tonic-gate break; 12580Sstevel@tonic-gate 12590Sstevel@tonic-gate case MC_STEP2: 12600Sstevel@tonic-gate /* 12610Sstevel@tonic-gate * Step 2 12620Sstevel@tonic-gate * 12630Sstevel@tonic-gate * In Step 2, each node walks the list of disksets. If a 12640Sstevel@tonic-gate * node is a master of a MN diskset, it synchronizes 12650Sstevel@tonic-gate * the local set USER records for that diskset. 12660Sstevel@tonic-gate * 12670Sstevel@tonic-gate * If disks exist in the diskset and there is a joined 12680Sstevel@tonic-gate * (owner) node in the diskset, the master will also: 12690Sstevel@tonic-gate * - synchronize the diskset mddbs to the master 12700Sstevel@tonic-gate * - play the change log 12710Sstevel@tonic-gate * 12720Sstevel@tonic-gate * The master node will now attempt to join any unjoined 12730Sstevel@tonic-gate * nodes that are currently members in the membership list. 12740Sstevel@tonic-gate */ 12750Sstevel@tonic-gate 12760Sstevel@tonic-gate /* expect the nodelist to follow the step name */ 12770Sstevel@tonic-gate if (argc < 1) 12780Sstevel@tonic-gate usage(sp, 1); 12790Sstevel@tonic-gate 12800Sstevel@tonic-gate meta_mc_log(MC_LOG2, gettext("Starting Step2: %s"), 12810Sstevel@tonic-gate meta_print_hrtime(0)); 12820Sstevel@tonic-gate 12830Sstevel@tonic-gate /* 12840Sstevel@tonic-gate * Does local set exist? If not, exit with 0 12850Sstevel@tonic-gate * since there's no reason to have this node panic if 12860Sstevel@tonic-gate * the local set cannot be started. 12870Sstevel@tonic-gate */ 12880Sstevel@tonic-gate if ((local_sp = load_local_set(ep)) == NULL) { 12890Sstevel@tonic-gate md_exit(local_sp, 0); 12900Sstevel@tonic-gate } 12910Sstevel@tonic-gate 12920Sstevel@tonic-gate if ((max_sets = get_max_sets(ep)) == 0) { 12930Sstevel@tonic-gate mde_perror(ep, ""); 12940Sstevel@tonic-gate md_exit(local_sp, 1); 12950Sstevel@tonic-gate } 12960Sstevel@tonic-gate 12970Sstevel@tonic-gate /* start walking through all possible disksets */ 12980Sstevel@tonic-gate for (setno = 1; setno < max_sets; setno++) { 12990Sstevel@tonic-gate if ((sp = metasetnosetname(setno, ep)) == NULL) { 13000Sstevel@tonic-gate if (mdiserror(ep, MDE_NO_SET)) { 13010Sstevel@tonic-gate /* No set for this setno - continue */ 13020Sstevel@tonic-gate mdclrerror(ep); 13030Sstevel@tonic-gate continue; 13040Sstevel@tonic-gate } else if (mdanyrpcerror(ep)) { 13050Sstevel@tonic-gate /* Fail on RPC failure to self */ 13060Sstevel@tonic-gate mde_perror(ep, gettext( 13070Sstevel@tonic-gate "Unable to get information for " 13080Sstevel@tonic-gate "set number %d"), setno); 13090Sstevel@tonic-gate md_exit(local_sp, 1); 13100Sstevel@tonic-gate } else { 13110Sstevel@tonic-gate mde_perror(ep, gettext( 13120Sstevel@tonic-gate "Unable to get information for " 13130Sstevel@tonic-gate "set number %d"), setno); 13140Sstevel@tonic-gate mdclrerror(ep); 13150Sstevel@tonic-gate continue; 13160Sstevel@tonic-gate } 13170Sstevel@tonic-gate } 13180Sstevel@tonic-gate 13190Sstevel@tonic-gate if ((sd = metaget_setdesc(sp, ep)) == NULL) { 13200Sstevel@tonic-gate if (mdanyrpcerror(ep)) { 13210Sstevel@tonic-gate /* Fail on RPC failure to self */ 13220Sstevel@tonic-gate mde_perror(ep, gettext( 13230Sstevel@tonic-gate "Unable to get information for " 13240Sstevel@tonic-gate "set number %d"), setno); 13250Sstevel@tonic-gate md_exit(local_sp, 1); 13260Sstevel@tonic-gate } 13270Sstevel@tonic-gate mde_perror(ep, gettext("Unable to get set " 13280Sstevel@tonic-gate "%s desc information"), sp->setname); 13290Sstevel@tonic-gate mdclrerror(ep); 13300Sstevel@tonic-gate continue; 13310Sstevel@tonic-gate } 13320Sstevel@tonic-gate 13330Sstevel@tonic-gate /* Only check MN disksets */ 13340Sstevel@tonic-gate if (!(MD_MNSET_DESC(sd))) { 13350Sstevel@tonic-gate continue; 13360Sstevel@tonic-gate } 13370Sstevel@tonic-gate 13380Sstevel@tonic-gate /* All actions in step 2 are driven by master */ 13390Sstevel@tonic-gate if (!(sd->sd_mn_am_i_master)) { 13400Sstevel@tonic-gate continue; 13410Sstevel@tonic-gate } 13420Sstevel@tonic-gate 13430Sstevel@tonic-gate meta_mc_log(MC_LOG3, gettext("Step2 - begin record " 13440Sstevel@tonic-gate "synchronization for set %s: %s"), sp->setname, 13450Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 13460Sstevel@tonic-gate 13470Sstevel@tonic-gate /* 13480Sstevel@tonic-gate * Synchronize the USER records in the local mddbs 13490Sstevel@tonic-gate * for hosts that are members. The USER records 13500Sstevel@tonic-gate * contain set, drive and host information. 13510Sstevel@tonic-gate */ 13520Sstevel@tonic-gate rval = meta_mnsync_user_records(sp, ep); 13530Sstevel@tonic-gate if (rval != 0) { 13540Sstevel@tonic-gate mde_perror(ep, gettext( 13550Sstevel@tonic-gate "Synchronization of user records " 13560Sstevel@tonic-gate "in set %s failed\n"), sp->setname); 13570Sstevel@tonic-gate if (rval == 205) { 13580Sstevel@tonic-gate /* 13590Sstevel@tonic-gate * NOTE: Should issue call to reboot 13600Sstevel@tonic-gate * remote host that is causing the RPC 13610Sstevel@tonic-gate * failure. Clustering to provide 13620Sstevel@tonic-gate * interface in the future. This 13630Sstevel@tonic-gate * should stop a never-ending set of 13640Sstevel@tonic-gate * 205 reconfig cycles. 13650Sstevel@tonic-gate * Remote host causing failure is 13660Sstevel@tonic-gate * stored in ep->host if ep is an 13670Sstevel@tonic-gate * RPC error. 13680Sstevel@tonic-gate * if (mdanyrpcerror(ep)) 13690Sstevel@tonic-gate * reboot (ep->host); 13700Sstevel@tonic-gate */ 13710Sstevel@tonic-gate md_exit(local_sp, 205); 13720Sstevel@tonic-gate } else { 13730Sstevel@tonic-gate md_exit(local_sp, 1); 13740Sstevel@tonic-gate } 13750Sstevel@tonic-gate } 13760Sstevel@tonic-gate 13770Sstevel@tonic-gate /* Reget sd since sync_user_recs may have flushed it */ 13780Sstevel@tonic-gate if ((sd = metaget_setdesc(sp, ep)) == NULL) { 13790Sstevel@tonic-gate mde_perror(ep, gettext("Unable to get set " 13800Sstevel@tonic-gate "%s desc information"), sp->setname); 13810Sstevel@tonic-gate md_exit(local_sp, 1); 13820Sstevel@tonic-gate } 13830Sstevel@tonic-gate 13840Sstevel@tonic-gate dd = metaget_drivedesc(sp, 13850Sstevel@tonic-gate (MD_BASICNAME_OK | PRINT_FAST), ep); 13860Sstevel@tonic-gate if (! mdisok(ep)) { 13870Sstevel@tonic-gate mde_perror(ep, gettext("Unable to get set " 13880Sstevel@tonic-gate "%s drive information"), sp->setname); 13890Sstevel@tonic-gate md_exit(local_sp, 1); 13900Sstevel@tonic-gate } 13910Sstevel@tonic-gate 13920Sstevel@tonic-gate /* 13930Sstevel@tonic-gate * No drives in set, continue to next set. 13940Sstevel@tonic-gate */ 13950Sstevel@tonic-gate if (dd == NULL) { 13960Sstevel@tonic-gate /* Done with this set */ 13970Sstevel@tonic-gate continue; 13980Sstevel@tonic-gate } 13990Sstevel@tonic-gate 14000Sstevel@tonic-gate meta_mc_log(MC_LOG3, gettext("Step2 - local set user " 14010Sstevel@tonic-gate "records completed for set %s: %s"), sp->setname, 14020Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 14030Sstevel@tonic-gate 14040Sstevel@tonic-gate /* 14050Sstevel@tonic-gate * Synchronize the diskset mddbs for hosts 14060Sstevel@tonic-gate * that are members. This may involve 14070Sstevel@tonic-gate * playing the changelog and writing out 14080Sstevel@tonic-gate * to the diskset mddbs. 14090Sstevel@tonic-gate */ 14100Sstevel@tonic-gate rval = meta_mnsync_diskset_mddbs(sp, ep); 14110Sstevel@tonic-gate if (rval != 0) { 14120Sstevel@tonic-gate mde_perror(ep, gettext( 14130Sstevel@tonic-gate "Synchronization of diskset mddbs " 14140Sstevel@tonic-gate "in set %s failed\n"), sp->setname); 14150Sstevel@tonic-gate meta_mc_log(MC_LOG3, gettext("Step2 - diskset " 14160Sstevel@tonic-gate "mddb synchronization failed for " 14170Sstevel@tonic-gate "set %s: %s"), sp->setname, 14180Sstevel@tonic-gate meta_print_hrtime(gethrtime() - 14190Sstevel@tonic-gate start_time)); 14200Sstevel@tonic-gate if (rval == 205) { 14210Sstevel@tonic-gate /* 14220Sstevel@tonic-gate * NOTE: Should issue call to reboot 14230Sstevel@tonic-gate * remote host that is causing the RPC 14240Sstevel@tonic-gate * failure. Clustering to provide 14250Sstevel@tonic-gate * interface in the future. This 14260Sstevel@tonic-gate * should stop a never-ending set of 14270Sstevel@tonic-gate * 205 reconfig cycles. 14280Sstevel@tonic-gate * Remote host causing failure is 14290Sstevel@tonic-gate * stored in ep->host if ep is an 14300Sstevel@tonic-gate * RPC error. 14310Sstevel@tonic-gate * if (mdanyrpcerror(ep)) 14320Sstevel@tonic-gate * reboot (ep->host); 14330Sstevel@tonic-gate */ 14340Sstevel@tonic-gate md_exit(local_sp, 205); 14350Sstevel@tonic-gate } else if (rval == 1) { 14360Sstevel@tonic-gate continue; 14370Sstevel@tonic-gate } else { 14380Sstevel@tonic-gate md_exit(local_sp, 1); 14390Sstevel@tonic-gate } 14400Sstevel@tonic-gate } 14410Sstevel@tonic-gate 14420Sstevel@tonic-gate meta_mc_log(MC_LOG3, gettext("Step2 - diskset mddb " 14430Sstevel@tonic-gate "synchronization completed for set %s: %s"), 14440Sstevel@tonic-gate sp->setname, 14450Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 14460Sstevel@tonic-gate 14470Sstevel@tonic-gate /* Join the starting nodes to the diskset */ 14480Sstevel@tonic-gate rval = meta_mnjoin_all(sp, ep); 14490Sstevel@tonic-gate if (rval != 0) { 14500Sstevel@tonic-gate mde_perror(ep, gettext( 14510Sstevel@tonic-gate "Join of non-owner (starting) nodes " 14520Sstevel@tonic-gate "in set %s failed\n"), sp->setname); 14530Sstevel@tonic-gate meta_mc_log(MC_LOG3, gettext("Step2 - non owner" 14540Sstevel@tonic-gate "nodes joined for set %s: %s"), 14550Sstevel@tonic-gate sp->setname, 14560Sstevel@tonic-gate meta_print_hrtime(gethrtime() - 14570Sstevel@tonic-gate start_time)); 14580Sstevel@tonic-gate if (rval == 205) { 14590Sstevel@tonic-gate /* 14600Sstevel@tonic-gate * NOTE: Should issue call to reboot 14610Sstevel@tonic-gate * remote host that is causing the RPC 14620Sstevel@tonic-gate * failure. Clustering to provide 14630Sstevel@tonic-gate * interface in the future. This 14640Sstevel@tonic-gate * should stop a never-ending set of 14650Sstevel@tonic-gate * 205 reconfig cycles. 14660Sstevel@tonic-gate * Remote host causing failure is 14670Sstevel@tonic-gate * stored in ep->host if ep is an 14680Sstevel@tonic-gate * RPC error. 14690Sstevel@tonic-gate * if (mdanyrpcerror(ep)) 14700Sstevel@tonic-gate * reboot (ep->host); 14710Sstevel@tonic-gate */ 14720Sstevel@tonic-gate md_exit(local_sp, 205); 14730Sstevel@tonic-gate } else { 14740Sstevel@tonic-gate md_exit(local_sp, 1); 14750Sstevel@tonic-gate } 14760Sstevel@tonic-gate } 14770Sstevel@tonic-gate 14780Sstevel@tonic-gate meta_mc_log(MC_LOG3, gettext("Step2 - non owner nodes " 14790Sstevel@tonic-gate "joined for set %s: %s"), sp->setname, 14800Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 14810Sstevel@tonic-gate 14820Sstevel@tonic-gate } 14830Sstevel@tonic-gate 14840Sstevel@tonic-gate meta_mc_log(MC_LOG2, gettext("Step2 completed: %s"), 14850Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 14860Sstevel@tonic-gate 14870Sstevel@tonic-gate break; 14880Sstevel@tonic-gate 14890Sstevel@tonic-gate case MC_STEP3: 14900Sstevel@tonic-gate /* 14910Sstevel@tonic-gate * Step 3 14920Sstevel@tonic-gate * 14930Sstevel@tonic-gate * For all multinode sets do, 14940Sstevel@tonic-gate * - Reinitialise rpc.mdcommd 14950Sstevel@tonic-gate * - Reset mirror owners to null if the current owner is 14960Sstevel@tonic-gate * no longer in the membership list 14970Sstevel@tonic-gate */ 14980Sstevel@tonic-gate 14990Sstevel@tonic-gate /* expect the nodelist to follow the step name */ 15000Sstevel@tonic-gate if (argc < 1) 15010Sstevel@tonic-gate usage(sp, 1); 15020Sstevel@tonic-gate 15030Sstevel@tonic-gate meta_mc_log(MC_LOG2, gettext("Starting Step3: %s"), 15040Sstevel@tonic-gate meta_print_hrtime(0)); 15050Sstevel@tonic-gate 15060Sstevel@tonic-gate /* 15070Sstevel@tonic-gate * Does local set exist? If not, exit with 0 15080Sstevel@tonic-gate * since there's no reason to have this node panic if 15090Sstevel@tonic-gate * the local set cannot be started. 15100Sstevel@tonic-gate */ 15110Sstevel@tonic-gate if ((local_sp = load_local_set(ep)) == NULL) { 15120Sstevel@tonic-gate md_exit(local_sp, 0); 15130Sstevel@tonic-gate } 15140Sstevel@tonic-gate 15150Sstevel@tonic-gate /* 15160Sstevel@tonic-gate * walk through all sets on this node which could include: 15170Sstevel@tonic-gate * - MN disksets 15180Sstevel@tonic-gate * - traditional disksets 15190Sstevel@tonic-gate * - non-existent disksets 15200Sstevel@tonic-gate * start mirror resync for all MN sets 15210Sstevel@tonic-gate */ 15220Sstevel@tonic-gate if ((max_sets = get_max_sets(ep)) == 0) { 15230Sstevel@tonic-gate mde_perror(ep, ""); 15240Sstevel@tonic-gate md_exit(local_sp, 1); 15250Sstevel@tonic-gate } 15260Sstevel@tonic-gate 15270Sstevel@tonic-gate /* start walking through all possible disksets */ 15280Sstevel@tonic-gate for (setno = 1; setno < max_sets; setno++) { 15290Sstevel@tonic-gate if ((sp = metasetnosetname(setno, ep)) == NULL) { 15300Sstevel@tonic-gate if (mdiserror(ep, MDE_NO_SET)) { 15310Sstevel@tonic-gate /* No set for this setno - continue */ 15320Sstevel@tonic-gate mdclrerror(ep); 15330Sstevel@tonic-gate continue; 15340Sstevel@tonic-gate } else { 15350Sstevel@tonic-gate mde_perror(ep, gettext("Unable to " 15360Sstevel@tonic-gate "get set %d information"), setno); 15370Sstevel@tonic-gate md_exit(local_sp, 1); 15380Sstevel@tonic-gate } 15390Sstevel@tonic-gate } 15400Sstevel@tonic-gate 15410Sstevel@tonic-gate /* only check multi-node disksets */ 15420Sstevel@tonic-gate if (!meta_is_mn_set(sp, ep)) { 15430Sstevel@tonic-gate mdclrerror(ep); 15440Sstevel@tonic-gate continue; 15450Sstevel@tonic-gate } 15460Sstevel@tonic-gate 15470Sstevel@tonic-gate if (meta_lock(sp, TRUE, ep) != 0) { 15480Sstevel@tonic-gate mde_perror(ep, ""); 15490Sstevel@tonic-gate md_exit(local_sp, 1); 15500Sstevel@tonic-gate } 15510Sstevel@tonic-gate 15520Sstevel@tonic-gate /* If this node isn't joined to set, do nothing */ 15530Sstevel@tonic-gate if (s_ownset(sp->setno, ep) != MD_SETOWNER_YES) { 15540Sstevel@tonic-gate if (!mdisok(ep)) { 15550Sstevel@tonic-gate mde_perror(ep, gettext("Could " 15560Sstevel@tonic-gate "not get set %s ownership"), 15570Sstevel@tonic-gate sp->setname); 15580Sstevel@tonic-gate md_exit(sp, 1); 15590Sstevel@tonic-gate } 15600Sstevel@tonic-gate mdclrerror(ep); 15610Sstevel@tonic-gate meta_unlock(sp, ep); 15620Sstevel@tonic-gate continue; 15630Sstevel@tonic-gate } 15640Sstevel@tonic-gate 15650Sstevel@tonic-gate meta_mc_log(MC_LOG3, gettext("Step3 - begin " 15660Sstevel@tonic-gate "re-initialising rpc.mdcommd and resetting mirror " 15670Sstevel@tonic-gate "owners for set %s: %s"), sp->setname, 15680Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 15690Sstevel@tonic-gate 15700Sstevel@tonic-gate /* reinitialzse rpc.mdcommd with new nodelist */ 1571*3073Sjkennedy if (mdmn_reinit_set(setno, commd_timeout)) { 15720Sstevel@tonic-gate md_eprintf(gettext( 15730Sstevel@tonic-gate "Could not re-initialise rpc.mdcommd for " 15740Sstevel@tonic-gate "set %s\n"), sp->setname); 15750Sstevel@tonic-gate md_exit(sp, 1); 15760Sstevel@tonic-gate } 15770Sstevel@tonic-gate 15780Sstevel@tonic-gate (void) memset(&cfg, 0, sizeof (cfg)); 15790Sstevel@tonic-gate cfg.c_id = 0; 15800Sstevel@tonic-gate cfg.c_setno = sp->setno; 15810Sstevel@tonic-gate if (metaioctl(MD_DB_GETDEV, &cfg, &cfg.c_mde, 15820Sstevel@tonic-gate NULL) != 0) { 15830Sstevel@tonic-gate mdstealerror(ep, &cfg.c_mde); 15840Sstevel@tonic-gate mde_perror(ep, gettext("Could " 15850Sstevel@tonic-gate "not get set %s information"), 15860Sstevel@tonic-gate sp->setname); 15870Sstevel@tonic-gate md_exit(sp, 1); 15880Sstevel@tonic-gate } 15890Sstevel@tonic-gate 15900Sstevel@tonic-gate /* Don't do anything else if set is stale */ 15910Sstevel@tonic-gate if (cfg.c_flags & MDDB_C_STALE) { 15920Sstevel@tonic-gate meta_unlock(sp, ep); 15930Sstevel@tonic-gate mdclrerror(ep); 15940Sstevel@tonic-gate continue; 15950Sstevel@tonic-gate } 15960Sstevel@tonic-gate 15970Sstevel@tonic-gate /* reset mirror owners */ 15980Sstevel@tonic-gate if (reset_state(RESET_OWNER, sp, MD_MIRROR, ep) == -1) { 15990Sstevel@tonic-gate md_exit(sp, 1); 16000Sstevel@tonic-gate } 16010Sstevel@tonic-gate 16020Sstevel@tonic-gate meta_unlock(sp, ep); 16030Sstevel@tonic-gate 16040Sstevel@tonic-gate meta_mc_log(MC_LOG3, gettext("Step3 - rpc.mdcommd " 16050Sstevel@tonic-gate "re-initialised and mirror owners reset for " 16060Sstevel@tonic-gate "set %s: %s"), sp->setname, 16070Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 16080Sstevel@tonic-gate } 16090Sstevel@tonic-gate 16100Sstevel@tonic-gate meta_mc_log(MC_LOG2, gettext("Step3 completed: %s"), 16110Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 16120Sstevel@tonic-gate 16130Sstevel@tonic-gate break; 16140Sstevel@tonic-gate 16150Sstevel@tonic-gate case MC_STEP4: 16160Sstevel@tonic-gate /* 16170Sstevel@tonic-gate * Step 4 16180Sstevel@tonic-gate * 16190Sstevel@tonic-gate * For all multinode sets do: 16200Sstevel@tonic-gate * - Resume the rpc.mdcommd messages. Must resume all 16210Sstevel@tonic-gate * sets before issuing I/O to any set since an error 16220Sstevel@tonic-gate * encountered in a commd suspended set could be 16230Sstevel@tonic-gate * blocked waiting for commd in another set to resume. 16240Sstevel@tonic-gate * (This happens since the daemon queues service 16250Sstevel@tonic-gate * all sets). An open of a soft partition causes 16260Sstevel@tonic-gate * a read of the watermarks during the open. 16270Sstevel@tonic-gate * - If set is non-writable (not an owner or STALE), then 16280Sstevel@tonic-gate * continue to next set. 16290Sstevel@tonic-gate * 16300Sstevel@tonic-gate * For all multinode sets do, 16310Sstevel@tonic-gate * - Reset ABR states for all mirrors, ie clear ABR if not 16320Sstevel@tonic-gate * open on any node. 16330Sstevel@tonic-gate * - Reset ABR states for all soft partitions, ie clear ABR if 16340Sstevel@tonic-gate * not open on any node. 16350Sstevel@tonic-gate * - For all slave nodes that have entered through the start 16360Sstevel@tonic-gate * step, update the ABR state to that of the master and 16370Sstevel@tonic-gate * get the submirror state from the master 16380Sstevel@tonic-gate * - meta_lock set 16390Sstevel@tonic-gate * - Resync all mirrors 16400Sstevel@tonic-gate * - unlock meta_lock for this set. 16410Sstevel@tonic-gate * - Choose a new owner for any orphaned resyncs 16420Sstevel@tonic-gate * 16430Sstevel@tonic-gate * There is one potential issue here. when concurrently 16440Sstevel@tonic-gate * resetting and updating the ABR state. If the master has ABR 16450Sstevel@tonic-gate * set, but should no longer have because the only node that 16460Sstevel@tonic-gate * had the metadevice open and had ABR set has paniced, the 16470Sstevel@tonic-gate * master will send a message to all nodes to clear the ABR 16480Sstevel@tonic-gate * state. Meanwhile any node that has come through the 16490Sstevel@tonic-gate * start step will get tstate from the master and will update 16500Sstevel@tonic-gate * ABR if it was set in tstate. So, we appear to have a problem 16510Sstevel@tonic-gate * if the following sequence occurs:- 16520Sstevel@tonic-gate * - The slave gets tstate with ABR set 16530Sstevel@tonic-gate * - The master sends a message to clear ABR 16540Sstevel@tonic-gate * - The slave updates ABR with the value it got from tstate. 16550Sstevel@tonic-gate * We now have the master with ABR clear and the slave with ABR 16560Sstevel@tonic-gate * set. Fortunately, having set ABR, the slave will close the 16570Sstevel@tonic-gate * metadevice after setting ABR and as there are no nodes with 16580Sstevel@tonic-gate * the device open, the close will send a message to clear ABR 16590Sstevel@tonic-gate * on all nodes. So, the nodes will all have ABR unset. 16600Sstevel@tonic-gate */ 16610Sstevel@tonic-gate 16620Sstevel@tonic-gate /* expect the nodelist to follow the step name */ 16630Sstevel@tonic-gate if (argc < 1) 16640Sstevel@tonic-gate usage(sp, 1); 16650Sstevel@tonic-gate 16660Sstevel@tonic-gate meta_mc_log(MC_LOG2, gettext("Starting Step4: %s"), 16670Sstevel@tonic-gate meta_print_hrtime(0)); 16680Sstevel@tonic-gate 16690Sstevel@tonic-gate /* 16700Sstevel@tonic-gate * Does local set exist? If not, exit with 0 16710Sstevel@tonic-gate * since there's no reason to have this node panic if 16720Sstevel@tonic-gate * the local set cannot be started. 16730Sstevel@tonic-gate */ 16740Sstevel@tonic-gate if ((local_sp = load_local_set(ep)) == NULL) { 16750Sstevel@tonic-gate md_exit(local_sp, 0); 16760Sstevel@tonic-gate } 16770Sstevel@tonic-gate 16780Sstevel@tonic-gate /* 16790Sstevel@tonic-gate * walk through all sets on this node which could include: 16800Sstevel@tonic-gate * - MN disksets 16810Sstevel@tonic-gate * - traditional disksets 16820Sstevel@tonic-gate * - non-existent disksets 16830Sstevel@tonic-gate * start mirror resync for all MN sets 16840Sstevel@tonic-gate */ 16850Sstevel@tonic-gate if ((max_sets = get_max_sets(ep)) == 0) { 16860Sstevel@tonic-gate mde_perror(ep, ""); 16870Sstevel@tonic-gate md_exit(local_sp, 1); 16880Sstevel@tonic-gate } 16890Sstevel@tonic-gate 16900Sstevel@tonic-gate /* Clear set_info structure */ 16910Sstevel@tonic-gate for (setno = 1; setno < max_sets; setno++) { 16920Sstevel@tonic-gate set_info[setno] = 0; 16930Sstevel@tonic-gate } 16940Sstevel@tonic-gate 16950Sstevel@tonic-gate /* start walking through all possible disksets */ 16960Sstevel@tonic-gate for (setno = 1; setno < max_sets; setno++) { 16970Sstevel@tonic-gate if ((sp = metasetnosetname(setno, ep)) == NULL) { 16980Sstevel@tonic-gate if (mdiserror(ep, MDE_NO_SET)) { 16990Sstevel@tonic-gate /* No set for this setno - continue */ 17000Sstevel@tonic-gate mdclrerror(ep); 17010Sstevel@tonic-gate continue; 17020Sstevel@tonic-gate } else { 17030Sstevel@tonic-gate mde_perror(ep, gettext("Unable to " 17040Sstevel@tonic-gate "get set %d information"), setno); 17050Sstevel@tonic-gate md_exit(local_sp, 1); 17060Sstevel@tonic-gate } 17070Sstevel@tonic-gate } 17080Sstevel@tonic-gate 17090Sstevel@tonic-gate if ((sd = metaget_setdesc(sp, ep)) == NULL) { 17100Sstevel@tonic-gate mde_perror(ep, gettext("Unable to get set " 17110Sstevel@tonic-gate "%s desc information"), sp->setname); 17120Sstevel@tonic-gate mdclrerror(ep); 17130Sstevel@tonic-gate continue; 17140Sstevel@tonic-gate } 17150Sstevel@tonic-gate 17160Sstevel@tonic-gate /* only check multi-node disksets */ 17170Sstevel@tonic-gate if (!meta_is_mn_set(sp, ep)) { 17180Sstevel@tonic-gate mdclrerror(ep); 17190Sstevel@tonic-gate continue; 17200Sstevel@tonic-gate } 17210Sstevel@tonic-gate 17220Sstevel@tonic-gate set_info[setno] |= SET_INFO_MN; 17230Sstevel@tonic-gate 17240Sstevel@tonic-gate /* 17250Sstevel@tonic-gate * If not an owner (all mddbs failed) or stale 17260Sstevel@tonic-gate * (< 50% mddbs operational), then set is 17270Sstevel@tonic-gate * non-writable so just resume commd and 17280Sstevel@tonic-gate * unblock mddb messages. 17290Sstevel@tonic-gate */ 17300Sstevel@tonic-gate mdclrerror(ep); 17310Sstevel@tonic-gate if (s_ownset(sp->setno, ep) != MD_SETOWNER_YES) { 17320Sstevel@tonic-gate set_info[setno] |= SET_INFO_NO_WR; 17330Sstevel@tonic-gate } 17340Sstevel@tonic-gate if (!mdisok(ep)) { 17350Sstevel@tonic-gate mde_perror(ep, gettext("Could " 17360Sstevel@tonic-gate "not get set %s ownership"), 17370Sstevel@tonic-gate sp->setname); 17380Sstevel@tonic-gate md_exit(local_sp, 1); 17390Sstevel@tonic-gate } 17400Sstevel@tonic-gate /* Set is owned - is it stale? */ 17410Sstevel@tonic-gate if (!set_info[setno] & SET_INFO_NO_WR) { 17420Sstevel@tonic-gate (void) memset(&cfg, 0, sizeof (cfg)); 17430Sstevel@tonic-gate cfg.c_id = 0; 17440Sstevel@tonic-gate cfg.c_setno = sp->setno; 17450Sstevel@tonic-gate if (metaioctl(MD_DB_GETDEV, &cfg, &cfg.c_mde, 17460Sstevel@tonic-gate NULL) != 0) { 17470Sstevel@tonic-gate mdstealerror(ep, &cfg.c_mde); 17480Sstevel@tonic-gate mde_perror(ep, gettext("Could " 17490Sstevel@tonic-gate "not get set %s information"), 17500Sstevel@tonic-gate sp->setname); 17510Sstevel@tonic-gate md_exit(local_sp, 1); 17520Sstevel@tonic-gate } 17530Sstevel@tonic-gate if (cfg.c_flags & MDDB_C_STALE) { 17540Sstevel@tonic-gate set_info[setno] |= SET_INFO_NO_WR; 17550Sstevel@tonic-gate } 17560Sstevel@tonic-gate } 17570Sstevel@tonic-gate 17580Sstevel@tonic-gate /* resume rpc.mdcommd */ 1759*3073Sjkennedy if (mdmn_resume(setno, MD_COMM_ALL_CLASSES, 0, 1760*3073Sjkennedy commd_timeout)) { 17610Sstevel@tonic-gate md_eprintf(gettext("Unable to resume " 17620Sstevel@tonic-gate "rpc.mdcommd for set %s\n"), sp->setname); 17630Sstevel@tonic-gate md_exit(local_sp, 1); 17640Sstevel@tonic-gate } 17650Sstevel@tonic-gate meta_ping_mnset(setno); 17660Sstevel@tonic-gate 17670Sstevel@tonic-gate /* Unblock mddb parse messages */ 17680Sstevel@tonic-gate if (s_ownset(sp->setno, ep) == MD_SETOWNER_YES) { 17690Sstevel@tonic-gate (void) memset(&mbp, 0, sizeof (mbp)); 17700Sstevel@tonic-gate mbp.c_setno = setno; 17710Sstevel@tonic-gate mbp.c_blk_flags = MDDB_UNBLOCK_PARSE; 17720Sstevel@tonic-gate if (metaioctl(MD_MN_MDDB_BLOCK, &mbp, 17730Sstevel@tonic-gate &mbp.c_mde, NULL)) { 17740Sstevel@tonic-gate mdstealerror(ep, &mbp.c_mde); 17750Sstevel@tonic-gate mde_perror(ep, gettext("Could not " 17760Sstevel@tonic-gate "unblock set %s"), sp->setname); 17770Sstevel@tonic-gate md_exit(local_sp, 1); 17780Sstevel@tonic-gate } 17790Sstevel@tonic-gate } 17800Sstevel@tonic-gate meta_mc_log(MC_LOG3, gettext("Step4 - rpc.mdcommd " 17810Sstevel@tonic-gate "resumed and messages unblocked for set %s: %s"), 17820Sstevel@tonic-gate sp->setname, 17830Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 17840Sstevel@tonic-gate } 17850Sstevel@tonic-gate 17860Sstevel@tonic-gate for (setno = 1; setno < max_sets; setno++) { 17870Sstevel@tonic-gate int start_step; 17880Sstevel@tonic-gate 17890Sstevel@tonic-gate /* Skip traditional disksets. */ 17900Sstevel@tonic-gate if ((set_info[setno] & SET_INFO_MN) == 0) 17910Sstevel@tonic-gate continue; 17920Sstevel@tonic-gate 17930Sstevel@tonic-gate /* 17940Sstevel@tonic-gate * If already determined that this set is 17950Sstevel@tonic-gate * a non-writable set, then just continue 17960Sstevel@tonic-gate * to next set since there's nothing else 17970Sstevel@tonic-gate * to do for a non-writable set. 17980Sstevel@tonic-gate */ 17990Sstevel@tonic-gate if (set_info[setno] & SET_INFO_NO_WR) 18000Sstevel@tonic-gate continue; 18010Sstevel@tonic-gate 18020Sstevel@tonic-gate if ((sp = metasetnosetname(setno, ep)) == NULL) { 18030Sstevel@tonic-gate if (mdiserror(ep, MDE_NO_SET)) { 18040Sstevel@tonic-gate /* No set for this setno - continue */ 18050Sstevel@tonic-gate mdclrerror(ep); 18060Sstevel@tonic-gate continue; 18070Sstevel@tonic-gate } else { 18080Sstevel@tonic-gate mde_perror(ep, gettext("Unable to " 18090Sstevel@tonic-gate "get set %d information"), setno); 18100Sstevel@tonic-gate md_exit(local_sp, 1); 18110Sstevel@tonic-gate } 18120Sstevel@tonic-gate } 18130Sstevel@tonic-gate 18140Sstevel@tonic-gate if ((sd = metaget_setdesc(sp, ep)) == NULL) { 18150Sstevel@tonic-gate mde_perror(ep, gettext("Unable to get set " 18160Sstevel@tonic-gate "%s desc information"), sp->setname); 18170Sstevel@tonic-gate mdclrerror(ep); 18180Sstevel@tonic-gate continue; 18190Sstevel@tonic-gate } 18200Sstevel@tonic-gate 18210Sstevel@tonic-gate /* See if this node came through the start step */ 18220Sstevel@tonic-gate (void) memset(&sf, 0, sizeof (sf)); 18230Sstevel@tonic-gate sf.sf_setno = sp->setno; 18240Sstevel@tonic-gate sf.sf_flags = MDDB_NM_GET; 18250Sstevel@tonic-gate /* Use magic to help protect ioctl against attack. */ 18260Sstevel@tonic-gate sf.sf_magic = MDDB_SETFLAGS_MAGIC; 18270Sstevel@tonic-gate if (metaioctl(MD_MN_SET_SETFLAGS, &sf, 18280Sstevel@tonic-gate &sf.sf_mde, NULL)) { 18290Sstevel@tonic-gate mdstealerror(ep, &sf.sf_mde); 18300Sstevel@tonic-gate mde_perror(ep, gettext("Could not get " 18310Sstevel@tonic-gate "start_step flag for set %s"), sp->setname); 18320Sstevel@tonic-gate md_exit(local_sp, 1); 18330Sstevel@tonic-gate } 18340Sstevel@tonic-gate start_step = 18350Sstevel@tonic-gate (sf.sf_setflags & MD_SET_MN_START_RC)? 1: 0; 18360Sstevel@tonic-gate 18370Sstevel@tonic-gate /* 18380Sstevel@tonic-gate * We can now reset the start_step flag for the set 18390Sstevel@tonic-gate * if it was already set. 18400Sstevel@tonic-gate */ 18410Sstevel@tonic-gate if (start_step) { 18420Sstevel@tonic-gate (void) memset(&sf, 0, sizeof (sf)); 18430Sstevel@tonic-gate sf.sf_setno = sp->setno; 18440Sstevel@tonic-gate sf.sf_setflags = MD_SET_MN_START_RC; 18450Sstevel@tonic-gate sf.sf_flags = MDDB_NM_RESET; 18460Sstevel@tonic-gate /* 18470Sstevel@tonic-gate * Use magic to help protect ioctl 18480Sstevel@tonic-gate * against attack. 18490Sstevel@tonic-gate */ 18500Sstevel@tonic-gate sf.sf_magic = MDDB_SETFLAGS_MAGIC; 18510Sstevel@tonic-gate if (metaioctl(MD_MN_SET_SETFLAGS, &sf, 18520Sstevel@tonic-gate &sf.sf_mde, NULL)) { 18530Sstevel@tonic-gate mdstealerror(ep, &sf.sf_mde); 18540Sstevel@tonic-gate mde_perror(ep, 18550Sstevel@tonic-gate gettext("Could not reset " 18560Sstevel@tonic-gate "start_step flag for set %s"), 18570Sstevel@tonic-gate sp->setname); 18580Sstevel@tonic-gate } 18590Sstevel@tonic-gate } 18600Sstevel@tonic-gate 18610Sstevel@tonic-gate meta_mc_log(MC_LOG3, gettext("Step4 - begin setting " 18620Sstevel@tonic-gate "ABR state and restarting io's for " 18630Sstevel@tonic-gate "set %s: %s"), sp->setname, 18640Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 18650Sstevel@tonic-gate 18660Sstevel@tonic-gate 18670Sstevel@tonic-gate /* 18680Sstevel@tonic-gate * If we are not the master and we have come through 18690Sstevel@tonic-gate * the start step, we must update the ABR states 18700Sstevel@tonic-gate * for mirrors and soft partitions. Also the submirror 18710Sstevel@tonic-gate * states need to be synchronised so that we see the 18720Sstevel@tonic-gate * same status as other previously joined members. 18730Sstevel@tonic-gate * This _must_ be done before starting the resync. 18740Sstevel@tonic-gate */ 18750Sstevel@tonic-gate if (!(sd->sd_mn_am_i_master) && start_step) { 18760Sstevel@tonic-gate if (reset_state(GET_MIRROR_STATE, sp, MD_MIRROR, 18770Sstevel@tonic-gate ep) == -1) { 18780Sstevel@tonic-gate md_exit(local_sp, 1); 18790Sstevel@tonic-gate } 18800Sstevel@tonic-gate if (reset_state(UPDATE_ABR, sp, MD_SP, 18810Sstevel@tonic-gate ep) == -1) { 18820Sstevel@tonic-gate md_exit(local_sp, 1); 18830Sstevel@tonic-gate } 18840Sstevel@tonic-gate /* 18850Sstevel@tonic-gate * Mark the fact that we've got the mirror 18860Sstevel@tonic-gate * state. This allows the resync thread to 18870Sstevel@tonic-gate * determine if _it_ needs to issue this. This 18880Sstevel@tonic-gate * can happen if a node is added to a set after 18890Sstevel@tonic-gate * a reconfig cycle has completed. 18900Sstevel@tonic-gate */ 18910Sstevel@tonic-gate (void) memset(&sf, 0, sizeof (sf)); 18920Sstevel@tonic-gate sf.sf_setno = sp->setno; 18930Sstevel@tonic-gate sf.sf_setflags = MD_SET_MN_MIR_STATE_RC; 18940Sstevel@tonic-gate sf.sf_flags = MDDB_NM_SET; 18950Sstevel@tonic-gate /* 18960Sstevel@tonic-gate * Use magic to help protect ioctl 18970Sstevel@tonic-gate * against attack. 18980Sstevel@tonic-gate */ 18990Sstevel@tonic-gate sf.sf_magic = MDDB_SETFLAGS_MAGIC; 19000Sstevel@tonic-gate if (metaioctl(MD_MN_SET_SETFLAGS, &sf, 19010Sstevel@tonic-gate &sf.sf_mde, NULL)) { 19020Sstevel@tonic-gate mdstealerror(ep, &sf.sf_mde); 19030Sstevel@tonic-gate mde_perror(ep, 19040Sstevel@tonic-gate gettext("Could not set " 19050Sstevel@tonic-gate "submirror state flag for set %s"), 19060Sstevel@tonic-gate sp->setname); 19070Sstevel@tonic-gate } 19080Sstevel@tonic-gate } 19090Sstevel@tonic-gate 19100Sstevel@tonic-gate /* 19110Sstevel@tonic-gate * All remaining actions are only performed by the 19120Sstevel@tonic-gate * master 19130Sstevel@tonic-gate */ 19140Sstevel@tonic-gate if (!(sd->sd_mn_am_i_master)) { 19150Sstevel@tonic-gate if (meta_lock(sp, TRUE, ep) != 0) { 19160Sstevel@tonic-gate mde_perror(ep, ""); 19170Sstevel@tonic-gate md_exit(local_sp, 1); 19180Sstevel@tonic-gate } 19190Sstevel@tonic-gate meta_mirror_resync_unblock(sp); 19200Sstevel@tonic-gate meta_unlock(sp, ep); 19210Sstevel@tonic-gate continue; 19220Sstevel@tonic-gate } 19230Sstevel@tonic-gate 19240Sstevel@tonic-gate /* 19250Sstevel@tonic-gate * If the master came through the start step, this 19260Sstevel@tonic-gate * implies that all of the nodes must have done the 19270Sstevel@tonic-gate * same and hence there can be no applications 19280Sstevel@tonic-gate * running. Hence no need to reset ABR 19290Sstevel@tonic-gate */ 19300Sstevel@tonic-gate if (!start_step) { 19310Sstevel@tonic-gate /* Reset ABR state for mirrors */ 19320Sstevel@tonic-gate if (reset_state(RESET_ABR, sp, MD_MIRROR, 19330Sstevel@tonic-gate ep) == -1) { 19340Sstevel@tonic-gate md_exit(local_sp, 1); 19350Sstevel@tonic-gate } 19360Sstevel@tonic-gate /* ...and now the same for soft partitions */ 19370Sstevel@tonic-gate if (reset_state(RESET_ABR, sp, MD_SP, 19380Sstevel@tonic-gate ep) == -1) { 19390Sstevel@tonic-gate md_exit(local_sp, 1); 19400Sstevel@tonic-gate } 19410Sstevel@tonic-gate } 19420Sstevel@tonic-gate 19430Sstevel@tonic-gate /* 19440Sstevel@tonic-gate * choose owners for orphaned resyncs and reset 19450Sstevel@tonic-gate * non-orphaned resyncs so that an owner node that 19460Sstevel@tonic-gate * reboots will restart the resync if needed. 19470Sstevel@tonic-gate */ 19480Sstevel@tonic-gate if (reset_state(CHOOSE_OWNER, sp, MD_MIRROR, ep) == -1) 19490Sstevel@tonic-gate md_exit(local_sp, 1); 19500Sstevel@tonic-gate 19510Sstevel@tonic-gate /* 19520Sstevel@tonic-gate * Must unlock set lock before meta_mirror_resync_all 19530Sstevel@tonic-gate * sends a message to run the metasync command 19540Sstevel@tonic-gate * which also grabs the meta_lock. 19550Sstevel@tonic-gate */ 19560Sstevel@tonic-gate if (meta_lock(sp, TRUE, ep) != 0) { 19570Sstevel@tonic-gate mde_perror(ep, ""); 19580Sstevel@tonic-gate md_exit(local_sp, 1); 19590Sstevel@tonic-gate } 19600Sstevel@tonic-gate meta_mirror_resync_unblock(sp); 19610Sstevel@tonic-gate meta_unlock(sp, ep); 19620Sstevel@tonic-gate 19630Sstevel@tonic-gate /* resync all mirrors in set */ 19640Sstevel@tonic-gate if (meta_mirror_resync_all(sp, 0, ep) != 0) { 19650Sstevel@tonic-gate mde_perror(ep, gettext("Mirror resyncs " 19660Sstevel@tonic-gate "failed for set %s"), sp->setname); 19670Sstevel@tonic-gate md_exit(local_sp, 1); 19680Sstevel@tonic-gate } 19690Sstevel@tonic-gate 19700Sstevel@tonic-gate meta_mc_log(MC_LOG3, gettext("Step4 - io's restarted " 19710Sstevel@tonic-gate "for set %s: %s"), sp->setname, 19720Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 19730Sstevel@tonic-gate } 19740Sstevel@tonic-gate 19750Sstevel@tonic-gate meta_mc_log(MC_LOG2, gettext("Step4 completed: %s"), 19760Sstevel@tonic-gate meta_print_hrtime(gethrtime() - start_time)); 19770Sstevel@tonic-gate 19780Sstevel@tonic-gate break; 19790Sstevel@tonic-gate 19800Sstevel@tonic-gate default: 19810Sstevel@tonic-gate usage(sp, 1); 19820Sstevel@tonic-gate break; 19830Sstevel@tonic-gate } 19840Sstevel@tonic-gate 19850Sstevel@tonic-gate md_exit(sp, 0); 19860Sstevel@tonic-gate /* NOTREACHED */ 19870Sstevel@tonic-gate return (0); 19880Sstevel@tonic-gate } 1989