zfs_fm.c revision 51ece83525fa18f5e72627610f480dffc7e492fd
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER START
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The contents of this file are subject to the terms of the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Common Development and Distribution License (the "License").
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You may not use this file except in compliance with the License.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * See the License for the specific language governing permissions
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * and limitations under the License.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * When distributing Covered Code, include this CDDL HEADER in each
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If applicable, add the following below this CDDL HEADER, with the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * fields enclosed by brackets "[]" replaced with your own identifying
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * information: Portions Copyright [yyyy] [name of copyright owner]
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER END
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Use is subject to license terms.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#pragma ident "%Z%%M% %I% %E% SMI"
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * This general routine is responsible for generating all the different ZFS
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ereports. The payload is dependent on the class, and which arguments are
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * supplied to the function:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * EREPORT POOL VDEV IO
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * block X X X
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * data X X
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * device X X
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * If we are in a loading state, all errors are chained together by the same
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SPA-wide ENA (Error Numeric Association).
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * For isolated I/O requests, we get the ENA from the zio_t. The propagation
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * gets very complicated due to RAID-Z, gang blocks, and vdev caching. We want
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * to chain together all ereports associated with a logical piece of data. For
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * read I/Os, there are basically three 'types' of I/O, which form a roughly
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * layered diagram:
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * +---------------+
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * | Aggregate I/O | No associated logical data or device
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * +---------------+
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * +---------------+ Reads associated with a piece of logical data.
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * | Read I/O | This includes reads on behalf of RAID-Z,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * +---------------+ mirrors, gang blocks, retries, etc.
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * +---------------+ Reads associated with a particular device, but
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * | Physical I/O | no logical data. Issued as part of vdev caching
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * +---------------+ and I/O aggregation.
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * Note that 'physical I/O' here is not the same terminology as used in the rest
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * of ZIO. Typically, 'physical I/O' simply means that there is no attached
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * blockpointer. But I/O with no associated block pointer can still be related
cbfb650a37bf2b1cd913645ee5ab0d1a13ef6246cp * to a logical piece of data (i.e. RAID-Z requests).
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * Purely physical I/O always have unique ENAs. They are not related to a
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * particular piece of logical data, and therefore cannot be chained together.
3db3f65c6274eb042354801a308c8e9bc4994553amw * We still generate an ereport, but the DE doesn't correlate it with any
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * logical piece of data. When such an I/O fails, the delegated I/O requests
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * will issue a retry, which will trigger the 'real' ereport with the correct
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * We keep track of the ENA for a ZIO chain through the 'io_logical' member.
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * When a new logical I/O is issued, we set this to point to itself. Child I/Os
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * then inherit this pointer, so that when it is first set subsequent failures
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * will use the same ENA. If a physical I/O is issued (by passing the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * ZIO_FLAG_NOBOOKMARK flag), then this pointer is reset, guaranteeing that a
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * unique ENA will be generated. For an aggregate I/O, this pointer is set to
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * NULL, and no ereport will be generated (since it doesn't actually correspond
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * to any particular device or piece of data).
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwzfs_ereport_post(const char *subclass, spa_t *spa, vdev_t *vd, zio_t *zio,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If we are doing a spa_tryimport(), ignore errors.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If we are in the middle of opening a pool, and the previous attempt
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * failed, don't bother logging any new ereports - we're just going to
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * get the same diagnosis anyway.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Ignore any errors from I/Os that we are going to retry
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * anyway - we only generate errors from the final failure.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Checksum errors are generated after the pipeline stage
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * responsible for retrying the I/O (VDEV_IO_ASSESS), so this
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * only applies to standard I/O errors.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If this is not a read or write zio, ignore the error. This
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * can occur if the DKIOCFLUSHWRITECACHE ioctl fails.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Ignore any errors from speculative I/Os, as failure is an
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * expected result.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If the vdev has already been marked as failing due to a
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * failed probe, then ignore any subsequent I/O errors, as the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * DE will automatically fault the vdev on the first such
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * failure.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Serialize ereport generation
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Determine the ENA to use for this event. If we are in a loading
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * state, use a SPA-wide ENA. Otherwise, if we are in an I/O state, use
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * a root zio-wide ENA. Otherwise, simply use a unique ENA.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Construct the full class, detector, and other standard FMA fields.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_fmri_zfs_set(detector, FM_ZFS_SCHEME_VERSION, spa_guid(spa),
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_ereport_set(ereport, FM_EREPORT_VERSION, class, ena, detector, NULL);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Construct the per-ereport payload, depending on which parameters are
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * passed in.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If we are importing a faulted pool, then we treat it like an open,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * not an import. Otherwise, the DE will ignore all faults during
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * import, since the default behavior is to mark the devices as
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * persistently unavailable, not leave them in the faulted state.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw state = spa->spa_import_faulted ? SPA_LOAD_OPEN : spa->spa_load_state;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Generic payload members common to all ereports.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The direct reference to spa_name is used rather than spa_name()
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * because of the asynchronous nature of the zio pipeline. spa_name()
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * asserts that the config lock is held in some form. This is always
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the case in I/O context, but because the check for RW_WRITER compares
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * against 'curthread', we may be in an asynchronous context and blow
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * this assert. Rather than loosen this assert, we acknowledge that all
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * contexts in which this function is called (pool open, I/O) are safe,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * and dereference the name directly.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DATA_TYPE_STRING, spa->spa_name, FM_EREPORT_PAYLOAD_ZFS_POOL_GUID,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_payload_set(ereport, FM_EREPORT_PAYLOAD_ZFS_POOL_FAILMODE,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw FM_EREPORT_FAILMODE_CONTINUE : FM_EREPORT_FAILMODE_PANIC,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_payload_set(ereport, FM_EREPORT_PAYLOAD_ZFS_VDEV_GUID,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Payload common to all I/Os.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If the 'size' parameter is non-zero, it indicates this is a
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * RAID-Z or other I/O where the physical offset and length are
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * provided for us, instead of within the zio_t.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Payload for I/Os with corresponding logical information.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If we have a vdev but no zio, this is a device fault, and the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 'stateoroffset' parameter indicates the previous state of the
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic void
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwzfs_post_common(spa_t *spa, vdev_t *vd, const char *name)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw (void) snprintf(class, sizeof (class), "%s.%s.%s", FM_RSRC_RESOURCE,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw VERIFY(nvlist_add_uint8(resource, FM_VERSION, FM_RSRC_VERSION) == 0);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw VERIFY(nvlist_add_string(resource, FM_CLASS, class) == 0);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The 'resource.fs.zfs.removed' event is an internal signal that the given vdev
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * has been removed from the system. This will cause the DE to ignore any
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * recent I/O errors, inferring that they are due to the asynchronous device
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * removal.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The 'resource.fs.zfs.autoreplace' event is an internal signal that the pool
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * has the 'autoreplace' property set, and therefore any broken vdevs will be
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * handled by higher level logic, and no vdev fault should be generated.