zfs_fm.c revision 51ece83525fa18f5e72627610f480dffc7e492fd
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER START
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
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 *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * or http://www.opensolaris.org/os/licensing.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * See the License for the specific language governing permissions
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * and limitations under the License.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
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 *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * CDDL HEADER END
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Use is subject to license terms.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#pragma ident "%Z%%M% %I% %E% SMI"
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#include <sys/spa.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#include <sys/spa_impl.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#include <sys/vdev.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#include <sys/vdev_impl.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#include <sys/zio.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#include <sys/fm/fs/zfs.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#include <sys/fm/protocol.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#include <sys/fm/util.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#include <sys/sysevent.h>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
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 *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * EREPORT POOL VDEV IO
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * block X X X
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * data X X
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * device X X
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * pool X
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
faa1795a28a5c712eed6d0a3f84d98c368a316c6jb * If we are in a loading state, all errors are chained together by the same
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SPA-wide ENA (Error Numeric Association).
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
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 *
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * +---------------+
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * | Aggregate I/O | No associated logical data or device
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * +---------------+
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * |
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * V
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 * |
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as * V
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.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
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 *
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 * ENA.
dc20a3024900c47dd2ee44b9707e6df38f7d62a5as *
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).
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwvoid
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwzfs_ereport_post(const char *subclass, spa_t *spa, vdev_t *vd, zio_t *zio,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint64_t stateoroffset, uint64_t size)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#ifdef _KERNEL
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw nvlist_t *ereport, *detector;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint64_t ena;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw char class[64];
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int state;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If we are doing a spa_tryimport(), ignore errors.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (spa->spa_load_state == SPA_LOAD_TRYIMPORT)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
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 */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (spa->spa_load_state != SPA_LOAD_NONE &&
3db3f65c6274eb042354801a308c8e9bc4994553amw spa->spa_last_open_failed)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (zio != NULL) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
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 */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (zio_should_retry(zio) && zio->io_error != ECKSUM)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If this is not a read or write zio, ignore the error. This
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * can occur if the DKIOCFLUSHWRITECACHE ioctl fails.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (zio->io_type != ZIO_TYPE_READ &&
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw zio->io_type != ZIO_TYPE_WRITE)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Ignore any errors from speculative I/Os, as failure is an
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * expected result.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (zio->io_flags & ZIO_FLAG_SPECULATIVE)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
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 */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (vd != NULL && vd->vdev_is_failing &&
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw strcmp(subclass, FM_EREPORT_ZFS_PROBE_FAILURE) != 0)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if ((ereport = fm_nvlist_create(NULL)) == NULL)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if ((detector = fm_nvlist_create(NULL)) == NULL) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_nvlist_destroy(ereport, FM_NVA_FREE);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Serialize ereport generation
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_enter(&spa->spa_errlist_lock);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
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 */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (spa->spa_load_state != SPA_LOAD_NONE) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (spa->spa_ena == 0)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw spa->spa_ena = fm_ena_generate(0, FM_ENA_FMT1);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ena = spa->spa_ena;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw } else if (zio != NULL && zio->io_logical != NULL) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (zio->io_logical->io_ena == 0)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw zio->io_logical->io_ena =
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_ena_generate(0, FM_ENA_FMT1);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ena = zio->io_logical->io_ena;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw } else {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ena = fm_ena_generate(0, FM_ENA_FMT1);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Construct the full class, detector, and other standard FMA fields.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw (void) snprintf(class, sizeof (class), "%s.%s",
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ZFS_ERROR_CLASS, subclass);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_fmri_zfs_set(detector, FM_ZFS_SCHEME_VERSION, spa_guid(spa),
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw vd != NULL ? vd->vdev_guid : 0);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_ereport_set(ereport, FM_EREPORT_VERSION, class, ena, detector, NULL);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Construct the per-ereport payload, depending on which parameters are
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * passed in.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
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.
3db3f65c6274eb042354801a308c8e9bc4994553amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw state = spa->spa_import_faulted ? SPA_LOAD_OPEN : spa->spa_load_state;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Generic payload members common to all ereports.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
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 */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_payload_set(ereport, FM_EREPORT_PAYLOAD_ZFS_POOL,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DATA_TYPE_STRING, spa->spa_name, FM_EREPORT_PAYLOAD_ZFS_POOL_GUID,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DATA_TYPE_UINT64, spa_guid(spa),
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw FM_EREPORT_PAYLOAD_ZFS_POOL_CONTEXT, DATA_TYPE_INT32,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw state, NULL);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (spa != NULL) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_payload_set(ereport, FM_EREPORT_PAYLOAD_ZFS_POOL_FAILMODE,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DATA_TYPE_STRING,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw spa_get_failmode(spa) == ZIO_FAILURE_MODE_WAIT ?
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw FM_EREPORT_FAILMODE_WAIT :
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw spa_get_failmode(spa) == ZIO_FAILURE_MODE_CONTINUE ?
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw FM_EREPORT_FAILMODE_CONTINUE : FM_EREPORT_FAILMODE_PANIC,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw NULL);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (vd != NULL) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw vdev_t *pvd = vd->vdev_parent;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_payload_set(ereport, FM_EREPORT_PAYLOAD_ZFS_VDEV_GUID,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DATA_TYPE_UINT64, vd->vdev_guid,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw FM_EREPORT_PAYLOAD_ZFS_VDEV_TYPE,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DATA_TYPE_STRING, vd->vdev_ops->vdev_op_type, NULL);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (vd->vdev_path)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_payload_set(ereport,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw FM_EREPORT_PAYLOAD_ZFS_VDEV_PATH,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DATA_TYPE_STRING, vd->vdev_path, NULL);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (vd->vdev_devid)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_payload_set(ereport,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw FM_EREPORT_PAYLOAD_ZFS_VDEV_DEVID,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DATA_TYPE_STRING, vd->vdev_devid, NULL);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (pvd != NULL) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_payload_set(ereport,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw FM_EREPORT_PAYLOAD_ZFS_PARENT_GUID,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DATA_TYPE_UINT64, pvd->vdev_guid,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw FM_EREPORT_PAYLOAD_ZFS_PARENT_TYPE,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DATA_TYPE_STRING, pvd->vdev_ops->vdev_op_type,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw NULL);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (pvd->vdev_path)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_payload_set(ereport,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw FM_EREPORT_PAYLOAD_ZFS_PARENT_PATH,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DATA_TYPE_STRING, pvd->vdev_path, NULL);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (pvd->vdev_devid)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_payload_set(ereport,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw FM_EREPORT_PAYLOAD_ZFS_PARENT_DEVID,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DATA_TYPE_STRING, pvd->vdev_devid, NULL);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (zio != NULL) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Payload common to all I/Os.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_payload_set(ereport, FM_EREPORT_PAYLOAD_ZFS_ZIO_ERR,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DATA_TYPE_INT32, zio->io_error, NULL);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
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 */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (vd != NULL) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (size)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_payload_set(ereport,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw FM_EREPORT_PAYLOAD_ZFS_ZIO_OFFSET,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DATA_TYPE_UINT64, stateoroffset,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw FM_EREPORT_PAYLOAD_ZFS_ZIO_SIZE,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DATA_TYPE_UINT64, size, NULL);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw else
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_payload_set(ereport,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw FM_EREPORT_PAYLOAD_ZFS_ZIO_OFFSET,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DATA_TYPE_UINT64, zio->io_offset,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw FM_EREPORT_PAYLOAD_ZFS_ZIO_SIZE,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DATA_TYPE_UINT64, zio->io_size, NULL);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Payload for I/Os with corresponding logical information.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (zio->io_logical != NULL)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_payload_set(ereport,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw FM_EREPORT_PAYLOAD_ZFS_ZIO_OBJSET,
3db3f65c6274eb042354801a308c8e9bc4994553amw DATA_TYPE_UINT64,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw zio->io_logical->io_bookmark.zb_objset,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw FM_EREPORT_PAYLOAD_ZFS_ZIO_OBJECT,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DATA_TYPE_UINT64,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw zio->io_logical->io_bookmark.zb_object,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw FM_EREPORT_PAYLOAD_ZFS_ZIO_LEVEL,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DATA_TYPE_INT64,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw zio->io_logical->io_bookmark.zb_level,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw FM_EREPORT_PAYLOAD_ZFS_ZIO_BLKID,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DATA_TYPE_UINT64,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw zio->io_logical->io_bookmark.zb_blkid, NULL);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw } else if (vd != NULL) {
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
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
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * vdev.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_payload_set(ereport,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw FM_EREPORT_PAYLOAD_ZFS_PREV_STATE,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw DATA_TYPE_UINT64, stateoroffset, NULL);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw }
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw mutex_exit(&spa->spa_errlist_lock);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_ereport_post(ereport, EVCH_SLEEP);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_nvlist_destroy(ereport, FM_NVA_FREE);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_nvlist_destroy(detector, FM_NVA_FREE);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#endif
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic void
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwzfs_post_common(spa_t *spa, vdev_t *vd, const char *name)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#ifdef _KERNEL
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw nvlist_t *resource;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw char class[64];
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if ((resource = fm_nvlist_create(NULL)) == NULL)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw (void) snprintf(class, sizeof (class), "%s.%s.%s", FM_RSRC_RESOURCE,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw ZFS_ERROR_CLASS, name);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw VERIFY(nvlist_add_uint8(resource, FM_VERSION, FM_RSRC_VERSION) == 0);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw VERIFY(nvlist_add_string(resource, FM_CLASS, class) == 0);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw VERIFY(nvlist_add_uint64(resource,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw FM_EREPORT_PAYLOAD_ZFS_POOL_GUID, spa_guid(spa)) == 0);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw if (vd)
3db3f65c6274eb042354801a308c8e9bc4994553amw VERIFY(nvlist_add_uint64(resource,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw FM_EREPORT_PAYLOAD_ZFS_VDEV_GUID, vd->vdev_guid) == 0);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_ereport_post(resource, EVCH_SLEEP);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw fm_nvlist_destroy(resource, FM_NVA_FREE);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw#endif
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
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 */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwvoid
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwzfs_post_remove(spa_t *spa, vdev_t *vd)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw zfs_post_common(spa, vd, FM_RESOURCE_REMOVED);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
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.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwvoid
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwzfs_post_autoreplace(spa_t *spa, vdev_t *vd)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw zfs_post_common(spa, vd, FM_RESOURCE_AUTOREPLACE);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw}
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw