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) 1994, 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 * FUNCTION: meta_get_raid_names() 2N/A * INPUT: sp - the set name to get raid from 2N/A * options - options from the command line 2N/A * OUTPUT: nlpp - list of all raid names 2N/A * ep - return error pointer 2N/A * RETURNS: int - -1 if error, 0 success 2N/A * PURPOSE: returns a list of all raid in the metadb 2N/A * for all devices in the specified set 2N/A /* get miscname and unit */ 2N/A /* allocate columns */ 2N/A /* get common info */ 2N/A /* get columns, update unit state */ 2N/A /* get column name */ 2N/A /* override any start_blk */ 2N/A /* get hotspare name */ 2N/A "%s: suspected bad start block," 2N/A " seems labelled [raid]\n"),
2N/A "%s: suspected bad start block, " 2N/A " seems unlabelled [raid]\n"),
2N/A /* override any start_blk */ 2N/A /* get state, flags, and timestamp */ 2N/A /* get resync info */ 2N/A /* cleanup, return success */ 2N/A /* cleanup, return error */ 2N/A * check raid for dev 2N/A /* should be in the same set */ 2N/A /* look in columns */ 2N/A /* check same drive since metagetstart() can fail */ 2N/A /* return success */ 2N/A * check to see if we're in a raid 2N/A /* should have a set */ 2N/A /* cleanup, return success */ 2N/A /* check for soft partitions */ 2N/A /* make sure we have a disk */ 2N/A /* check to ensure that it is not already in use */ 2N/A /* make sure it is in the set */ 2N/A /* make sure its not in a metadevice */ 2N/A /* return success */ 2N/A /* print name and -r */ 2N/A * Print columns. Always print the full path. 2N/A /* terminate last line */ 2N/A /* cleanup, return error */ 2N/A /* No resyncing columns */ 2N/A * convert raid state to name 2N/A * If the device has a transient error state (due to it being DR'ed or 2N/A * failed) and there has been no I/O to it (the actual device is still 2N/A * marked as 'Okay') then we cannot know what the state is or what 2N/A * action to take on it. Therefore report the device as 'Unavailable'. 2N/A * A subsequent I/O to the device will cause the 'Okay' status to 2N/A * disappear if the device is actually gone and then we will print out 2N/A * the appropriate status. The MD_INACCESSIBLE state is only set 2N/A * on the raid when we open it or probe it. One the raid is open 2N/A * then we will just have regular error status on the device. 2N/A /* everything else */ 2N/A /* No erred columns */ 2N/A * convert raid state to repair action 2N/A /* first check for full init failure */ 2N/A /* replace errored or init errored raid column */ 2N/A /* get column with error */ 2N/A "metareplace %s%s %s <%s>",
2N/A /* replace last errored raid column */ 2N/A "metareplace %s %s %s <%s>",
2N/A * get printable raid column state 2N/A /* everything else */ 2N/A * if top_tstate is set, that implies that you have 2N/A * a ctd type device with an unavailable metadevice 2N/A * on top of it. If so, print a - for it's state 2N/A /* populate the key in the name_p structure */ 2N/A /* determine if devid does NOT exist */ 2N/A * Building a format string on the fly that will 2N/A * be used in (f)printf. This allows the length 2N/A * of the ctd to vary from small to large without 2N/A "\t%-*.*s %8lld %5.5s %12.12s %5.5s %s\n",
2N/A "\t%-*s %5lld %-5s %-11s %-5s %-9s %s\n",
2N/A /* cleanup, return error */ 2N/A * print raid options 2N/A /* cleanup, return error */ 2N/A * Display recovery action if we're marked in the Unavailable state. 2N/A /* print what to do */ 2N/A " Invoke: %s\n"), p) ==
EOF) {
2N/A " Resync in progress: %2d.%1d%% done\n"),
2N/A " Initialization in progress: %2d.%1d%% " 2N/A " Parity regeneration in progress: %2d.%1d%% " 2N/A /* print hotspare pool */ 2N/A /* print interlace */ 2N/A /* MD_DEBUG stuff */ 2N/A /* get additional info */ 2N/A /* print prewrite count and size */ 2N/A " Prewrite Count: %u slots\n"),
2N/A " Prewrite Slot Size: %u blocks\n"),
2N/A " Prewrite Total Size: %u blocks\n"),
2N/A /* print original devices */ 2N/A * Building a format string on the fly that will 2N/A * be used in (f)printf. This allows the length 2N/A * of the ctd to vary from small to large without 2N/A "\t%-*.*s %-12.12s %-5.5s %12.12s %-5.5s %s\n",
2N/A "\t%-*s %5s %-5s %-11s %-5s %-9s %s\n",
2N/A /* print concatenated devices */ 2N/A "Concatenated Devices:\n")) ==
EOF) {
2N/A " Size: %lld blocks (%s)\n"),
2N/A * This allows the length 2N/A * of the ctd to vary from small to large without 2N/A "\t%-*.*s %-12.12s %-5.5s %-12.12s %5.5s %s\n",
2N/A "\t%-*s %5s %-5s %-11s %-9s %s\t%s\n",
2N/A /* add extra line */ 2N/A /* cleanup, return error */ 2N/A /* should have same set */ 2N/A /* print all raids */ 2N/A /* cleanup, return success */ 2N/A /* get unit structure */ 2N/A /* check for parented */ 2N/A /* print appropriate detail */ 2N/A /* Recurse on components that are metadevices */ 2N/A * adjust raid geometry 2N/A /* get reinstructs */ 2N/A /* adjust geometry */ 2N/A /* return success */ 2N/A * add another column to the raid unit structure 2N/A /* setup state and timestamp */ 2N/A /* get start, size, and maxio */ 2N/A /* adjust start and size by prewrite */ 2N/A /* make sure we still have something left */ 2N/A /* store name in namespace */ 2N/A /* add the size (we use) of the device to the total */ 2N/A /* adjust geometry */ 2N/A /* return success */ 2N/A * invalidate column names 2N/A * attach columns to raid 2N/A /* should have a set */ 2N/A /* check and count new columns */ 2N/A /* check against existing devices */ 2N/A /* check against ourselves */ 2N/A * calculate the size needed for the new raid unit and allocate 2N/A * the appropriate structure. allocate new unit. 2N/A /* We always want a do-it, this is for attach_raid_col below */ 2N/A /* build new unit structure */ 2N/A "%s: component is attached\n"),
2N/A "%s: components are attached\n"),
2N/A /* grow any parents */ 2N/A /* cleanup, return error */ 2N/A * get raid parameters 2N/A /* should have a set */ 2N/A /* return parameters */ 2N/A * set raid parameters 2N/A /* should have a set */ 2N/A /* set parameters */ 2N/A /* return success */ 2N/A * validate raid replace column 2N/A /* cleanup, return error */ 2N/A * replace raid column 2N/A /* should have same set */ 2N/A /* save new binding incase this is a rebind where oldnp==newnp */ 2N/A /* invalidate, then get the raid (fill in oldnp from metadb) */ 2N/A /* can't replace a component if the raid inaccessible */ 2N/A /* the old device binding is now established */ 2N/A /* setup raid info */ 2N/A * Save a copy of the devid associated with the new disk, the 2N/A * reason is that the checks for the column (meta_check_column) 2N/A * via validate_new_raid(), could cause the disk's devid to be 2N/A * changed to that of the devid that is currently stored in the 2N/A * replica namespace for the disk in question. This devid could 2N/A * be stale if we are replacing the disk. The actual function 2N/A * that overwrites the devid is dr2drivedesc(). 2N/A /* don't setup new_devid if no devids */ 2N/A /* check out new (sets up start_blk, has_label, number_blks) */ 2N/A * Copy back the saved devid. 2N/A /* store name in namespace, allocate new key */ 2N/A * We are 'rebind'ing a disk that is in a diskset so as well 2N/A * as updating the diskset's namespace the local set needs 2N/A * to be updated because it also contains a reference to the 2N/A /* replace column */ 2N/A "%s: device %s is replaced with %s\n"),
2N/A /* return success */ 2N/A * enable raid column 2N/A /* should have same set */ 2N/A /* get the file_system dev binding */ 2N/A /* get the raid unit (fill in colnp->dev with metadb version) */ 2N/A /* enabling a component can't work if the raid inaccessible */ 2N/A /* the metadb device binding is now established */ 2N/A * check for the case where the dev_t has changed between the 2N/A * filesystem and the metadb. This is called a rebind, and 2N/A * is handled by meta_raid_replace. 2N/A * Save the devt of mddb version 2N/A /* establish file system binding with invalid start/end */ 2N/A * Don't do it if meta_raid_replace returns an error 2N/A /* setup raid info */ 2N/A * are we dealing with a non-local set? If so need to update the 2N/A * local namespace so that the disk record has the correct devid. 2N/A * Failed to update the local set. Nothing to do here 2N/A * apart from report the error. The namespace is 2N/A * most likely broken and some form of remedial 2N/A * recovery is going to be required. 2N/A "%s: device %s is enabled\n"),
2N/A /* return success */ 2N/A * check for dups in the raid itself 2N/A * default raid interlace 2N/A /* default to 512k, round up if necessary */ 2N/A * convert interlaces 2N/A /* compute default interlace */ 2N/A /* check interlace */ 2N/A /* check hotspare pool name */ 2N/A /* check this raid too */ 2N/A /* return success */ 2N/A * setup raid geometry 2N/A /* get worst reinstructs */ 2N/A /* setup geometry from first column */ 2N/A /* return success */ 2N/A * validate that a raid device being created with the -k flag is a real 2N/A * If our raid device is a 64 bit device, we can accept the 2N/A * pw header we just read in. 2N/A * Otherwise it's of type raid_pwhdr32_od_t and has to 2N/A /* 4.1 prewrite header */ 2N/A * this is an old prewrite header (4.0) the unit structure 2N/A * will have to be trusted. 2N/A /* allocate raid unit */ 2N/A * initialize the top level mr_unit_t structure 2N/A * setup the unit state to indicate whether to retain 2N/A * any data currently on the metadevice or to clear it 2N/A * setup original columns, saving start_block and 2N/A * finding smallest size and maxio 2N/A /* setup creation time */ 2N/A /* get start, size, and maxio */ 2N/A /* store name in namespace */ 2N/A /* adjust for smallest disk */ 2N/A * before processing any of the attached column(s) 2N/A * set up the composition of the metadevice for column 2N/A * sizes and pre-write information 2N/A /* now calculate the number of segments per column */ 2N/A * adjust the pw_cnt, pw_size, to fit into any fragmentation 2N/A * left over after column_size has been computed 2N/A * calculate the actual block count available based on the 2N/A * segment size and the number of segments per column ... 2N/A * ... and adjust for the number of parity segments 2N/A * now calculate the pre-write offset and update the column 2N/A * structures to include the address of the individual pre-write 2N/A /* adjust start and size by prewrite */ 2N/A /* make sure we still have something left */ 2N/A /* do concat cols */ 2N/A /* fill in the size of the raid */ 2N/A /* if we're not doing anything, return success */ 2N/A /* did the user tell us to generate a large device? */ 2N/A /* cleanup, return success */ 2N/A * NOTE: this functions is metainit(1m)'s command line parser! 2N/A * Raid metadevice not allowed on multi-node diskset. 2N/A /* see if it exists already */ 2N/A /* parse general options */ 2N/A /* allocate and parse cols */ 2N/A /* parse column name */ 2N/A /* check for soft partitions */ 2N/A /* parse raid options */ 2N/A * Get out if the specified hotspare pool really 2N/A /* we should be at the end */ 2N/A /* default to all original columns */ 2N/A /* cleanup, return error */ 2N/A /* should have same set */ 2N/A /* reset all raids */ 2N/A /* cleanup, return success */ 2N/A /* get unit structure */ 2N/A /* make sure nobody owns us */ 2N/A /* clear subdevices cache */ 2N/A /* clear metadevice */ 2N/A /* clear subdevices */ 2N/A /* only recurse on metadevices */ 2N/A /* cleanup, return success */ 2N/A * reports TRUE if any RAID component is in error 2N/A * regen parity on a raid 2N/A /* should have a set */ 2N/A /* make sure we have a raid */ 2N/A /* return success */ 2N/A /* get count of underlying devices */ 2N/A * Now get the data from the unit structure. 2N/A * The compnamep stuff contains the data from 2N/A * the namespace and we need the un_dev 2N/A * from the unit structure. 2N/A /* Get the devname from the name space. */ 2N/A * The minor numbers are different. Update 2N/A * the namespace with the information from 2N/A }
/* End of if (mydevs == mydev[i]) */ 2N/A }
/* end of for loop */