10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*1945Sjeanm * Common Development and Distribution License (the "License"). 6*1945Sjeanm * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*1945Sjeanm * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 270Sstevel@tonic-gate 280Sstevel@tonic-gate #include <stdio.h> 290Sstevel@tonic-gate #include <stdarg.h> 300Sstevel@tonic-gate #include <ctype.h> 310Sstevel@tonic-gate #include <sys/fcntl.h> 320Sstevel@tonic-gate #include <sys/types.h> 330Sstevel@tonic-gate #include <devid.h> 340Sstevel@tonic-gate #include <ftw.h> 350Sstevel@tonic-gate #include <string.h> 360Sstevel@tonic-gate #include <mdiox.h> 370Sstevel@tonic-gate #include <sys/lvm/mdio.h> 380Sstevel@tonic-gate #include <meta.h> 390Sstevel@tonic-gate #include <syslog.h> 400Sstevel@tonic-gate #include <sdssc.h> 410Sstevel@tonic-gate #include "meta_set_prv.h" 420Sstevel@tonic-gate 430Sstevel@tonic-gate /* 440Sstevel@tonic-gate * Just in case we're not in a build environment, make sure that 450Sstevel@tonic-gate * TEXT_DOMAIN gets set to something. 460Sstevel@tonic-gate */ 470Sstevel@tonic-gate #if !defined(TEXT_DOMAIN) 480Sstevel@tonic-gate #define TEXT_DOMAIN "SYS_TEST" 490Sstevel@tonic-gate #endif 500Sstevel@tonic-gate 510Sstevel@tonic-gate #define RAW_PATH 0x001 /* rdsk */ 520Sstevel@tonic-gate #define BLOCK_PATH 0x002 /* dsk */ 530Sstevel@tonic-gate #define DSK_TYPE 0x004 /* normal /dev/[r]dsk */ 540Sstevel@tonic-gate #define TEST_TYPE 0x008 /* test driver path */ 550Sstevel@tonic-gate #define DID_TYPE 0x010 /* cluster did path */ 560Sstevel@tonic-gate #define AP_TYPE 0x020 /* should be obsolete */ 570Sstevel@tonic-gate 580Sstevel@tonic-gate typedef struct path_list { 590Sstevel@tonic-gate char *search_path; 600Sstevel@tonic-gate char *search_type; 610Sstevel@tonic-gate int path_type; 620Sstevel@tonic-gate } path_list_t; 630Sstevel@tonic-gate 640Sstevel@tonic-gate /* 650Sstevel@tonic-gate * A table of the supported path types - this should ideally be generated 660Sstevel@tonic-gate * by reading the /etc/lvm/devpath file 670Sstevel@tonic-gate */ 680Sstevel@tonic-gate static path_list_t plist[] = { 690Sstevel@tonic-gate {"/dev/rdsk", DEVID_MINOR_NAME_ALL_CHR, RAW_PATH|DSK_TYPE}, 700Sstevel@tonic-gate {"/dev/dsk", DEVID_MINOR_NAME_ALL_BLK, BLOCK_PATH|DSK_TYPE}, 710Sstevel@tonic-gate {"/dev/did/rdsk", DEVID_MINOR_NAME_ALL_CHR, RAW_PATH|DID_TYPE}, 720Sstevel@tonic-gate {"/dev/did/dsk", DEVID_MINOR_NAME_ALL_BLK, BLOCK_PATH|DID_TYPE}, 730Sstevel@tonic-gate {"/dev/td/dsk", DEVID_MINOR_NAME_ALL_BLK, BLOCK_PATH|TEST_TYPE}, 740Sstevel@tonic-gate {"/dev/td/rdsk", DEVID_MINOR_NAME_ALL_CHR, RAW_PATH|TEST_TYPE}, 750Sstevel@tonic-gate }; 760Sstevel@tonic-gate static int num = sizeof (plist)/sizeof (path_list_t); 770Sstevel@tonic-gate 780Sstevel@tonic-gate static mddevopts_t dev_options = 0; 790Sstevel@tonic-gate 800Sstevel@tonic-gate /* indicate whether to print an error message or not */ 810Sstevel@tonic-gate static int firsttime = 1; 820Sstevel@tonic-gate 830Sstevel@tonic-gate #define DEV_MATCH 0x1 840Sstevel@tonic-gate #define NAME_MATCH 0x2 850Sstevel@tonic-gate 860Sstevel@tonic-gate #define DEBUGON 1 870Sstevel@tonic-gate #define DEBUGOFF 2 880Sstevel@tonic-gate 890Sstevel@tonic-gate /* 900Sstevel@tonic-gate * Debug function: to turn on devadm function debugging include DEVADM 910Sstevel@tonic-gate * in the MD_DEBUG enviroment variable: MD_DEBUG=...,DEVADM... 920Sstevel@tonic-gate */ 930Sstevel@tonic-gate /*PRINTFLIKE1*/ 940Sstevel@tonic-gate static void 950Sstevel@tonic-gate mda_debug(char *format, ...) 960Sstevel@tonic-gate { 970Sstevel@tonic-gate char *p; 980Sstevel@tonic-gate static int debug_set = 0; 990Sstevel@tonic-gate va_list ap; 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate if (debug_set == 0) { 1020Sstevel@tonic-gate if (((p = getenv("MD_DEBUG")) != NULL) && 1030Sstevel@tonic-gate (strstr(p, "DEVADM") != NULL)) 1040Sstevel@tonic-gate debug_set = DEBUGON; 1050Sstevel@tonic-gate else 1060Sstevel@tonic-gate debug_set = DEBUGOFF; 1070Sstevel@tonic-gate } 1080Sstevel@tonic-gate if (debug_set == DEBUGON) { 1090Sstevel@tonic-gate va_start(ap, format); 1100Sstevel@tonic-gate (void) vfprintf(stderr, format, ap); 1110Sstevel@tonic-gate va_end(ap); 1120Sstevel@tonic-gate } 1130Sstevel@tonic-gate } 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate /* print error messages to the terminal or syslog */ 1160Sstevel@tonic-gate /*PRINTFLIKE1*/ 1170Sstevel@tonic-gate static void 1180Sstevel@tonic-gate mda_print(char *message, ...) 1190Sstevel@tonic-gate { 1200Sstevel@tonic-gate va_list ap; 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate va_start(ap, message); 1230Sstevel@tonic-gate if (dev_options & DEV_LOG) { 1240Sstevel@tonic-gate /* 1250Sstevel@tonic-gate * The program is a daemon in the sense that it 1260Sstevel@tonic-gate * is a system utility. 1270Sstevel@tonic-gate */ 1280Sstevel@tonic-gate (void) vsyslog((LOG_ERR | LOG_DAEMON), message, ap); 1290Sstevel@tonic-gate } else { 1300Sstevel@tonic-gate (void) vfprintf(stderr, message, ap); 1310Sstevel@tonic-gate } 1320Sstevel@tonic-gate va_end(ap); 1330Sstevel@tonic-gate } 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate /* 1360Sstevel@tonic-gate * Utility to find the correct options to use for the devid search 1370Sstevel@tonic-gate * based upon the path of the device. 1380Sstevel@tonic-gate * 1390Sstevel@tonic-gate * RETURN: 1400Sstevel@tonic-gate * -1 Error, the path passed in is not in the table 1410Sstevel@tonic-gate * >= 0 The element number for the options within the table 1420Sstevel@tonic-gate */ 1430Sstevel@tonic-gate static int 1440Sstevel@tonic-gate mda_findpath(char *path) 1450Sstevel@tonic-gate { 1460Sstevel@tonic-gate int i = 0; 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate for (i = 0; i < num; i++) { 1490Sstevel@tonic-gate if (strncmp(plist[i].search_path, path, 1500Sstevel@tonic-gate strlen(plist[i].search_path)) == 0) 1510Sstevel@tonic-gate return (i); 1520Sstevel@tonic-gate } 1530Sstevel@tonic-gate return (-1); 1540Sstevel@tonic-gate } 1550Sstevel@tonic-gate 1560Sstevel@tonic-gate /* 1570Sstevel@tonic-gate * Utility to get the path of a device 1580Sstevel@tonic-gate */ 1590Sstevel@tonic-gate static char * 1600Sstevel@tonic-gate mda_getpath(char *devname) 1610Sstevel@tonic-gate { 1620Sstevel@tonic-gate char *ptr; 1630Sstevel@tonic-gate char *pathname; 1640Sstevel@tonic-gate size_t len; 1650Sstevel@tonic-gate 1660Sstevel@tonic-gate if ((ptr = strrchr(devname, '/')) == NULL) { 1670Sstevel@tonic-gate mda_debug("Invalid format: %s\n", devname); 1680Sstevel@tonic-gate return (NULL); 1690Sstevel@tonic-gate } 1700Sstevel@tonic-gate ptr++; 1710Sstevel@tonic-gate len = strlen(devname) - strlen(ptr); 1720Sstevel@tonic-gate pathname = Malloc(len + 1); 1730Sstevel@tonic-gate (void) strncpy(pathname, devname, len); 1740Sstevel@tonic-gate pathname[len] = '\0'; 1750Sstevel@tonic-gate return (pathname); 1760Sstevel@tonic-gate } 1770Sstevel@tonic-gate 1780Sstevel@tonic-gate /* 1790Sstevel@tonic-gate * update_locator_namespace -- Contains the ioctl call that will update 1800Sstevel@tonic-gate * the ctds and pathname (ie. /dev/dsk etc) within the 1810Sstevel@tonic-gate * locator block namespace. 1820Sstevel@tonic-gate * 1830Sstevel@tonic-gate * RETURN 1840Sstevel@tonic-gate * METADEVADM_ERR ioctl failed and ep is updated with the error 1850Sstevel@tonic-gate * METADEVADM_SUCCESS success 1860Sstevel@tonic-gate */ 1870Sstevel@tonic-gate static int 1880Sstevel@tonic-gate update_locator_namespace( 1890Sstevel@tonic-gate set_t setno, 1900Sstevel@tonic-gate side_t sideno, 1910Sstevel@tonic-gate char *devname, 1920Sstevel@tonic-gate md_dev64_t dev, 1930Sstevel@tonic-gate char *pname, 1940Sstevel@tonic-gate md_error_t *ep 1950Sstevel@tonic-gate ) 1960Sstevel@tonic-gate { 1970Sstevel@tonic-gate mdnm_params_t nm; 1980Sstevel@tonic-gate 1990Sstevel@tonic-gate (void) memset(&nm, '\0', sizeof (nm)); 2000Sstevel@tonic-gate nm.mde = mdnullerror; 2010Sstevel@tonic-gate nm.setno = setno; 2020Sstevel@tonic-gate nm.side = sideno; 2030Sstevel@tonic-gate nm.devname = (uintptr_t)devname; 2040Sstevel@tonic-gate nm.devname_len = strlen(devname); 2050Sstevel@tonic-gate nm.devt = dev; 2060Sstevel@tonic-gate nm.pathname = (uintptr_t)pname; 2070Sstevel@tonic-gate nm.pathname_len = strlen(pname); 2080Sstevel@tonic-gate if (metaioctl(MD_IOCUPD_LOCNM, &nm, &nm.mde, NULL) != 0) { 2090Sstevel@tonic-gate (void) mdstealerror(ep, &nm.mde); 2100Sstevel@tonic-gate return (METADEVADM_ERR); 2110Sstevel@tonic-gate } 2120Sstevel@tonic-gate return (METADEVADM_SUCCESS); 2130Sstevel@tonic-gate } 2140Sstevel@tonic-gate 2150Sstevel@tonic-gate /* 2160Sstevel@tonic-gate * update_namespace -- Contains the ioctl call that will update the 2170Sstevel@tonic-gate * device name and pathname in the namespace area. 2180Sstevel@tonic-gate * 2190Sstevel@tonic-gate * RETURN 2200Sstevel@tonic-gate * METADEVADM_ERR ioctl failed and ep is updated with the error 2210Sstevel@tonic-gate * METADEVADM_SUCCESS success 2220Sstevel@tonic-gate */ 2230Sstevel@tonic-gate static int 2240Sstevel@tonic-gate update_namespace( 2250Sstevel@tonic-gate set_t setno, 2260Sstevel@tonic-gate side_t sideno, 2270Sstevel@tonic-gate char *devname, 2280Sstevel@tonic-gate md_dev64_t dev, 2290Sstevel@tonic-gate mdkey_t key, 2300Sstevel@tonic-gate char *pname, 2310Sstevel@tonic-gate md_error_t *ep 2320Sstevel@tonic-gate ) 2330Sstevel@tonic-gate { 2340Sstevel@tonic-gate mdnm_params_t nm; 2350Sstevel@tonic-gate 2360Sstevel@tonic-gate (void) memset(&nm, '\0', sizeof (nm)); 2370Sstevel@tonic-gate nm.mde = mdnullerror; 2380Sstevel@tonic-gate nm.setno = setno; 2390Sstevel@tonic-gate nm.side = sideno; 2400Sstevel@tonic-gate nm.devname = (uintptr_t)devname; 2410Sstevel@tonic-gate nm.devname_len = strlen(devname); 2420Sstevel@tonic-gate nm.mnum = meta_getminor(dev); 2430Sstevel@tonic-gate nm.key = key; 2440Sstevel@tonic-gate nm.pathname = (uintptr_t)pname; 2450Sstevel@tonic-gate nm.pathname_len = strlen(pname); 2460Sstevel@tonic-gate if (metaioctl(MD_IOCUPD_NM, &nm, &nm.mde, NULL) != 0) { 2470Sstevel@tonic-gate (void) mdstealerror(ep, &nm.mde); 2480Sstevel@tonic-gate return (METADEVADM_ERR); 2490Sstevel@tonic-gate } 2500Sstevel@tonic-gate return (METADEVADM_SUCCESS); 2510Sstevel@tonic-gate } 2520Sstevel@tonic-gate 2530Sstevel@tonic-gate /* 2540Sstevel@tonic-gate * stripS - Strip s<digits> off the end of the ctds name if it exists 2550Sstevel@tonic-gate */ 2560Sstevel@tonic-gate static void 2570Sstevel@tonic-gate stripS(char *name) 2580Sstevel@tonic-gate { 2590Sstevel@tonic-gate char *p; 2600Sstevel@tonic-gate 2610Sstevel@tonic-gate /* gobble number and 's' */ 2620Sstevel@tonic-gate p = name + strlen(name) - 1; 2630Sstevel@tonic-gate for (; (p > name); --p) { 2640Sstevel@tonic-gate if (!isdigit(*p)) 2650Sstevel@tonic-gate break; 2660Sstevel@tonic-gate } 2670Sstevel@tonic-gate 2680Sstevel@tonic-gate if (*p == 's') { 2690Sstevel@tonic-gate *p = '\0'; 2700Sstevel@tonic-gate } 2710Sstevel@tonic-gate } 2720Sstevel@tonic-gate 2730Sstevel@tonic-gate /* 2740Sstevel@tonic-gate * getdiskname -- to be used when scanning the input from the -u arg. 2750Sstevel@tonic-gate * This routine will strip off input that is anything but cxtxdx. 2760Sstevel@tonic-gate * ie. it will call stripS to get rid of slice info. Will also 2770Sstevel@tonic-gate * strip off /dev/dsk, /dev/rdsk, /dev/ap/dsk, /dev/ap/rdsk, 2780Sstevel@tonic-gate * /dev/did/dsk, or /dev/did/rdsk. The caller will need to free 2790Sstevel@tonic-gate * the return value. 2800Sstevel@tonic-gate * 2810Sstevel@tonic-gate * RETURN 2820Sstevel@tonic-gate * string that has the disk name in it ie. c0t0d0 2830Sstevel@tonic-gate */ 2840Sstevel@tonic-gate static char * 2850Sstevel@tonic-gate getdiskname( 2860Sstevel@tonic-gate char *name 2870Sstevel@tonic-gate ) 2880Sstevel@tonic-gate { 2890Sstevel@tonic-gate char *p; 2900Sstevel@tonic-gate char *diskname; 2910Sstevel@tonic-gate 2920Sstevel@tonic-gate /* regular device */ 2930Sstevel@tonic-gate if ((strncmp(name, "/dev/dsk/", strlen("/dev/dsk/")) == 0) && 2940Sstevel@tonic-gate (strchr((p = name + strlen("/dev/dsk/")), '/') == NULL)) { 2950Sstevel@tonic-gate diskname = Strdup(p); 2960Sstevel@tonic-gate stripS(diskname); 2970Sstevel@tonic-gate return (diskname); 2980Sstevel@tonic-gate } 2990Sstevel@tonic-gate 3000Sstevel@tonic-gate if ((strncmp(name, "/dev/rdsk/", strlen("/dev/rdsk/")) == 0) && 3010Sstevel@tonic-gate (strchr((p = name + strlen("/dev/rdsk/")), '/') == NULL)) { 3020Sstevel@tonic-gate diskname = Strdup(p); 3030Sstevel@tonic-gate stripS(diskname); 3040Sstevel@tonic-gate return (diskname); 3050Sstevel@tonic-gate } 3060Sstevel@tonic-gate 3070Sstevel@tonic-gate if ((strncmp(name, "/dev/ap/dsk/", strlen("/dev/ap/dsk/")) == 0) && 3080Sstevel@tonic-gate (strchr((p = name + strlen("/dev/ap/dsk/")), '/') == NULL)) { 3090Sstevel@tonic-gate diskname = Strdup(p); 3100Sstevel@tonic-gate stripS(diskname); 3110Sstevel@tonic-gate return (diskname); 3120Sstevel@tonic-gate } 3130Sstevel@tonic-gate 3140Sstevel@tonic-gate if ((strncmp(name, "/dev/ap/rdsk/", strlen("/dev/ap/rdsk/")) == 0) && 3150Sstevel@tonic-gate (strchr((p = name + strlen("/dev/ap/rdsk/")), '/') == NULL)) { 3160Sstevel@tonic-gate diskname = Strdup(p); 3170Sstevel@tonic-gate stripS(diskname); 3180Sstevel@tonic-gate return (diskname); 3190Sstevel@tonic-gate } 3200Sstevel@tonic-gate 3210Sstevel@tonic-gate if ((strncmp(name, "/dev/did/dsk/", strlen("/dev/did/dsk/")) == 0) && 3220Sstevel@tonic-gate (strchr((p = name + strlen("/dev/did/dsk/")), '/') == NULL)) { 3230Sstevel@tonic-gate diskname = Strdup(p); 3240Sstevel@tonic-gate stripS(diskname); 3250Sstevel@tonic-gate return (diskname); 3260Sstevel@tonic-gate } 3270Sstevel@tonic-gate 3280Sstevel@tonic-gate if ((strncmp(name, "/dev/did/rdsk/", strlen("/dev/did/rdsk/")) == 0) && 3290Sstevel@tonic-gate (strchr((p = name + strlen("/dev/did/rdsk/")), '/') == NULL)) { 3300Sstevel@tonic-gate diskname = Strdup(p); 3310Sstevel@tonic-gate stripS(diskname); 3320Sstevel@tonic-gate return (diskname); 3330Sstevel@tonic-gate } 3340Sstevel@tonic-gate 3350Sstevel@tonic-gate diskname = Strdup(name); 3360Sstevel@tonic-gate stripS(diskname); 3370Sstevel@tonic-gate return (diskname); 3380Sstevel@tonic-gate } 3390Sstevel@tonic-gate 3400Sstevel@tonic-gate /* 3410Sstevel@tonic-gate * has_devid -- return the device ID for a given key 3420Sstevel@tonic-gate * 3430Sstevel@tonic-gate * RETURN 3440Sstevel@tonic-gate * NULL error 3450Sstevel@tonic-gate * devid devid found that corresponds to the given key. 3460Sstevel@tonic-gate */ 3470Sstevel@tonic-gate static ddi_devid_t 3480Sstevel@tonic-gate has_devid(set_t setno, side_t sideno, mdkey_t key, md_error_t *ep) 3490Sstevel@tonic-gate { 3500Sstevel@tonic-gate return (meta_getdidbykey(setno, sideno, key, ep)); 3510Sstevel@tonic-gate } 3520Sstevel@tonic-gate 3530Sstevel@tonic-gate /* 3540Sstevel@tonic-gate * Go through the existing list of replicas and check to see 3550Sstevel@tonic-gate * if their disk has moved, if so update the replica list 3560Sstevel@tonic-gate * 3570Sstevel@tonic-gate * RETURN 3580Sstevel@tonic-gate * -1 error 3590Sstevel@tonic-gate * 0 success 3600Sstevel@tonic-gate */ 3610Sstevel@tonic-gate static int 3620Sstevel@tonic-gate fix_replicanames( 3630Sstevel@tonic-gate mdsetname_t *sp, 3640Sstevel@tonic-gate md_error_t *ep 3650Sstevel@tonic-gate ) 3660Sstevel@tonic-gate { 3670Sstevel@tonic-gate md_replicalist_t *rlp = NULL; 3680Sstevel@tonic-gate md_replicalist_t *rl; 3690Sstevel@tonic-gate int ret = -1; 3700Sstevel@tonic-gate int match_type = 0; 3710Sstevel@tonic-gate devid_nmlist_t *disklist = NULL; 3720Sstevel@tonic-gate dev_t small_dev = (dev_t)NODEV; 3730Sstevel@tonic-gate side_t sideno; 3740Sstevel@tonic-gate set_t setno = sp->setno; 3750Sstevel@tonic-gate char *search_path; 3760Sstevel@tonic-gate int search_number; 3770Sstevel@tonic-gate char *ctds_name; 3780Sstevel@tonic-gate char *path_name; 3790Sstevel@tonic-gate int i; 3800Sstevel@tonic-gate 3810Sstevel@tonic-gate sideno = getmyside(sp, ep); 3820Sstevel@tonic-gate if (sideno == MD_SIDEWILD) { 3830Sstevel@tonic-gate mda_debug("Failed to find the side number\n"); 3840Sstevel@tonic-gate return (-1); 3850Sstevel@tonic-gate } 3860Sstevel@tonic-gate 3870Sstevel@tonic-gate if (metareplicalist(sp, MD_BASICNAME_OK | PRINT_FAST, &rlp, ep) < 0) { 3880Sstevel@tonic-gate mda_debug("Unable to get a list of replicas\n"); 3890Sstevel@tonic-gate return (METADEVADM_ERR); 3900Sstevel@tonic-gate } 3910Sstevel@tonic-gate 3920Sstevel@tonic-gate for (rl = rlp; (rl != NULL); rl = rl->rl_next) { 3930Sstevel@tonic-gate md_replica_t *r = rl->rl_repp; 3940Sstevel@tonic-gate 3950Sstevel@tonic-gate small_dev = meta_cmpldev(r->r_namep->dev); 3960Sstevel@tonic-gate search_number = mda_findpath(r->r_namep->bname); 3970Sstevel@tonic-gate if (search_number == -1) { 3980Sstevel@tonic-gate mda_debug("replica update: invalid path: %s", 3990Sstevel@tonic-gate r->r_namep->bname); 4000Sstevel@tonic-gate continue; 4010Sstevel@tonic-gate } else { 4020Sstevel@tonic-gate search_path = plist[search_number].search_path; 4030Sstevel@tonic-gate } 4040Sstevel@tonic-gate 4050Sstevel@tonic-gate if (r->r_devid == NULL) 4060Sstevel@tonic-gate continue; 4070Sstevel@tonic-gate 4080Sstevel@tonic-gate ret = meta_deviceid_to_nmlist(search_path, r->r_devid, 4090Sstevel@tonic-gate r->r_minor_name, &disklist); 4100Sstevel@tonic-gate 4110Sstevel@tonic-gate mda_debug("replica update: search_path %s\n", search_path); 4120Sstevel@tonic-gate 4130Sstevel@tonic-gate if (ret != 0) { 4140Sstevel@tonic-gate /* 4150Sstevel@tonic-gate * Failed to find the disk, nothing can be done. 4160Sstevel@tonic-gate * The replica will be marked as bad later. 4170Sstevel@tonic-gate */ 4180Sstevel@tonic-gate mda_debug("replica update: failed to find disk %s\n", 4190Sstevel@tonic-gate r->r_namep->cname); 4200Sstevel@tonic-gate continue; 4210Sstevel@tonic-gate } 4220Sstevel@tonic-gate mda_debug("replica update: current %s (%p)\n", 4230Sstevel@tonic-gate r->r_namep->bname, (void *) small_dev); 4240Sstevel@tonic-gate 4250Sstevel@tonic-gate /* 4260Sstevel@tonic-gate * Check to see if the returned disk matches the stored one 4270Sstevel@tonic-gate */ 4280Sstevel@tonic-gate for (i = 0; disklist[i].dev != NODEV; i++) { 4290Sstevel@tonic-gate match_type = 0; 4300Sstevel@tonic-gate 4310Sstevel@tonic-gate mda_debug("replica update: devid list: %s (%p)\n", 4320Sstevel@tonic-gate disklist[i].devname, (void *) disklist[i].dev); 4330Sstevel@tonic-gate 4340Sstevel@tonic-gate if (disklist[i].dev == small_dev) { 4350Sstevel@tonic-gate match_type |= DEV_MATCH; 4360Sstevel@tonic-gate } 4370Sstevel@tonic-gate 4380Sstevel@tonic-gate if (strncmp(r->r_namep->bname, disklist[i].devname, 4390Sstevel@tonic-gate strlen(r->r_namep->bname)) == 0) { 4400Sstevel@tonic-gate match_type |= NAME_MATCH; 4410Sstevel@tonic-gate } 4420Sstevel@tonic-gate 4430Sstevel@tonic-gate /* 4440Sstevel@tonic-gate * break out if some sort of match is found because 4450Sstevel@tonic-gate * we already match on the devid. 4460Sstevel@tonic-gate */ 4470Sstevel@tonic-gate if (match_type != 0) 4480Sstevel@tonic-gate break; 4490Sstevel@tonic-gate } 4500Sstevel@tonic-gate 4510Sstevel@tonic-gate mda_debug("fix_replicanames: match: %x i: %d\n", match_type, i); 4520Sstevel@tonic-gate 4530Sstevel@tonic-gate if (match_type == (DEV_MATCH|NAME_MATCH)) { 4540Sstevel@tonic-gate /* no change */ 4550Sstevel@tonic-gate mda_debug("replica update: no change %s\n", 4560Sstevel@tonic-gate disklist[i].devname); 4570Sstevel@tonic-gate devid_free_nmlist(disklist); 4580Sstevel@tonic-gate continue; 4590Sstevel@tonic-gate } 4600Sstevel@tonic-gate 4610Sstevel@tonic-gate /* No match found - use the first entry in disklist */ 4620Sstevel@tonic-gate if (disklist[i].dev == NODEV) 4630Sstevel@tonic-gate i = 0; 4640Sstevel@tonic-gate 4650Sstevel@tonic-gate mda_debug("replica update: reloading %s %p\n", 4660Sstevel@tonic-gate disklist[i].devname, 46762Sjeanm (void *)(uintptr_t)meta_expldev(disklist[i].dev)); 4680Sstevel@tonic-gate 4690Sstevel@tonic-gate if (firsttime) { 4700Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 4710Sstevel@tonic-gate "Disk movement detected\n")); 4720Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 4730Sstevel@tonic-gate "Updating device names in Solaris Volume " 4740Sstevel@tonic-gate "Manager\n")); 4750Sstevel@tonic-gate firsttime = 0; 4760Sstevel@tonic-gate } 4770Sstevel@tonic-gate 4780Sstevel@tonic-gate if (dev_options & DEV_VERBOSE) { 4790Sstevel@tonic-gate char *devidstr; 4800Sstevel@tonic-gate 4810Sstevel@tonic-gate devidstr = 4820Sstevel@tonic-gate devid_str_encode(r->r_devid, r->r_minor_name); 4830Sstevel@tonic-gate if (devidstr == NULL) { 4840Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 4850Sstevel@tonic-gate "Failed to encode the devid\n")); 4860Sstevel@tonic-gate continue; 4870Sstevel@tonic-gate } 4880Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 4890Sstevel@tonic-gate "%s changed to %s from device relocation " 4900Sstevel@tonic-gate "information %s\n"), 4910Sstevel@tonic-gate (char *)r->r_namep->cname, disklist[i].devname, 4920Sstevel@tonic-gate devidstr); 4930Sstevel@tonic-gate } 4940Sstevel@tonic-gate 4950Sstevel@tonic-gate if (!(dev_options & DEV_NOACTION)) { 4960Sstevel@tonic-gate mda_debug("Updating locator name\n"); 4970Sstevel@tonic-gate ctds_name = strrchr(disklist[i].devname, '/'); 4980Sstevel@tonic-gate ctds_name++; 4990Sstevel@tonic-gate if ((path_name = mda_getpath(disklist[i].devname)) 5000Sstevel@tonic-gate == NULL) { 5010Sstevel@tonic-gate continue; 5020Sstevel@tonic-gate } 5030Sstevel@tonic-gate if (update_locator_namespace(setno, sideno, 5040Sstevel@tonic-gate ctds_name, meta_expldev(disklist[i].dev), 5050Sstevel@tonic-gate path_name, ep) != 0) { 5060Sstevel@tonic-gate mda_debug("replica update: ioctl failed\n"); 5070Sstevel@tonic-gate if (dev_options & DEV_VERBOSE) { 5080Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 5090Sstevel@tonic-gate "Failed to update locator " 5100Sstevel@tonic-gate "namespace on change from %s " 5110Sstevel@tonic-gate "to %s\n"), ctds_name, 5120Sstevel@tonic-gate disklist[i].devname); 5130Sstevel@tonic-gate } 5140Sstevel@tonic-gate } 5150Sstevel@tonic-gate } 5160Sstevel@tonic-gate Free(path_name); 5170Sstevel@tonic-gate devid_free_nmlist(disklist); 5180Sstevel@tonic-gate } 5190Sstevel@tonic-gate metafreereplicalist(rlp); 5200Sstevel@tonic-gate return (0); 5210Sstevel@tonic-gate } 5220Sstevel@tonic-gate 5230Sstevel@tonic-gate /* 5240Sstevel@tonic-gate * pathname_reload - main function for the -r option. Will reload the 5250Sstevel@tonic-gate * pathname in both the main namespace and the locator namespace. 5260Sstevel@tonic-gate * Also, checks both areas for invalid device ID's and prints them 5270Sstevel@tonic-gate * out. 5280Sstevel@tonic-gate * 5290Sstevel@tonic-gate * If the set is a multi-node diskset that means there are no devid's 5300Sstevel@tonic-gate * so just return. 5310Sstevel@tonic-gate * 5320Sstevel@tonic-gate * RETURN 5330Sstevel@tonic-gate * METADEVADM_ERR error 5340Sstevel@tonic-gate * METADEVADM_SUCCESS success 5350Sstevel@tonic-gate * METADEVADM_DEVIDINVALID success, but invalid devids detected 5360Sstevel@tonic-gate */ 5370Sstevel@tonic-gate int 5380Sstevel@tonic-gate pathname_reload( 5390Sstevel@tonic-gate mdsetname_t **spp, 5400Sstevel@tonic-gate set_t setno, 5410Sstevel@tonic-gate md_error_t *ep) 5420Sstevel@tonic-gate { 5430Sstevel@tonic-gate char *drvnmp; 5440Sstevel@tonic-gate minor_t mnum = 0; 5450Sstevel@tonic-gate md_dev64_t dev = 0; 5460Sstevel@tonic-gate mdnm_params_t nm; 5470Sstevel@tonic-gate char *ctds_name; 5480Sstevel@tonic-gate ddi_devid_t devidp; 5490Sstevel@tonic-gate md_i_didstat_t ds; 5500Sstevel@tonic-gate side_t sideno; 5510Sstevel@tonic-gate char *search_path = NULL; 5520Sstevel@tonic-gate int search_number; 5530Sstevel@tonic-gate devid_nmlist_t *disklist = NULL; 5540Sstevel@tonic-gate char *minor_name = NULL; 5550Sstevel@tonic-gate char *devidstr = NULL; 5560Sstevel@tonic-gate char *path = NULL; 5570Sstevel@tonic-gate int ret; 5580Sstevel@tonic-gate dev_t small_dev = (dev_t)NODEV; 5590Sstevel@tonic-gate int match_type; 5600Sstevel@tonic-gate char *tmp = NULL; 5610Sstevel@tonic-gate mdsetname_t *sp = *spp; 5620Sstevel@tonic-gate md_set_desc *sd; 5630Sstevel@tonic-gate int i; 5640Sstevel@tonic-gate 5650Sstevel@tonic-gate /* 5660Sstevel@tonic-gate * Check for multi-node diskset and return if it is one. 5670Sstevel@tonic-gate */ 5680Sstevel@tonic-gate if (!metaislocalset(sp)) { 5690Sstevel@tonic-gate if ((sd = metaget_setdesc(sp, ep)) == NULL) 5700Sstevel@tonic-gate return (METADEVADM_ERR); 5710Sstevel@tonic-gate 5720Sstevel@tonic-gate if (MD_MNSET_DESC(sd)) 5730Sstevel@tonic-gate return (METADEVADM_SUCCESS); 5740Sstevel@tonic-gate } 5750Sstevel@tonic-gate 5760Sstevel@tonic-gate /* 5770Sstevel@tonic-gate * Get the entry of the namespace via the key. To do this 5780Sstevel@tonic-gate * call MD_IOCNXTKEY until no more. 5790Sstevel@tonic-gate * For each entry in the namespace we want to check 5800Sstevel@tonic-gate * for devid and update 5810Sstevel@tonic-gate */ 5820Sstevel@tonic-gate 5830Sstevel@tonic-gate (void) memset(&nm, '\0', sizeof (nm)); 5840Sstevel@tonic-gate nm.key = MD_KEYWILD; 5850Sstevel@tonic-gate 5860Sstevel@tonic-gate sideno = getmyside(*spp, ep); 5870Sstevel@tonic-gate if (sideno == MD_SIDEWILD) { 5880Sstevel@tonic-gate /* failed to find this node in the set */ 5890Sstevel@tonic-gate mda_debug("Failed to find the side number\n"); 5900Sstevel@tonic-gate return (METADEVADM_ERR); 5910Sstevel@tonic-gate } 5920Sstevel@tonic-gate 5930Sstevel@tonic-gate /* LINTED */ 5940Sstevel@tonic-gate while (1) { 5950Sstevel@tonic-gate nm.mde = mdnullerror; 5960Sstevel@tonic-gate nm.setno = setno; 5970Sstevel@tonic-gate nm.side = sideno; 5980Sstevel@tonic-gate /* look at each key in the namespace */ 5990Sstevel@tonic-gate if (metaioctl(MD_IOCNXTKEY_NM, &nm, &nm.mde, NULL) != 0) { 6000Sstevel@tonic-gate (void) mdstealerror(ep, &nm.mde); 6010Sstevel@tonic-gate return (METADEVADM_ERR); 6020Sstevel@tonic-gate } 6030Sstevel@tonic-gate 6040Sstevel@tonic-gate if (nm.key == MD_KEYWILD) { 6050Sstevel@tonic-gate /* no more entries */ 6060Sstevel@tonic-gate break; 6070Sstevel@tonic-gate } 6080Sstevel@tonic-gate 6090Sstevel@tonic-gate /* 6100Sstevel@tonic-gate * get the nm entry using the key. Then check to see if 6110Sstevel@tonic-gate * there's a devid associated with this entry 6120Sstevel@tonic-gate * If not, go onto next key. 6130Sstevel@tonic-gate */ 6140Sstevel@tonic-gate if ((nm.devname = (uintptr_t)meta_getnmentbykey(setno, sideno, 6150Sstevel@tonic-gate nm.key, &drvnmp, &mnum, &dev, ep)) == NULL) { 6160Sstevel@tonic-gate mda_debug("pathname_reload: no name for key: %d\n", 6170Sstevel@tonic-gate nm.key); 6180Sstevel@tonic-gate continue; 6190Sstevel@tonic-gate } 6200Sstevel@tonic-gate 6210Sstevel@tonic-gate mda_debug("pathname_reload: examining %s\n", 62262Sjeanm (char *)(uintptr_t)nm.devname); 6230Sstevel@tonic-gate 6240Sstevel@tonic-gate if ((devidp = has_devid(setno, sideno, nm.key, ep)) == NULL) { 6250Sstevel@tonic-gate /* metadevices do not have devid's in them */ 6260Sstevel@tonic-gate mda_debug("pathname_reload: no devid for %s\n", 62762Sjeanm (char *)(uintptr_t)nm.devname); 628*1945Sjeanm /* Clear error if no devid and go to next nm entry */ 629*1945Sjeanm mdclrerror(ep); 6300Sstevel@tonic-gate continue; 6310Sstevel@tonic-gate } 6320Sstevel@tonic-gate 6330Sstevel@tonic-gate if ((minor_name = meta_getdidminorbykey(setno, sideno, 6340Sstevel@tonic-gate nm.key, ep)) == NULL) { 6350Sstevel@tonic-gate /* 6360Sstevel@tonic-gate * In theory this is impossible because if the 6370Sstevel@tonic-gate * devidp is non-null then the minor_name has 6380Sstevel@tonic-gate * already been looked up. 6390Sstevel@tonic-gate */ 64062Sjeanm mda_debug("No minor name for %s\n", 64162Sjeanm (char *)(uintptr_t)nm.devname); 6420Sstevel@tonic-gate free(devidp); 6430Sstevel@tonic-gate continue; 6440Sstevel@tonic-gate } 6450Sstevel@tonic-gate /* 6460Sstevel@tonic-gate * If there is a devid then we have a real device that 6470Sstevel@tonic-gate * could have moved. 6480Sstevel@tonic-gate */ 6490Sstevel@tonic-gate devidstr = devid_str_encode(devidp, minor_name); 6500Sstevel@tonic-gate if (devidstr == NULL) { 6510Sstevel@tonic-gate mda_debug("Failed to encode the devid\n"); 6520Sstevel@tonic-gate free(devidp); 6530Sstevel@tonic-gate continue; 6540Sstevel@tonic-gate } 6550Sstevel@tonic-gate mda_debug("devid: %s\n", devidstr); 6560Sstevel@tonic-gate 6570Sstevel@tonic-gate /* 6580Sstevel@tonic-gate * Find the search path that should be used. This is an 6590Sstevel@tonic-gate * optimization to try and prevent a search for the complete 6600Sstevel@tonic-gate * /dev namespace. 6610Sstevel@tonic-gate */ 66262Sjeanm search_number = mda_findpath((char *)(uintptr_t)nm.devname); 6630Sstevel@tonic-gate if (search_number == -1) { 6640Sstevel@tonic-gate search_path = "/dev"; 6650Sstevel@tonic-gate } else { 6660Sstevel@tonic-gate search_path = plist[search_number].search_path; 6670Sstevel@tonic-gate } 6680Sstevel@tonic-gate 6690Sstevel@tonic-gate /* now look for the disk name using the devid */ 6700Sstevel@tonic-gate ret = meta_deviceid_to_nmlist(search_path, devidp, 6710Sstevel@tonic-gate minor_name, &disklist); 6720Sstevel@tonic-gate free(devidp); 6730Sstevel@tonic-gate 6740Sstevel@tonic-gate if (ret != 0) { 6750Sstevel@tonic-gate /* 6760Sstevel@tonic-gate * Failed to find the disk 6770Sstevel@tonic-gate */ 6780Sstevel@tonic-gate devid_str_free(devidstr); 6790Sstevel@tonic-gate continue; 6800Sstevel@tonic-gate } 6810Sstevel@tonic-gate 6820Sstevel@tonic-gate small_dev = meta_cmpldev(dev); 6830Sstevel@tonic-gate mda_debug("Old device lookup: %s (%p)\n", 68462Sjeanm (char *)(uintptr_t)nm.devname, (void *)small_dev); 6850Sstevel@tonic-gate 6860Sstevel@tonic-gate /* 6870Sstevel@tonic-gate * Check to see if the returned disk matches the stored one 6880Sstevel@tonic-gate */ 6890Sstevel@tonic-gate for (i = 0; disklist[i].dev != NODEV; i++) { 6900Sstevel@tonic-gate match_type = 0; 6910Sstevel@tonic-gate mda_debug("From devid lookup: %s (%p)\n", 6920Sstevel@tonic-gate (char *)disklist[i].devname, 6930Sstevel@tonic-gate (void *)disklist[i].dev); 6940Sstevel@tonic-gate 6950Sstevel@tonic-gate if (disklist[i].dev == small_dev) { 6960Sstevel@tonic-gate match_type |= DEV_MATCH; 6970Sstevel@tonic-gate } 6980Sstevel@tonic-gate 69962Sjeanm if (strncmp((char *)(uintptr_t)nm.devname, 70062Sjeanm disklist[i].devname, 70162Sjeanm strlen((char *)(uintptr_t)nm.devname)) == 0) { 7020Sstevel@tonic-gate mda_debug("Name match: %s and %s (%d)\n", 70362Sjeanm disklist[i].devname, 70462Sjeanm (char *)(uintptr_t)nm.devname, 70562Sjeanm strlen((char *)(uintptr_t)nm.devname)); 7060Sstevel@tonic-gate match_type |= NAME_MATCH; 7070Sstevel@tonic-gate } 7080Sstevel@tonic-gate 7090Sstevel@tonic-gate if (match_type == (DEV_MATCH|NAME_MATCH)) 7100Sstevel@tonic-gate break; 7110Sstevel@tonic-gate } 7120Sstevel@tonic-gate 7130Sstevel@tonic-gate if (match_type == (DEV_MATCH|NAME_MATCH)) { 7140Sstevel@tonic-gate /* no change */ 7150Sstevel@tonic-gate devid_str_free(devidstr); 7160Sstevel@tonic-gate mda_debug("All matched %s\n", disklist[i].devname); 7170Sstevel@tonic-gate devid_free_nmlist(disklist); 7180Sstevel@tonic-gate continue; 7190Sstevel@tonic-gate } 7200Sstevel@tonic-gate 7210Sstevel@tonic-gate /* No match found - use the first entry in disklist */ 7220Sstevel@tonic-gate i = 0; 7230Sstevel@tonic-gate 7240Sstevel@tonic-gate if (firsttime) { 7250Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 7260Sstevel@tonic-gate "Disk movement detected\n")); 7270Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 7280Sstevel@tonic-gate "Updating device names in " 7290Sstevel@tonic-gate "Solaris Volume Manager\n")); 7300Sstevel@tonic-gate firsttime = 0; 7310Sstevel@tonic-gate } 7320Sstevel@tonic-gate if (dev_options & DEV_VERBOSE) { 7330Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 7340Sstevel@tonic-gate "%s changed to %s from device relocation " 7350Sstevel@tonic-gate "information %s\n"), 73662Sjeanm (char *)(uintptr_t)nm.devname, disklist[i].devname, 7370Sstevel@tonic-gate devidstr); 7380Sstevel@tonic-gate } 7390Sstevel@tonic-gate devid_str_free(devidstr); 7400Sstevel@tonic-gate 7410Sstevel@tonic-gate /* need to build up the path of the disk */ 7420Sstevel@tonic-gate if ((path = Strdup(disklist[i].devname)) == NULL) { 7430Sstevel@tonic-gate mda_debug("Failed to duplicate path: %s\n", 7440Sstevel@tonic-gate disklist[i].devname); 7450Sstevel@tonic-gate devid_free_nmlist(disklist); 7460Sstevel@tonic-gate continue; 7470Sstevel@tonic-gate } 7480Sstevel@tonic-gate if ((tmp = strrchr(path, '/')) == NULL) { 7490Sstevel@tonic-gate mda_debug("Failed to parse %s\n", path); 7500Sstevel@tonic-gate devid_free_nmlist(disklist); 7510Sstevel@tonic-gate Free(path); 7520Sstevel@tonic-gate continue; 7530Sstevel@tonic-gate } 7540Sstevel@tonic-gate tmp += sizeof (char); 7550Sstevel@tonic-gate *tmp = '\0'; 7560Sstevel@tonic-gate 7570Sstevel@tonic-gate if ((ctds_name = strrchr(disklist[i].devname, '/')) == NULL) { 7580Sstevel@tonic-gate mda_debug("Failed to parse ctds name: %s\n", 7590Sstevel@tonic-gate disklist[i].devname); 7600Sstevel@tonic-gate devid_free_nmlist(disklist); 7610Sstevel@tonic-gate Free(path); 7620Sstevel@tonic-gate continue; 7630Sstevel@tonic-gate } 7640Sstevel@tonic-gate ctds_name += sizeof (char); 7650Sstevel@tonic-gate 7660Sstevel@tonic-gate mda_debug("Reloading disk %s %s %p\n", 76762Sjeanm ctds_name, path, 76862Sjeanm (void *)(uintptr_t)meta_expldev(disklist[i].dev)); 7690Sstevel@tonic-gate 7700Sstevel@tonic-gate if (!(dev_options & DEV_NOACTION)) { 7710Sstevel@tonic-gate /* Something has changed so update the namespace */ 7720Sstevel@tonic-gate if (update_namespace(setno, sideno, ctds_name, 7730Sstevel@tonic-gate meta_expldev(disklist[i].dev), nm.key, path, 7740Sstevel@tonic-gate ep) != 0) { 7750Sstevel@tonic-gate mda_debug("Failed to update namespace\n"); 7760Sstevel@tonic-gate if (dev_options & DEV_VERBOSE) { 7770Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 7780Sstevel@tonic-gate "Failed to update namespace on " 7790Sstevel@tonic-gate "change from %s to %s\n"), 7800Sstevel@tonic-gate ctds_name, disklist[i].devname); 7810Sstevel@tonic-gate } 7820Sstevel@tonic-gate } 7830Sstevel@tonic-gate } 7840Sstevel@tonic-gate devid_free_nmlist(disklist); 7850Sstevel@tonic-gate Free(path); 7860Sstevel@tonic-gate } 7870Sstevel@tonic-gate 7880Sstevel@tonic-gate if (fix_replicanames(*spp, ep) == -1) 7890Sstevel@tonic-gate mda_debug("Failed to update replicas\n"); 7900Sstevel@tonic-gate 7910Sstevel@tonic-gate /* 7920Sstevel@tonic-gate * check for invalid device id's 7930Sstevel@tonic-gate */ 7940Sstevel@tonic-gate (void) memset(&ds, '\0', sizeof (ds)); 7950Sstevel@tonic-gate ds.setno = setno; 7960Sstevel@tonic-gate ds.side = sideno; 7970Sstevel@tonic-gate ds.mode = MD_FIND_INVDID; 7980Sstevel@tonic-gate /* get count of number of invalid device id's */ 7990Sstevel@tonic-gate if (metaioctl(MD_IOCDID_STAT, &ds, &ds.mde, NULL) != 0) { 8000Sstevel@tonic-gate (void) mdstealerror(ep, &ds.mde); 8010Sstevel@tonic-gate return (METADEVADM_ERR); 8020Sstevel@tonic-gate } 8030Sstevel@tonic-gate if (ds.cnt != 0) { 8040Sstevel@tonic-gate char *ctdptr, *ctdp; 8050Sstevel@tonic-gate /* 8060Sstevel@tonic-gate * we have some invalid device id's so we need to 8070Sstevel@tonic-gate * print them out 8080Sstevel@tonic-gate */ 8090Sstevel@tonic-gate ds.mode = MD_GET_INVDID; 8100Sstevel@tonic-gate /* malloc buffer for kernel to place devid list into */ 8110Sstevel@tonic-gate if ((ctdptr = (char *)Malloc((ds.cnt * ds.maxsz) + 1)) == 0) { 8120Sstevel@tonic-gate return (METADEVADM_ERR); 8130Sstevel@tonic-gate } 8140Sstevel@tonic-gate ds.ctdp = (uintptr_t)ctdptr; 8150Sstevel@tonic-gate /* get actual list of invalid device id's */ 8160Sstevel@tonic-gate if (metaioctl(MD_IOCDID_STAT, &ds, &ds.mde, NULL) != 0) { 8170Sstevel@tonic-gate Free(ctdptr); 8180Sstevel@tonic-gate (void) mdstealerror(ep, &ds.mde); 8190Sstevel@tonic-gate return (METADEVADM_ERR); 8200Sstevel@tonic-gate } 8210Sstevel@tonic-gate 8220Sstevel@tonic-gate /* print out the invalid devid's */ 8230Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 8240Sstevel@tonic-gate "Invalid device relocation information " 8250Sstevel@tonic-gate "detected in Solaris Volume Manager\n")); 8260Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 8270Sstevel@tonic-gate "Please check the status of the following disk(s):\n")); 82862Sjeanm ctdp = (char *)(uintptr_t)ds.ctdp; 8290Sstevel@tonic-gate while (*ctdp != NULL) { 8300Sstevel@tonic-gate mda_print("\t%s\n", ctdp); 8310Sstevel@tonic-gate ctdp += ds.maxsz; 8320Sstevel@tonic-gate } 8330Sstevel@tonic-gate Free(ctdptr); 8340Sstevel@tonic-gate return (METADEVADM_DEVIDINVALID); 8350Sstevel@tonic-gate } 8360Sstevel@tonic-gate return (METADEVADM_SUCCESS); 8370Sstevel@tonic-gate } 8380Sstevel@tonic-gate 8390Sstevel@tonic-gate /* 8400Sstevel@tonic-gate * replica_update_devid - cycle through the replica list, rlp, and 8410Sstevel@tonic-gate * update the device ids on all of the replicas that are on the 8420Sstevel@tonic-gate * device specified by lp. A side effect is to update the value of 8430Sstevel@tonic-gate * cdevidpp to contain the character representation of the device 8440Sstevel@tonic-gate * id before updating if it is not already set. 8450Sstevel@tonic-gate * 8460Sstevel@tonic-gate * RETURN 8470Sstevel@tonic-gate * METADEVADM_ERR error 8480Sstevel@tonic-gate * METADEVADM_SUCCESS success 8490Sstevel@tonic-gate */ 8500Sstevel@tonic-gate static int 8510Sstevel@tonic-gate replica_update_devid( 8520Sstevel@tonic-gate md_replicalist_t *rlp, 8530Sstevel@tonic-gate mddrivename_t *dnp, 8540Sstevel@tonic-gate set_t setno, 8550Sstevel@tonic-gate char **cdevidpp, 8560Sstevel@tonic-gate md_error_t *ep 8570Sstevel@tonic-gate ) 8580Sstevel@tonic-gate { 8590Sstevel@tonic-gate mddb_config_t db_c; 8600Sstevel@tonic-gate md_replicalist_t *rl; 8610Sstevel@tonic-gate ddi_devid_t devidp; 8620Sstevel@tonic-gate int ret; 8630Sstevel@tonic-gate 8640Sstevel@tonic-gate if (cdevidpp == NULL) 8650Sstevel@tonic-gate return (METADEVADM_ERR); 8660Sstevel@tonic-gate 8670Sstevel@tonic-gate ret = devid_str_decode(dnp->devid, &devidp, NULL); 8680Sstevel@tonic-gate if (ret != 0) { 8690Sstevel@tonic-gate /* failed to encode the devid */ 8700Sstevel@tonic-gate mda_debug("Failed to decode %s into a valid devid\n", 8710Sstevel@tonic-gate dnp->devid); 8720Sstevel@tonic-gate return (METADEVADM_ERR); 8730Sstevel@tonic-gate } 8740Sstevel@tonic-gate 8750Sstevel@tonic-gate /* search replica list for give ctd name */ 8760Sstevel@tonic-gate for (rl = rlp; (rl != NULL); rl = rl->rl_next) { 8770Sstevel@tonic-gate md_replica_t *r = rl->rl_repp; 8780Sstevel@tonic-gate mdname_t *rnp = r->r_namep; 8790Sstevel@tonic-gate 8800Sstevel@tonic-gate if (strncmp(rnp->cname, dnp->cname, strlen(dnp->cname)) == 0) { 8810Sstevel@tonic-gate 8820Sstevel@tonic-gate /* found the replica, now grab the devid */ 8830Sstevel@tonic-gate if (*cdevidpp == NULL) { 8840Sstevel@tonic-gate *cdevidpp = devid_str_encode(r->r_devid, NULL); 8850Sstevel@tonic-gate } 8860Sstevel@tonic-gate 8870Sstevel@tonic-gate if (*cdevidpp == NULL) { 8880Sstevel@tonic-gate devid_free(devidp); 8890Sstevel@tonic-gate return (METADEVADM_ERR); 8900Sstevel@tonic-gate } 8910Sstevel@tonic-gate 8920Sstevel@tonic-gate mda_debug("Updating replica %s, set %d, old devid %s\n", 8930Sstevel@tonic-gate rnp->cname, setno, *cdevidpp); 8940Sstevel@tonic-gate 8950Sstevel@tonic-gate if (dev_options & DEV_VERBOSE) { 8960Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 8970Sstevel@tonic-gate "Updating replica %s of set number %d from " 8980Sstevel@tonic-gate "device id %s to device id %s\n"), 8990Sstevel@tonic-gate rnp->cname, setno, *cdevidpp, dnp->devid); 9000Sstevel@tonic-gate } 9010Sstevel@tonic-gate 9020Sstevel@tonic-gate (void) memset(&db_c, '\0', sizeof (db_c)); 9030Sstevel@tonic-gate 9040Sstevel@tonic-gate db_c.c_setno = setno; 9050Sstevel@tonic-gate db_c.c_devt = rnp->dev; 9060Sstevel@tonic-gate 9070Sstevel@tonic-gate if (!(dev_options & DEV_NOACTION)) { 9080Sstevel@tonic-gate 9090Sstevel@tonic-gate mda_debug("Updating replica\n"); 9100Sstevel@tonic-gate 9110Sstevel@tonic-gate /* 9120Sstevel@tonic-gate * call into kernel to update lb 9130Sstevel@tonic-gate * namespace device id 9140Sstevel@tonic-gate * of given devt 9150Sstevel@tonic-gate */ 9160Sstevel@tonic-gate if (metaioctl(MD_DB_SETDID, &db_c, 9170Sstevel@tonic-gate &db_c.c_mde, NULL) != 0) { 9180Sstevel@tonic-gate devid_free(devidp); 9190Sstevel@tonic-gate (void) mdstealerror(ep, &db_c.c_mde); 9200Sstevel@tonic-gate return (METADEVADM_ERR); 9210Sstevel@tonic-gate } 9220Sstevel@tonic-gate } 9230Sstevel@tonic-gate 9240Sstevel@tonic-gate } 9250Sstevel@tonic-gate } 9260Sstevel@tonic-gate devid_free(devidp); 9270Sstevel@tonic-gate return (METADEVADM_SUCCESS); 9280Sstevel@tonic-gate } 9290Sstevel@tonic-gate 9300Sstevel@tonic-gate /* 9310Sstevel@tonic-gate * devid_update -- main routine for the -u option. Will update both the 9320Sstevel@tonic-gate * namespace and the locator block with the correct devid for the 9330Sstevel@tonic-gate * disk specified. 9340Sstevel@tonic-gate * 9350Sstevel@tonic-gate * RETURN 9360Sstevel@tonic-gate * METADEVADM_ERR error 9370Sstevel@tonic-gate * METADEVADM_SUCCESS success 9380Sstevel@tonic-gate */ 9390Sstevel@tonic-gate static int 9400Sstevel@tonic-gate devid_update( 9410Sstevel@tonic-gate mdsetname_t **spp, 9420Sstevel@tonic-gate set_t setno, 9430Sstevel@tonic-gate char *ctd, 9440Sstevel@tonic-gate md_error_t *ep 9450Sstevel@tonic-gate ) 9460Sstevel@tonic-gate { 9470Sstevel@tonic-gate md_drive_desc *dd, *ddp; 9480Sstevel@tonic-gate mddrivename_t *dnp; 9490Sstevel@tonic-gate mdnm_params_t nm; 9500Sstevel@tonic-gate ddi_devid_t devidp; 9510Sstevel@tonic-gate side_t side; 9520Sstevel@tonic-gate char *old_cdevidp = NULL; 9530Sstevel@tonic-gate md_replicalist_t *rlp = NULL; 9540Sstevel@tonic-gate int rval = METADEVADM_ERR; 9550Sstevel@tonic-gate mdname_t *np = NULL; 9560Sstevel@tonic-gate uint_t rep_slice; 9570Sstevel@tonic-gate char *pathname = NULL; 9580Sstevel@tonic-gate char *diskname = NULL; 9590Sstevel@tonic-gate int fd = -1; 9600Sstevel@tonic-gate int len; 9610Sstevel@tonic-gate char *fp; 9620Sstevel@tonic-gate 9630Sstevel@tonic-gate side = getmyside(*spp, ep); 9640Sstevel@tonic-gate if (side == MD_SIDEWILD) { 9650Sstevel@tonic-gate /* failed to find this node in the set */ 9660Sstevel@tonic-gate mda_debug("Failed to find the side number\n"); 9670Sstevel@tonic-gate return (METADEVADM_ERR); 9680Sstevel@tonic-gate } 9690Sstevel@tonic-gate 9700Sstevel@tonic-gate if ((dnp = metadrivename(spp, ctd, ep)) == NULL) { 9710Sstevel@tonic-gate mda_debug("Failed to create a dnp for %s\n", ctd); 9720Sstevel@tonic-gate return (METADEVADM_ERR); 9730Sstevel@tonic-gate } 9740Sstevel@tonic-gate if (dnp->devid == NULL) { 9750Sstevel@tonic-gate /* 9760Sstevel@tonic-gate * Disk does not have a devid! So cannot update the 9770Sstevel@tonic-gate * devid within the replica. 9780Sstevel@tonic-gate */ 9790Sstevel@tonic-gate mda_debug("%s does not have a devid\n", dnp->cname); 9800Sstevel@tonic-gate if (dev_options & DEV_VERBOSE) { 9810Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 9820Sstevel@tonic-gate "%s does not have a device id. Cannot update " 9830Sstevel@tonic-gate "device id if none exists\n"), ctd); 9840Sstevel@tonic-gate } 9850Sstevel@tonic-gate return (METADEVADM_ERR); 9860Sstevel@tonic-gate } 9870Sstevel@tonic-gate 9880Sstevel@tonic-gate mda_debug("Devid update to: %s\n", dnp->devid); 9890Sstevel@tonic-gate 9900Sstevel@tonic-gate /* 9910Sstevel@tonic-gate * Check if we own the set, if we do then do some processing 9920Sstevel@tonic-gate * on the replicas. 9930Sstevel@tonic-gate */ 9940Sstevel@tonic-gate if (meta_check_ownership(*spp, ep) == 0) { 9950Sstevel@tonic-gate 9960Sstevel@tonic-gate /* get the replicas */ 9970Sstevel@tonic-gate if (metareplicalist(*spp, MD_BASICNAME_OK | PRINT_FAST, &rlp, 9980Sstevel@tonic-gate ep) < 0) 9990Sstevel@tonic-gate return (METADEVADM_ERR); 10000Sstevel@tonic-gate 10010Sstevel@tonic-gate /* update the devids in the replicas if necessary */ 10020Sstevel@tonic-gate if (replica_update_devid(rlp, dnp, setno, &old_cdevidp, 10030Sstevel@tonic-gate ep) != METADEVADM_SUCCESS) { 10040Sstevel@tonic-gate metafreereplicalist(rlp); 10050Sstevel@tonic-gate return (METADEVADM_ERR); 10060Sstevel@tonic-gate } 10070Sstevel@tonic-gate 10080Sstevel@tonic-gate metafreereplicalist(rlp); 10090Sstevel@tonic-gate } 10100Sstevel@tonic-gate 10110Sstevel@tonic-gate /* 10120Sstevel@tonic-gate * If this is not the LOCAL set then need to update the LOCAL 10130Sstevel@tonic-gate * replica with the new disk record. 10140Sstevel@tonic-gate */ 10150Sstevel@tonic-gate 10160Sstevel@tonic-gate if (setno != MD_LOCAL_SET) { 10170Sstevel@tonic-gate mda_debug("Non-local set: %d side %d\n", setno, side); 10180Sstevel@tonic-gate 10190Sstevel@tonic-gate /* 10200Sstevel@tonic-gate * Need to find the disk record within the set and then 10210Sstevel@tonic-gate * update it. 10220Sstevel@tonic-gate */ 10230Sstevel@tonic-gate if ((dd = 10240Sstevel@tonic-gate metaget_drivedesc(*spp, MD_FULLNAME_ONLY, ep)) == NULL) { 10250Sstevel@tonic-gate if (! mdisok(ep)) 10260Sstevel@tonic-gate goto out; 10270Sstevel@tonic-gate /* no disks in the set - no point continuing */ 10280Sstevel@tonic-gate mda_debug("No disks in diskset\n"); 10290Sstevel@tonic-gate rval = METADEVADM_SUCCESS; 10300Sstevel@tonic-gate goto out; 10310Sstevel@tonic-gate } 10320Sstevel@tonic-gate 10330Sstevel@tonic-gate for (ddp = dd; ddp != NULL; ddp = ddp->dd_next) { 10340Sstevel@tonic-gate if (strncmp(ddp->dd_dnp->cname, dnp->cname, 10350Sstevel@tonic-gate strlen(dnp->cname)) == 0) 10360Sstevel@tonic-gate break; 10370Sstevel@tonic-gate } 10380Sstevel@tonic-gate 10390Sstevel@tonic-gate if (ddp == NULL) { 10400Sstevel@tonic-gate /* failed to finddisk in the set */ 10410Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 10420Sstevel@tonic-gate "%s not found in set %s. Check your syntax\n"), 10430Sstevel@tonic-gate ctd, (*spp)->setname); 10440Sstevel@tonic-gate (void) mddserror(ep, MDE_DS_DRIVENOTINSET, setno, NULL, 10450Sstevel@tonic-gate ctd, (*spp)->setname); 10460Sstevel@tonic-gate goto out; 10470Sstevel@tonic-gate } 10480Sstevel@tonic-gate 10490Sstevel@tonic-gate /* 10500Sstevel@tonic-gate * Now figure out the correct slice, for a diskset the slice 10510Sstevel@tonic-gate * we care about is always the 'replica' slice. 10520Sstevel@tonic-gate */ 10530Sstevel@tonic-gate if (meta_replicaslice(dnp, &rep_slice, ep) != 0) { 10540Sstevel@tonic-gate mda_debug("Unable to find replica slice for %s\n", 10550Sstevel@tonic-gate dnp->cname); 10560Sstevel@tonic-gate goto out; 10570Sstevel@tonic-gate } 10580Sstevel@tonic-gate 10590Sstevel@tonic-gate mda_debug("slice no: %d disk %s\n", rep_slice, dnp->cname); 10600Sstevel@tonic-gate 10610Sstevel@tonic-gate if ((np = metaslicename(dnp, rep_slice, ep)) == NULL) { 10620Sstevel@tonic-gate mda_debug("Unable to build namespace\n"); 10630Sstevel@tonic-gate goto out; 10640Sstevel@tonic-gate } 10650Sstevel@tonic-gate 10660Sstevel@tonic-gate mda_debug("check: ctdname: %s\n", np->cname); 10670Sstevel@tonic-gate mda_debug("check: ctdname: %s\n", np->rname); 10680Sstevel@tonic-gate mda_debug("check: ctdname: %s\n", np->bname); 10690Sstevel@tonic-gate 10700Sstevel@tonic-gate if (!(dev_options & DEV_NOACTION)) { 10710Sstevel@tonic-gate 10720Sstevel@tonic-gate mda_debug("Updating record: key %d name %s\n", 10730Sstevel@tonic-gate ddp->dd_dnp->side_names_key, np->cname); 10740Sstevel@tonic-gate 10750Sstevel@tonic-gate pathname = mda_getpath(np->bname); 10760Sstevel@tonic-gate 10770Sstevel@tonic-gate if (update_namespace(MD_LOCAL_SET, side + SKEW, 10780Sstevel@tonic-gate np->cname, np->dev, ddp->dd_dnp->side_names_key, 10790Sstevel@tonic-gate pathname, ep) != 0) { 10800Sstevel@tonic-gate goto out; 10810Sstevel@tonic-gate } 10820Sstevel@tonic-gate 10830Sstevel@tonic-gate /* 10840Sstevel@tonic-gate * Now update the devid entry as well, this works 10850Sstevel@tonic-gate * correctly because the prior call to 10860Sstevel@tonic-gate * update_namespace() above puts the correct dev_t 10870Sstevel@tonic-gate * in the namespace which will then be resolved 10880Sstevel@tonic-gate * to the new devid by the ioctl now called. 10890Sstevel@tonic-gate */ 10900Sstevel@tonic-gate nm.mde = mdnullerror; 10910Sstevel@tonic-gate nm.setno = MD_LOCAL_SET; 10920Sstevel@tonic-gate nm.side = side + SKEW; 10930Sstevel@tonic-gate nm.key = ddp->dd_dnp->side_names_key; 10940Sstevel@tonic-gate if (metaioctl(MD_SETNMDID, &nm, &nm.mde, NULL) != 0) { 10950Sstevel@tonic-gate (void) mdstealerror(ep, &nm.mde); 10960Sstevel@tonic-gate goto out; 10970Sstevel@tonic-gate } 10980Sstevel@tonic-gate } 10990Sstevel@tonic-gate } 11000Sstevel@tonic-gate 11010Sstevel@tonic-gate if ((dev_options & DEV_LOCAL_SET) && (setno != MD_LOCAL_SET)) { 11020Sstevel@tonic-gate /* 11030Sstevel@tonic-gate * Only want to update the local set so do not continue. 11040Sstevel@tonic-gate */ 11050Sstevel@tonic-gate rval = METADEVADM_SUCCESS; 11060Sstevel@tonic-gate goto out; 11070Sstevel@tonic-gate } 11080Sstevel@tonic-gate 11090Sstevel@tonic-gate /* 11100Sstevel@tonic-gate * Iterate through all of the metadevices looking for the 11110Sstevel@tonic-gate * passed in ctd. If found then update the devid 11120Sstevel@tonic-gate */ 11130Sstevel@tonic-gate (void) memset(&nm, '\0', sizeof (nm)); 11140Sstevel@tonic-gate nm.key = MD_KEYWILD; 11150Sstevel@tonic-gate /* LINTED */ 11160Sstevel@tonic-gate while (1) { 11170Sstevel@tonic-gate nm.mde = mdnullerror; 11180Sstevel@tonic-gate nm.setno = setno; 11190Sstevel@tonic-gate nm.side = side; 11200Sstevel@tonic-gate 11210Sstevel@tonic-gate /* search each namespace entry */ 11220Sstevel@tonic-gate if (metaioctl(MD_IOCNXTKEY_NM, &nm, &nm.mde, NULL) != 0) { 11230Sstevel@tonic-gate (void) mdstealerror(ep, &nm.mde); 11240Sstevel@tonic-gate rval = METADEVADM_ERR; 11250Sstevel@tonic-gate goto out; 11260Sstevel@tonic-gate } 11270Sstevel@tonic-gate if (nm.key == MD_KEYWILD) { 11280Sstevel@tonic-gate if (setno != MD_LOCAL_SET) { 11290Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 11300Sstevel@tonic-gate "%s not found in set %s. Check your " 11310Sstevel@tonic-gate "syntax\n"), ctd, (*spp)->setname); 11320Sstevel@tonic-gate goto out; 11330Sstevel@tonic-gate } else { 11340Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 11350Sstevel@tonic-gate "%s not found in local set. " 11360Sstevel@tonic-gate "Check your syntax\n"), ctd); 11370Sstevel@tonic-gate goto out; 11380Sstevel@tonic-gate } 11390Sstevel@tonic-gate } 11400Sstevel@tonic-gate 11410Sstevel@tonic-gate nm.devname = (uintptr_t)meta_getnmentbykey(setno, side, nm.key, 11420Sstevel@tonic-gate NULL, NULL, NULL, ep); 11430Sstevel@tonic-gate if (nm.devname == NULL) { 11440Sstevel@tonic-gate rval = METADEVADM_ERR; 11450Sstevel@tonic-gate goto out; 11460Sstevel@tonic-gate } 11470Sstevel@tonic-gate 114862Sjeanm diskname = getdiskname((char *)(uintptr_t)nm.devname); 11490Sstevel@tonic-gate 11500Sstevel@tonic-gate mda_debug("Checking %s with %s\n", diskname, dnp->cname); 11510Sstevel@tonic-gate if (strcmp(diskname, dnp->cname) != 0) 11520Sstevel@tonic-gate continue; 11530Sstevel@tonic-gate 11540Sstevel@tonic-gate mda_debug("Updating device %s in namespace\n", 115562Sjeanm (char *)(uintptr_t)nm.devname); 11560Sstevel@tonic-gate 11570Sstevel@tonic-gate /* 11580Sstevel@tonic-gate * found disk, does it have a devid within the namespace ? 11590Sstevel@tonic-gate * It might not because it does not support devid's or was 11600Sstevel@tonic-gate * put into the namespace when there was no devid support 11610Sstevel@tonic-gate */ 11620Sstevel@tonic-gate if ((devidp = has_devid(setno, side, nm.key, ep)) == NULL) { 11630Sstevel@tonic-gate mda_debug("%s has no devid in the namespace", 116462Sjeanm (char *)(uintptr_t)nm.devname); 11650Sstevel@tonic-gate if (dev_options & DEV_VERBOSE) { 11660Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 11670Sstevel@tonic-gate "SVM has no device id for " 116862Sjeanm "%s, cannot update.\n"), 116962Sjeanm (char *)(uintptr_t)nm.devname); 11700Sstevel@tonic-gate } 11710Sstevel@tonic-gate continue; /* no devid. go on to next */ 11720Sstevel@tonic-gate } 11730Sstevel@tonic-gate if (old_cdevidp == NULL) { 11740Sstevel@tonic-gate old_cdevidp = devid_str_encode(devidp, NULL); 11750Sstevel@tonic-gate } 11760Sstevel@tonic-gate free(devidp); 11770Sstevel@tonic-gate 11780Sstevel@tonic-gate /* 11790Sstevel@tonic-gate * has devid so update namespace, note the key has been set 11800Sstevel@tonic-gate * by the prior MD_IOCNXTKEY_NM ioctl. 11810Sstevel@tonic-gate */ 11820Sstevel@tonic-gate nm.mde = mdnullerror; 11830Sstevel@tonic-gate nm.setno = setno; 11840Sstevel@tonic-gate nm.side = side; 11850Sstevel@tonic-gate if (!(dev_options & DEV_NOACTION)) { 11860Sstevel@tonic-gate /* 11870Sstevel@tonic-gate * The call below may fail if the -u option is being 11880Sstevel@tonic-gate * used to update a disk that has been replaced. 11890Sstevel@tonic-gate * The -u option to metadevadm should not be used 11900Sstevel@tonic-gate * for this purpose because we trust the dev_t of 11910Sstevel@tonic-gate * the device in the replica and if we have replaced 11920Sstevel@tonic-gate * the device and it is a fibre one then the dev_t 11930Sstevel@tonic-gate * will have changed. This means we end up looking for 11940Sstevel@tonic-gate * the devid of a non-existant disk and we subsequently 11950Sstevel@tonic-gate * fail with NODEVID. 11960Sstevel@tonic-gate */ 11970Sstevel@tonic-gate if (metaioctl(MD_SETNMDID, &nm, 11980Sstevel@tonic-gate &nm.mde, NULL) != 0) { 11990Sstevel@tonic-gate if (dev_options & DEV_VERBOSE) { 12000Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 12010Sstevel@tonic-gate "SVM failed to update the device " 12020Sstevel@tonic-gate "id for %s probably due to both " 12030Sstevel@tonic-gate "devt and device id changing.\n"), 120462Sjeanm (char *)(uintptr_t)nm.devname); 12050Sstevel@tonic-gate } 12060Sstevel@tonic-gate (void) mdstealerror(ep, &nm.mde); 12070Sstevel@tonic-gate mde_perror(ep, ""); 12080Sstevel@tonic-gate rval = METADEVADM_ERR; 12090Sstevel@tonic-gate goto out; 12100Sstevel@tonic-gate } 12110Sstevel@tonic-gate } 12120Sstevel@tonic-gate if (old_cdevidp == NULL) { 12130Sstevel@tonic-gate rval = METADEVADM_ERR; 12140Sstevel@tonic-gate goto out; 12150Sstevel@tonic-gate } 12160Sstevel@tonic-gate break; 12170Sstevel@tonic-gate } /* end while */ 12180Sstevel@tonic-gate 12190Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 12200Sstevel@tonic-gate "Updating Solaris Volume Manager device relocation " 12210Sstevel@tonic-gate "information for %s\n"), ctd); 12220Sstevel@tonic-gate 12230Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 12240Sstevel@tonic-gate "Old device reloc information:\n\t%s\n"), old_cdevidp); 12250Sstevel@tonic-gate 12260Sstevel@tonic-gate len = strlen(dnp->rname) + strlen("s0"); 12270Sstevel@tonic-gate if ((fp = (char *)Malloc(len + 1)) == NULL) { 12280Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 12290Sstevel@tonic-gate "insufficient memory, device Reloc info not " 12300Sstevel@tonic-gate "available\n")); 12310Sstevel@tonic-gate } else { 12320Sstevel@tonic-gate (void) snprintf(fp, len + 1, "%ss0", dnp->rname); 12330Sstevel@tonic-gate if ((fd = open(fp, O_RDONLY|O_NDELAY)) < 0) { 12340Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 12350Sstevel@tonic-gate "Open of %s failed\n"), fp); 12360Sstevel@tonic-gate } else { 12370Sstevel@tonic-gate int rc = -1; 12380Sstevel@tonic-gate ddi_devid_t devid1 = NULL; 12390Sstevel@tonic-gate char *cdevidp; 12400Sstevel@tonic-gate 12410Sstevel@tonic-gate rc = devid_get(fd, &devid1); 12420Sstevel@tonic-gate if (close(fd) < 0) { 12430Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 12440Sstevel@tonic-gate "Close of %s failed\n"), fp); 12450Sstevel@tonic-gate } 12460Sstevel@tonic-gate if (rc != 0) { 12470Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 12480Sstevel@tonic-gate "Unable to obtain device " 12490Sstevel@tonic-gate "Reloc info for %s\n"), fp); 12500Sstevel@tonic-gate } else { 12510Sstevel@tonic-gate cdevidp = devid_str_encode(devid1, NULL); 12520Sstevel@tonic-gate if (cdevidp == NULL) { 12530Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 12540Sstevel@tonic-gate "Unable to print " 12550Sstevel@tonic-gate "device Reloc info for %s\n"), fp); 12560Sstevel@tonic-gate } else { 12570Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 12580Sstevel@tonic-gate "New device reloc " 12590Sstevel@tonic-gate "information:\n\t%s\n"), cdevidp); 12600Sstevel@tonic-gate devid_str_free(cdevidp); 12610Sstevel@tonic-gate } 12620Sstevel@tonic-gate devid_free(devid1); 12630Sstevel@tonic-gate } 12640Sstevel@tonic-gate } 12650Sstevel@tonic-gate Free(fp); 12660Sstevel@tonic-gate } 12670Sstevel@tonic-gate 12680Sstevel@tonic-gate rval = METADEVADM_SUCCESS; 12690Sstevel@tonic-gate 12700Sstevel@tonic-gate out: 12710Sstevel@tonic-gate if (diskname) 12720Sstevel@tonic-gate Free(diskname); 12730Sstevel@tonic-gate if (pathname) 12740Sstevel@tonic-gate Free(pathname); 12750Sstevel@tonic-gate if (old_cdevidp) { 12760Sstevel@tonic-gate devid_str_free(old_cdevidp); 12770Sstevel@tonic-gate } 12780Sstevel@tonic-gate return (rval); 12790Sstevel@tonic-gate 12800Sstevel@tonic-gate } 12810Sstevel@tonic-gate 12820Sstevel@tonic-gate /* 12830Sstevel@tonic-gate * Check the ctd name of the disk to see if the disk has moved. If it 12840Sstevel@tonic-gate * has moved then the newname is returned in 'newname', it is up to 12850Sstevel@tonic-gate * the caller to free the memory associated with it. 12860Sstevel@tonic-gate * 12870Sstevel@tonic-gate * RETURN 12880Sstevel@tonic-gate * METADEVADM_ERR error 12890Sstevel@tonic-gate * METADEVADM_SUCCESS success 12900Sstevel@tonic-gate * METADEVADM_DISKMOVE success, and the disk has moved 12910Sstevel@tonic-gate * METADEVADM_DSKNAME_ERR error creating the disk name structures. 12920Sstevel@tonic-gate */ 12930Sstevel@tonic-gate int 12940Sstevel@tonic-gate meta_upd_ctdnames( 12950Sstevel@tonic-gate mdsetname_t **spp, 12960Sstevel@tonic-gate set_t setno, 12970Sstevel@tonic-gate side_t sideno, 12980Sstevel@tonic-gate mddrivename_t *dnp, 12990Sstevel@tonic-gate char **newname, 13000Sstevel@tonic-gate md_error_t *ep 13010Sstevel@tonic-gate ) 13020Sstevel@tonic-gate { 13030Sstevel@tonic-gate char *drvnmp; 13040Sstevel@tonic-gate int i; 13050Sstevel@tonic-gate minor_t mnum = 0; 13060Sstevel@tonic-gate md_dev64_t dev = 0; 13070Sstevel@tonic-gate dev_t small_dev = (dev_t)NODEV; 13080Sstevel@tonic-gate mdnm_params_t nm; 13090Sstevel@tonic-gate char *pathname; 13100Sstevel@tonic-gate char *minor_name = NULL; 13110Sstevel@tonic-gate ddi_devid_t devidp; 13120Sstevel@tonic-gate devid_nmlist_t *disklist = NULL; 13130Sstevel@tonic-gate int ret = 0; 13140Sstevel@tonic-gate mdsidenames_t *snp; 13150Sstevel@tonic-gate int match_type; 13160Sstevel@tonic-gate int search_number = -1; 13170Sstevel@tonic-gate char *search_type = NULL; 13180Sstevel@tonic-gate char *search_path = NULL; 13190Sstevel@tonic-gate uint_t rep_slice; 13200Sstevel@tonic-gate mddrivename_t *newdnp; 13210Sstevel@tonic-gate mdname_t *np; 13220Sstevel@tonic-gate mdsetname_t *sp = *spp; 13230Sstevel@tonic-gate md_set_desc *sd; 13240Sstevel@tonic-gate 13250Sstevel@tonic-gate /* 13260Sstevel@tonic-gate * setno should always be 0 but we're going to 13270Sstevel@tonic-gate * check for multi-node diskset and return if it is one. 13280Sstevel@tonic-gate */ 13290Sstevel@tonic-gate if (!metaislocalset(sp)) { 13300Sstevel@tonic-gate if ((sd = metaget_setdesc(sp, ep)) == NULL) 13310Sstevel@tonic-gate return (METADEVADM_ERR); 13320Sstevel@tonic-gate 13330Sstevel@tonic-gate if (MD_MNSET_DESC(sd)) 13340Sstevel@tonic-gate return (METADEVADM_SUCCESS); 13350Sstevel@tonic-gate } 13360Sstevel@tonic-gate 13370Sstevel@tonic-gate if (dnp->devid == NULL) { 13380Sstevel@tonic-gate /* no devid, nothing can be done */ 13390Sstevel@tonic-gate mda_debug("meta_upd_ctdnames: %s has no devid\n", dnp->cname); 13400Sstevel@tonic-gate if (dev_options & DEV_VERBOSE) { 13410Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 13420Sstevel@tonic-gate "%s has no devid, cannot detect " 13430Sstevel@tonic-gate "disk movement for this disk.\n"), dnp->cname); 13440Sstevel@tonic-gate } 13450Sstevel@tonic-gate return (ret); 13460Sstevel@tonic-gate } 13470Sstevel@tonic-gate 13480Sstevel@tonic-gate /* 13490Sstevel@tonic-gate * Find the correct side name for the disk. There is a sidename 13500Sstevel@tonic-gate * for each host associated with the diskset. 13510Sstevel@tonic-gate */ 13520Sstevel@tonic-gate for (snp = dnp->side_names; snp != NULL; snp = snp->next) { 13530Sstevel@tonic-gate mda_debug("meta_upd_ctdnames: %s %d args: setno %d sideno %d\n", 13540Sstevel@tonic-gate snp->cname, snp->sideno, setno, sideno); 13550Sstevel@tonic-gate /* only use SKEW for the local replica */ 13560Sstevel@tonic-gate if (setno == 0) { 13570Sstevel@tonic-gate if (snp->sideno + SKEW == sideno) 13580Sstevel@tonic-gate break; 13590Sstevel@tonic-gate } else { 13600Sstevel@tonic-gate if (snp->sideno == sideno) 13610Sstevel@tonic-gate break; 13620Sstevel@tonic-gate } 13630Sstevel@tonic-gate } 13640Sstevel@tonic-gate 13650Sstevel@tonic-gate if (snp == NULL) { 13660Sstevel@tonic-gate /* 13670Sstevel@tonic-gate * Failed to find the side name, this should not 13680Sstevel@tonic-gate * be possible. However if it does happen this is an 13690Sstevel@tonic-gate * indication of an inconsistant replica - something 13700Sstevel@tonic-gate * might have gone wrong during an add or a delete of 13710Sstevel@tonic-gate * a host. 13720Sstevel@tonic-gate */ 13730Sstevel@tonic-gate mda_debug("Unable to find the side information for disk %s", 13740Sstevel@tonic-gate dnp->cname); 13750Sstevel@tonic-gate (void) mddserror(ep, MDE_DS_HOSTNOSIDE, (*spp)->setno, mynode(), 13760Sstevel@tonic-gate NULL, dnp->cname); 13770Sstevel@tonic-gate return (METADEVADM_ERR); 13780Sstevel@tonic-gate } 13790Sstevel@tonic-gate /* 13800Sstevel@tonic-gate * Find the type of device we are to be searching on 13810Sstevel@tonic-gate */ 13820Sstevel@tonic-gate search_number = mda_findpath(snp->cname); 13830Sstevel@tonic-gate if (search_number == -1) { 13840Sstevel@tonic-gate search_path = "/dev"; 13850Sstevel@tonic-gate search_type = DEVID_MINOR_NAME_ALL; 13860Sstevel@tonic-gate } else { 13870Sstevel@tonic-gate search_path = plist[search_number].search_path; 13880Sstevel@tonic-gate search_type = plist[search_number].search_type; 13890Sstevel@tonic-gate } 13900Sstevel@tonic-gate 13910Sstevel@tonic-gate mda_debug("Search path :%s searth_type: %x\n", 13920Sstevel@tonic-gate search_path, (int)search_type); 13930Sstevel@tonic-gate (void) memset(&nm, '\0', sizeof (nm)); 13940Sstevel@tonic-gate 13950Sstevel@tonic-gate nm.mde = mdnullerror; 13960Sstevel@tonic-gate nm.setno = setno; 13970Sstevel@tonic-gate nm.side = sideno; 13980Sstevel@tonic-gate 13990Sstevel@tonic-gate /* 14000Sstevel@tonic-gate * Get the devname from the name space. 14010Sstevel@tonic-gate */ 14020Sstevel@tonic-gate if ((nm.devname = (uintptr_t)meta_getnmentbykey(setno, sideno, 14030Sstevel@tonic-gate dnp->side_names_key, &drvnmp, &mnum, &dev, ep)) == NULL) { 14040Sstevel@tonic-gate return (METADEVADM_ERR); 14050Sstevel@tonic-gate } 14060Sstevel@tonic-gate 14070Sstevel@tonic-gate ret = devid_str_decode(dnp->devid, &devidp, &minor_name); 14080Sstevel@tonic-gate devid_str_free(minor_name); 14090Sstevel@tonic-gate 14100Sstevel@tonic-gate if (ret != 0) { 14110Sstevel@tonic-gate /* 14120Sstevel@tonic-gate * Failed to encode the devid. 14130Sstevel@tonic-gate */ 14140Sstevel@tonic-gate devid_free(devidp); 14150Sstevel@tonic-gate return (METADEVADM_ERR); 14160Sstevel@tonic-gate } 14170Sstevel@tonic-gate 14180Sstevel@tonic-gate /* 14190Sstevel@tonic-gate * Use the stored devid to find the existing device node and check 14200Sstevel@tonic-gate * to see if the disk has moved. Use the raw devices as the name 14210Sstevel@tonic-gate * of the disk is stored as the raw device, if this is not done 14220Sstevel@tonic-gate * then the disk will not be found. 14230Sstevel@tonic-gate */ 14240Sstevel@tonic-gate ret = meta_deviceid_to_nmlist(search_path, devidp, 14250Sstevel@tonic-gate search_type, &disklist); 14260Sstevel@tonic-gate 14270Sstevel@tonic-gate if (ret != 0) { 14280Sstevel@tonic-gate if (dev_options & DEV_VERBOSE) { 14290Sstevel@tonic-gate mda_print(dgettext(TEXT_DOMAIN, 14300Sstevel@tonic-gate "Device ID %s last associated with " 14310Sstevel@tonic-gate "disk %s no longer found in system\n"), 14320Sstevel@tonic-gate dnp->devid, dnp->cname); 14330Sstevel@tonic-gate } 14340Sstevel@tonic-gate devid_free(devidp); 14350Sstevel@tonic-gate devid_free_nmlist(disklist); 14360Sstevel@tonic-gate return (METADEVADM_SUCCESS); 14370Sstevel@tonic-gate } 14380Sstevel@tonic-gate 14390Sstevel@tonic-gate small_dev = meta_cmpldev(dev); 14400Sstevel@tonic-gate mda_debug("Old device lookup: %s (%p)\n", 144162Sjeanm (char *)(uintptr_t)nm.devname, (void *)small_dev); 14420Sstevel@tonic-gate /* 14430Sstevel@tonic-gate * Check to see if the returned disk matches the stored one 14440Sstevel@tonic-gate */ 14450Sstevel@tonic-gate for (i = 0; disklist[i].dev != NODEV; i++) { 14460Sstevel@tonic-gate match_type = 0; 14470Sstevel@tonic-gate mda_debug("From devid lookup: %s (%p)\n", 14480Sstevel@tonic-gate disklist[i].devname, (void *)disklist[i].dev); 14490Sstevel@tonic-gate 14500Sstevel@tonic-gate if (disklist[i].dev == small_dev) { 14510Sstevel@tonic-gate match_type |= DEV_MATCH; 14520Sstevel@tonic-gate } 14530Sstevel@tonic-gate 145462Sjeanm if (strncmp((char *)(uintptr_t)nm.devname, disklist[i].devname, 145562Sjeanm strlen((char *)(uintptr_t)nm.devname)) == 0) { 14560Sstevel@tonic-gate match_type |= NAME_MATCH; 14570Sstevel@tonic-gate } 14580Sstevel@tonic-gate 14590Sstevel@tonic-gate if (match_type != 0) 14600Sstevel@tonic-gate break; 14610Sstevel@tonic-gate } 14620Sstevel@tonic-gate devid_free(devidp); 14630Sstevel@tonic-gate 14640Sstevel@tonic-gate mda_debug("meta_upd_ctdnames: match: %x i: %d\n", match_type, i); 14650Sstevel@tonic-gate 14660Sstevel@tonic-gate if (match_type == (DEV_MATCH|NAME_MATCH)) { 14670Sstevel@tonic-gate /* no change */ 14680Sstevel@tonic-gate devid_free_nmlist(disklist); 14690Sstevel@tonic-gate return (METADEVADM_SUCCESS); 14700Sstevel@tonic-gate } 14710Sstevel@tonic-gate 14720Sstevel@tonic-gate /* No match found - use the first entry in disklist */ 14730Sstevel@tonic-gate if (disklist[i].dev == NODEV) 14740Sstevel@tonic-gate i = 0; 14750Sstevel@tonic-gate 14760Sstevel@tonic-gate if (!(match_type & DEV_MATCH)) { 14770Sstevel@tonic-gate /* did not match on the dev, so dev_t has changed */ 14780Sstevel@tonic-gate mda_debug("Did not match on dev: %p %p\n", 14790Sstevel@tonic-gate (void *) small_dev, (void *) disklist[i].dev); 14800Sstevel@tonic-gate dev = meta_expldev(disklist[i].dev); 14810Sstevel@tonic-gate } 14820Sstevel@tonic-gate 14830Sstevel@tonic-gate if (!(match_type & NAME_MATCH)) { 14840Sstevel@tonic-gate mda_debug("Did not match on name: %s (%p)\n", 148562Sjeanm (char *)(uintptr_t)nm.devname, (void *) disklist[i].dev); 14860Sstevel@tonic-gate } 14870Sstevel@tonic-gate 14880Sstevel@tonic-gate /* 14890Sstevel@tonic-gate * If here, then the name in the disklist is the one we 14900Sstevel@tonic-gate * want in any case so use it. 14910Sstevel@tonic-gate */ 14920Sstevel@tonic-gate mda_debug("devname: %s\n", disklist[i].devname); 14930Sstevel@tonic-gate /* 14940Sstevel@tonic-gate * Need to remove the slice as metadrivename() expects a diskname 14950Sstevel@tonic-gate */ 14960Sstevel@tonic-gate stripS(disklist[i].devname); 14970Sstevel@tonic-gate /* 14980Sstevel@tonic-gate * Build an mddrivename_t to use 14990Sstevel@tonic-gate */ 15000Sstevel@tonic-gate if ((newdnp = metadrivename(spp, disklist[i].devname, ep)) == NULL) { 15010Sstevel@tonic-gate mda_debug("Unable to make a dnp out of %s\n", 15020Sstevel@tonic-gate disklist[i].devname); 15030Sstevel@tonic-gate return (METADEVADM_DSKNAME_ERR); 15040Sstevel@tonic-gate } 15050Sstevel@tonic-gate /* 15060Sstevel@tonic-gate * Need to find the correct slice used for the replica 15070Sstevel@tonic-gate */ 15080Sstevel@tonic-gate if (meta_replicaslice(newdnp, &rep_slice, ep) != 0) { 15090Sstevel@tonic-gate return (METADEVADM_DSKNAME_ERR); 15100Sstevel@tonic-gate } 15110Sstevel@tonic-gate 15120Sstevel@tonic-gate if ((np = metaslicename(newdnp, rep_slice, ep)) == NULL) { 15130Sstevel@tonic-gate mda_debug("Failed to build an np for %s\n", dnp->rname); 15140Sstevel@tonic-gate return (METADEVADM_DSKNAME_ERR); 15150Sstevel@tonic-gate } 15160Sstevel@tonic-gate mda_debug("check: cname: %s\n", np->cname); 15170Sstevel@tonic-gate mda_debug("check: rname: %s\n", np->rname); 15180Sstevel@tonic-gate mda_debug("check: bname: %s\n", np->bname); 15190Sstevel@tonic-gate 15200Sstevel@tonic-gate if (newname != NULL) 15210Sstevel@tonic-gate *newname = Strdup(np->bname); 15220Sstevel@tonic-gate 15230Sstevel@tonic-gate if (!(dev_options & DEV_NOACTION)) { 15240Sstevel@tonic-gate 15250Sstevel@tonic-gate mda_debug("update namespace\n"); 15260Sstevel@tonic-gate 15270Sstevel@tonic-gate /* get the block path */ 15280Sstevel@tonic-gate pathname = mda_getpath(np->bname); 15290Sstevel@tonic-gate 15300Sstevel@tonic-gate if (update_namespace(setno, sideno, np->cname, 15310Sstevel@tonic-gate dev, dnp->side_names_key, pathname, ep) != 0) { 15320Sstevel@tonic-gate /* finished with the list so return the memory */ 15330Sstevel@tonic-gate Free(pathname); 15340Sstevel@tonic-gate devid_free_nmlist(disklist); 15350Sstevel@tonic-gate return (METADEVADM_ERR); 15360Sstevel@tonic-gate } 15370Sstevel@tonic-gate } 15380Sstevel@tonic-gate /* finished with the list so return the memory */ 15390Sstevel@tonic-gate Free(pathname); 15400Sstevel@tonic-gate devid_free_nmlist(disklist); 15410Sstevel@tonic-gate ret = METADEVADM_DISKMOVE; 15420Sstevel@tonic-gate return (ret); 15430Sstevel@tonic-gate } 15440Sstevel@tonic-gate 15450Sstevel@tonic-gate int 15460Sstevel@tonic-gate meta_fixdevid( 15470Sstevel@tonic-gate mdsetname_t *sp, 15480Sstevel@tonic-gate mddevopts_t options, 15490Sstevel@tonic-gate char *diskname, 15500Sstevel@tonic-gate md_error_t *ep 15510Sstevel@tonic-gate ) 15520Sstevel@tonic-gate { 15530Sstevel@tonic-gate set_t setno = sp->setno; 15540Sstevel@tonic-gate int ret = 0; 15550Sstevel@tonic-gate char *pathname = NULL; 15560Sstevel@tonic-gate mdsetname_t *local_sp = NULL; 15570Sstevel@tonic-gate md_drive_desc *d = NULL; 15580Sstevel@tonic-gate char *newname = NULL; 15590Sstevel@tonic-gate md_drive_desc *dd; 15600Sstevel@tonic-gate side_t sideno; 15610Sstevel@tonic-gate md_set_desc *sd; 15620Sstevel@tonic-gate 15630Sstevel@tonic-gate /* if MN diskset just return */ 15640Sstevel@tonic-gate if (!metaislocalset(sp)) { 15650Sstevel@tonic-gate if ((sd = metaget_setdesc(sp, ep)) == NULL) { 15660Sstevel@tonic-gate return (METADEVADM_ERR); 15670Sstevel@tonic-gate } 15680Sstevel@tonic-gate if (MD_MNSET_DESC(sd)) 15690Sstevel@tonic-gate return (METADEVADM_SUCCESS); 15700Sstevel@tonic-gate } 15710Sstevel@tonic-gate 15720Sstevel@tonic-gate dev_options |= options; 15730Sstevel@tonic-gate mda_debug("dev_options: %x\n", dev_options); 15740Sstevel@tonic-gate if (dev_options & DEV_RELOAD) { 15750Sstevel@tonic-gate /* 15760Sstevel@tonic-gate * If it's not the local set we need to check the local 15770Sstevel@tonic-gate * namespace to see if disks have moved as it contains 15780Sstevel@tonic-gate * entries for the disks in the set. 15790Sstevel@tonic-gate */ 15800Sstevel@tonic-gate if (setno != MD_LOCAL_SET) { 15810Sstevel@tonic-gate if ((dd = metaget_drivedesc(sp, MD_BASICNAME_OK | 15820Sstevel@tonic-gate PRINT_FAST, ep)) == NULL) { 15830Sstevel@tonic-gate mde_perror(ep, ""); 15840Sstevel@tonic-gate mdclrerror(ep); 15850Sstevel@tonic-gate return (METADEVADM_ERR); 15860Sstevel@tonic-gate } 15870Sstevel@tonic-gate local_sp = metasetname(MD_LOCAL_NAME, ep); 15880Sstevel@tonic-gate sideno = getmyside(sp, ep) + SKEW; 15890Sstevel@tonic-gate for (d = dd; d != NULL; d = d->dd_next) { 15900Sstevel@tonic-gate /* 15910Sstevel@tonic-gate * Actually do the check of the disks. 15920Sstevel@tonic-gate */ 15930Sstevel@tonic-gate ret = meta_upd_ctdnames(&local_sp, 0, sideno, 15940Sstevel@tonic-gate d->dd_dnp, &newname, ep); 15950Sstevel@tonic-gate 15960Sstevel@tonic-gate if ((ret == METADEVADM_ERR) || 15970Sstevel@tonic-gate (ret == METADEVADM_DSKNAME_ERR)) { 15980Sstevel@tonic-gate /* check failed in unknown manner */ 15990Sstevel@tonic-gate mda_debug("meta_upd_ctdnames failed\n"); 16000Sstevel@tonic-gate return (METADEVADM_ERR); 16010Sstevel@tonic-gate } 16020Sstevel@tonic-gate } 16030Sstevel@tonic-gate } 16040Sstevel@tonic-gate 16050Sstevel@tonic-gate /* do a reload of the devid namespace */ 16060Sstevel@tonic-gate ret = pathname_reload(&sp, setno, ep); 16070Sstevel@tonic-gate } else if (dev_options & DEV_UPDATE) { 16080Sstevel@tonic-gate pathname = getdiskname(diskname); 16090Sstevel@tonic-gate ret = devid_update(&sp, setno, pathname, ep); 16100Sstevel@tonic-gate free(pathname); 16110Sstevel@tonic-gate } 16120Sstevel@tonic-gate return (ret); 16130Sstevel@tonic-gate } 1614