2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 2N/A * Just in case we're not in a build environment, make sure that 2N/A * TEXT_DOMAIN gets set to something. 2N/A * A table of the supported path types - this should ideally be generated 2N/A/* indicate whether to print an error message or not */ 2N/A * Debug function: to turn on devadm function debugging include DEVADM 2N/A * in the MD_DEBUG enviroment variable: MD_DEBUG=...,DEVADM... 2N/A/* print error messages to the terminal or syslog */ 2N/A * The program is a daemon in the sense that it 2N/A * is a system utility. 2N/A * Utility to find the correct options to use for the devid search 2N/A * based upon the path of the device. 2N/A * -1 Error, the path passed in is not in the table 2N/A * >= 0 The element number for the options within the table 2N/A * Utility to get the path of a device 2N/A * meta_update_devtree -- Update the /dev/md namespace for metadevices. 2N/A * Only update the specific link if a valid minor(not NODEV) is given. 2N/A * Otherwise, update the entire /dev/md . 2N/A * di_devlink_init() returns once the /dev links have been 2N/A * updated(created or removed). If di_devlink_init returns 2N/A * a NULL, the link operation failed. 2N/A * Use the enhanced di_devlink_init interface if the mnum 2N/A * NOTE: This will take a _long_ time for large numbers 2N/A /* Call di_devlink_init twice, for block and raw devices */ 2N/A * update_locator_namespace -- Contains the ioctl call that will update 2N/A * the ctds and pathname (ie. /dev/dsk etc) within the 2N/A * locator block namespace. 2N/A * METADEVADM_ERR ioctl failed and ep is updated with the error 2N/A * METADEVADM_SUCCESS success 2N/A * meta_update_namespace -- Contains the ioctl call that will update the 2N/A * device name and pathname in the namespace area. 2N/A * METADEVADM_ERR ioctl failed and ep is updated with the error 2N/A * METADEVADM_SUCCESS success 2N/A * stripS - Strip s<digits> off the end of the ctds name if it exists 2N/A /* gobble number and 's' */ 2N/A * getdiskname -- to be used when scanning the input from the -u arg. 2N/A * This routine will strip off input that is anything but cxtxdx. 2N/A * ie. it will call stripS to get rid of slice info. Will also 2N/A * string that has the disk name in it ie. c0t0d0 2N/A /* regular device */ 2N/A * has_devid -- return the device ID for a given key 2N/A * devid devid found that corresponds to the given key. 2N/A * Go through the existing list of replicas and check to see 2N/A * if their disk has moved, if so update the replica list 2N/A * Failed to find the disk, nothing can be done. 2N/A * The replica will be marked as bad later. 2N/A * Check to see if the returned disk matches the stored one 2N/A * break out if some sort of match is found because 2N/A * we already match on the devid. 2N/A /* No match found - use the first entry in disklist */ 2N/A "Disk movement detected\n"));
2N/A "Updating device names in Solaris Volume " 2N/A "Failed to encode the devid\n"));
2N/A "%s changed to %s from device relocation " 2N/A "information %s\n"),
2N/A "Failed to update locator " 2N/A "namespace on change from %s " 2N/A * pathname_reload - main function for the -r option. Will reload the 2N/A * pathname in both the main namespace and the locator namespace. 2N/A * Also, checks both areas for invalid device ID's and prints them 2N/A * If the set is a multi-node diskset that means there are no devid's 2N/A * METADEVADM_ERR error 2N/A * METADEVADM_SUCCESS success 2N/A * METADEVADM_DEVIDINVALID success, but invalid devids detected 2N/A * Get the entry of the namespace via the key. To do this 2N/A * call MD_IOCNXTKEY until no more. 2N/A * For each entry in the namespace we want to check 2N/A * for devid and update 2N/A /* failed to find this node in the set */ 2N/A /* look at each key in the namespace */ 2N/A /* no more entries */ 2N/A * get the nm entry using the key. Then check to see if 2N/A * there's a devid associated with this entry 2N/A * If not, go onto next key. 2N/A /* metadevices do not have devid's in them */ 2N/A /* Clear error if no devid and go to next nm entry */ 2N/A * In theory this is impossible because if the 2N/A * devidp is non-null then the minor_name has 2N/A * already been looked up. 2N/A * If there is a devid then we have a real device that 2N/A * Find the search path that should be used. This is an 2N/A * optimization to try and prevent a search for the complete 2N/A /* now look for the disk name using the devid */ 2N/A * Failed to find the disk 2N/A * Check to see if the returned disk matches the stored one 2N/A /* No match found - use the first entry in disklist */ 2N/A "Disk movement detected\n"));
2N/A "Updating device names in " 2N/A "Solaris Volume Manager\n"));
2N/A "%s changed to %s from device relocation " 2N/A "information %s\n"),
2N/A /* need to build up the path of the disk */ 2N/A /* Something has changed so update the namespace */ 2N/A "Failed to update namespace on " 2N/A "change from %s to %s\n"),
2N/A * check for invalid device id's 2N/A /* get count of number of invalid device id's */ 2N/A * we have some invalid device id's so we need to 2N/A /* malloc buffer for kernel to place devid list into */ 2N/A /* get actual list of invalid device id's */ 2N/A /* print out the invalid devid's */ 2N/A "Invalid device relocation information " 2N/A "detected in Solaris Volume Manager\n"));
2N/A "Please check the status of the following disk(s):\n"));
2N/A * replica_update_devid - cycle through the replica list, rlp, and 2N/A * update the device ids on all of the replicas that are on the 2N/A * device specified by lp. A side effect is to update the value of 2N/A * cdevidpp to contain the character representation of the device 2N/A * id before updating if it is not already set. 2N/A * METADEVADM_ERR error 2N/A * METADEVADM_SUCCESS success 2N/A /* failed to encode the devid */ 2N/A /* search replica list for give ctd name */ 2N/A /* found the replica, now grab the devid */ 2N/A "Updating replica %s of set number %d from " 2N/A "device id %s to device id %s\n"),
2N/A * call into kernel to update lb 2N/A * namespace device id 2N/A * devid_update -- main routine for the -u option. Will update both the 2N/A * namespace and the locator block with the correct devid for the 2N/A * METADEVADM_ERR error 2N/A * METADEVADM_SUCCESS success 2N/A /* failed to find this node in the set */ 2N/A * Disk does not have a devid! So cannot update the 2N/A * devid within the replica. 2N/A "%s does not have a device id. Cannot update " 2N/A "device id if none exists\n"),
ctd);
2N/A * Check if we own the set, if we do then do some processing 2N/A /* get the replicas */ 2N/A /* update the devids in the replicas if necessary */ 2N/A * If this is not the LOCAL set then need to update the LOCAL 2N/A * replica with the new disk record. 2N/A * Need to find the disk record within the set and then 2N/A /* no disks in the set - no point continuing */ 2N/A /* failed to finddisk in the set */ 2N/A "%s not found in set %s. Check your syntax\n"),
2N/A * Now figure out the correct slice, for a diskset the slice 2N/A * we care about is always the 'replica' slice. 2N/A * Now update the devid entry as well, this works 2N/A * correctly because the prior call to 2N/A * meta_update_namespace() above puts the correct dev_t 2N/A * in the namespace which will then be resolved 2N/A * to the new devid by the ioctl now called. 2N/A * Only want to update the local set so do not continue. 2N/A * Iterate through all of the metadevices looking for the 2N/A * passed in ctd. If found then update the devid 2N/A /* search each namespace entry */ 2N/A "%s not found in set %s. Check your " 2N/A "%s not found in local set. " 2N/A * found disk, does it have a devid within the namespace ? 2N/A * It might not because it does not support devid's or was 2N/A * put into the namespace when there was no devid support 2N/A "SVM has no device id for " 2N/A "%s, cannot update.\n"),
2N/A continue;
/* no devid. go on to next */ 2N/A * has devid so update namespace, note the key has been set 2N/A * by the prior MD_IOCNXTKEY_NM ioctl. 2N/A * The call below may fail if the -u option is being 2N/A * used to update a disk that has been replaced. 2N/A * The -u option to metadevadm should not be used 2N/A * for this purpose because we trust the dev_t of 2N/A * the device in the replica and if we have replaced 2N/A * the device and it is a fibre one then the dev_t 2N/A * will have changed. This means we end up looking for 2N/A * the devid of a non-existant disk and we subsequently 2N/A * fail with NODEVID. 2N/A "SVM failed to update the device " 2N/A "id for %s probably due to both " 2N/A "devt and device id changing.\n"),
2N/A "Updating Solaris Volume Manager device relocation " 2N/A "information for %s\n"),
ctd);
2N/A "insufficient memory, device Reloc info not " 2N/A "Open of %s failed\n"),
fp);
2N/A "Close of %s failed\n"),
fp);
2N/A "Unable to obtain device " 2N/A "Reloc info for %s\n"),
fp);
2N/A "device Reloc info for %s\n"),
fp);
2N/A * Check the ctd name of the disk to see if the disk has moved. If it 2N/A * has moved then the newname is returned in 'newname', it is up to 2N/A * the caller to free the memory associated with it. 2N/A * METADEVADM_ERR error 2N/A * METADEVADM_SUCCESS success 2N/A * METADEVADM_DISKMOVE success, and the disk has moved 2N/A * METADEVADM_DSKNAME_ERR error creating the disk name structures. 2N/A /* no devid, nothing can be done */ 2N/A "%s has no devid, cannot detect " 2N/A * Find the correct side name for the disk. There is a sidename 2N/A * for each host associated with the diskset. 2N/A mda_debug(
"meta_upd_ctdnames: %s %d args: setno %d sideno %d\n",
2N/A * Only use SKEW for the local replica and for traditional 2N/A * Failed to find the side name, this should not 2N/A * be possible. However if it does happen this is an 2N/A * indication of an inconsistant replica - something 2N/A * might have gone wrong during an add or a delete of 2N/A mda_debug(
"Unable to find the side information for disk %s\n",
2N/A * Find the type of device we are to be searching on 2N/A mda_debug(
"Side name: sideno: %d dname: %s cname: %s minor: %lx\n",
2N/A * Get the devname from the name space. 2N/A * Failed to encode the devid. 2N/A * Use the stored devid to find the existing device node and check 2N/A * to see if the disk has moved. Use the raw devices as the name 2N/A * of the disk is stored as the raw device, if this is not done 2N/A * then the disk will not be found. 2N/A "Device ID %s last associated with " 2N/A "disk %s no longer found in system\n"),
2N/A * Check to see if the returned disk matches the stored one 2N/A /* No match found - use the first entry in disklist */ 2N/A /* did not match on the dev, so dev_t has changed */ 2N/A * If here, then the name in the disklist is the one we 2N/A * want in any case so use it. 2N/A * Need to remove the slice as metadrivename() expects a diskname 2N/A * Build an mddrivename_t to use 2N/A * Need to find the correct slice used for the replica 2N/A /* get the block path */ 2N/A /* finished with the list so return the memory */ 2N/A /* finished with the list so return the memory */ 2N/A * If it's not the local set we need to check the local 2N/A * namespace to see if disks have moved as it contains 2N/A * entries for the disks in the set. 2N/A * Only add a SKEW to traditional disksets because 2N/A * multi-owner disksets use the node id for the side. 2N/A * Actually do the check of the disks. 2N/A /* check failed in unknown manner */ 2N/A /* do a reload of the devid namespace */