zio_inject.c revision 874395d5f8cae2b9cd2d1fcbfcfe963a0c23966d
312N/A * The contents of this file are subject to the terms of the 312N/A * Common Development and Distribution License (the "License"). 312N/A * You may not use this file except in compliance with the License. 312N/A * See the License for the specific language governing permissions 312N/A * and limitations under the License. 312N/A * When distributing Covered Code, include this CDDL HEADER in each 312N/A * If applicable, add the following below this CDDL HEADER, with the 312N/A * fields enclosed by brackets "[]" replaced with your own identifying 312N/A * information: Portions Copyright [yyyy] [name of copyright owner] 1639N/A * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 312N/A * Use is subject to license terms. 814N/A#
pragma ident "%Z%%M% %I% %E% SMI" 312N/A * To handle fault injection, we keep track of a series of zinject_record_t 623N/A * structures which describe which logical block(s) should be injected with a 312N/A * fault. These are kept in a global list. Each record corresponds to a given 312N/A * spa_t and maintains a special hold on the spa_t so that it cannot be deleted 844N/A * or exported while the injection record exists. 623N/A * Device level injection is done using the 'zi_guid' field. If this is set, it 312N/A * means that the error is destined for a particular device, not a piece of 312N/A * This is a rather poor data structure and algorithm, but we don't expect more 312N/A * than a few faults at any one time, so it should be sufficient for our needs. 623N/A * Returns true if the given record matches the I/O in progress. 312N/A * Check for a match against the MOS, which is based on type 312N/A * Check for an exact match. * Determine if the I/O in question should return failure. Returns the errno * to be returned to the caller. * Ignore I/O not associated with any logical data. * Currently, we only support fault injection on reads. /* Ignore errors not destined for this pool */ /* Ignore device errors */ /* If this handler matches, return EIO */ * For a failed open, pretend like the device * Create a new handler for the given record. We add it to the list, adding * a reference to the spa_t in the process. We increment zio_injection_enabled, * which is the switch to trigger all fault injection. * If this is pool-wide metadata, make sure we unload the corresponding * spa_t, so that the next attempt to load it will trigger the fault. * We call spa_reset() to unload the pool appropriately. * spa_inject_ref() will add an injection reference, which will * prevent the pool from being removed from the namespace while * still allowing it to be unloaded. * Flush the ARC, so that any attempts to read this data will end up * going to the ZIO layer. Note that this is a little overkill, but * we don't have the necessary ARC interfaces to do anything else, and * fault injection isn't a performance critical path. * Returns the next record with an ID greater than that supplied to the * function. Used to iterate over all handlers in the system. * Clear the fault handler with the given identifier, or return ENOENT if none