ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * CDDL HEADER START
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * The contents of this file are subject to the terms of the
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Common Development and Distribution License (the "License").
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * You may not use this file except in compliance with the License.
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * See the License for the specific language governing permissions
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * and limitations under the License.
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * When distributing Covered Code, include this CDDL HEADER in each
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * If applicable, add the following below this CDDL HEADER, with the
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * fields enclosed by brackets "[]" replaced with your own identifying
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * information: Portions Copyright [yyyy] [name of copyright owner]
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * CDDL HEADER END
6809eb4e2a4a94bcc76229c7b5108b96134537b6Eric Schrock * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Use is subject to license terms.
cd0837cc943a814d8b2e7ff44d61265f67220f66George Wilson * Copyright (c) 2012 by Delphix. All rights reserved.
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * This general routine is responsible for generating all the different ZFS
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * ereports. The payload is dependent on the class, and which arguments are
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * supplied to the function:
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * EREPORT POOL VDEV IO
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * block X X X
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * device X X
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * If we are in a loading state, all errors are chained together by the same
32b87932f3ef0887d873b7f6d2d1943799b2afc0ek * SPA-wide ENA (Error Numeric Association).
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * For isolated I/O requests, we get the ENA from the zio_t. The propagation
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * gets very complicated due to RAID-Z, gang blocks, and vdev caching. We want
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * to chain together all ereports associated with a logical piece of data. For
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * read I/Os, there are basically three 'types' of I/O, which form a roughly
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * layered diagram:
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * +---------------+
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * | Aggregate I/O | No associated logical data or device
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * +---------------+
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * +---------------+ Reads associated with a piece of logical data.
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * | Read I/O | This includes reads on behalf of RAID-Z,
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * +---------------+ mirrors, gang blocks, retries, etc.
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * +---------------+ Reads associated with a particular device, but
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * | Physical I/O | no logical data. Issued as part of vdev caching
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * +---------------+ and I/O aggregation.
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Note that 'physical I/O' here is not the same terminology as used in the rest
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * of ZIO. Typically, 'physical I/O' simply means that there is no attached
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * blockpointer. But I/O with no associated block pointer can still be related
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * to a logical piece of data (i.e. RAID-Z requests).
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Purely physical I/O always have unique ENAs. They are not related to a
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * particular piece of logical data, and therefore cannot be chained together.
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * We still generate an ereport, but the DE doesn't correlate it with any
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * logical piece of data. When such an I/O fails, the delegated I/O requests
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * will issue a retry, which will trigger the 'real' ereport with the correct
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * We keep track of the ENA for a ZIO chain through the 'io_logical' member.
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * When a new logical I/O is issued, we set this to point to itself. Child I/Os
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * then inherit this pointer, so that when it is first set subsequent failures
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick * will use the same ENA. For vdev cache fill and queue aggregation I/O,
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick * this pointer is set to NULL, and no ereport will be generated (since it
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick * doesn't actually correspond to any particular device or piece of data,
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick * and the caller will always retry without caching or queueing anyway).
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams * For checksum errors, we want to include more information about the actual
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams * error which occurs. Accordingly, we build an ereport when the error is
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams * noticed, but instead of sending it in immediately, we hang it off of the
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams * io_cksum_report field of the logical IO. When the logical IO completes
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams * (successfully or not), zfs_ereport_finish_checksum() is called with the
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams * good and bad versions of the buffer (if available), and we annotate the
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams * ereport with information about the differences.
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adamszfs_ereport_start(nvlist_t **ereport_out, nvlist_t **detector_out,
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams const char *subclass, spa_t *spa, vdev_t *vd, zio_t *zio,
468c413a79615e77179e8d98f22a7e513a8135bdTim Haley * If we are doing a spa_tryimport() or in recovery mode,
468c413a79615e77179e8d98f22a7e513a8135bdTim Haley * ignore errors.
b16da2e29e074fb6eaeadc4fd7d17ae7340ba240George Wilson if (spa_load_state(spa) == SPA_LOAD_TRYIMPORT ||
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * If we are in the middle of opening a pool, and the previous attempt
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * failed, don't bother logging any new ereports - we're just going to
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * get the same diagnosis anyway.
bf82a41b568b2bd31bf9814587eb25ee2e7b05ffeschrock * If this is not a read or write zio, ignore the error. This
bf82a41b568b2bd31bf9814587eb25ee2e7b05ffeschrock * can occur if the DKIOCFLUSHWRITECACHE ioctl fails.
bf82a41b568b2bd31bf9814587eb25ee2e7b05ffeschrock * Ignore any errors from speculative I/Os, as failure is an
bf82a41b568b2bd31bf9814587eb25ee2e7b05ffeschrock * expected result.
8956713aded83a741173fcd4f9ef1c83521fbea9Eric Schrock * If this I/O is not a retry I/O, don't post an ereport.
8956713aded83a741173fcd4f9ef1c83521fbea9Eric Schrock * Otherwise, we risk making bad diagnoses based on B_FAILFAST
6809eb4e2a4a94bcc76229c7b5108b96134537b6Eric Schrock * If the vdev has already been marked as failing due
6809eb4e2a4a94bcc76229c7b5108b96134537b6Eric Schrock * to a failed probe, then ignore any subsequent I/O
6809eb4e2a4a94bcc76229c7b5108b96134537b6Eric Schrock * errors, as the DE will automatically fault the vdev
6809eb4e2a4a94bcc76229c7b5108b96134537b6Eric Schrock * on the first such failure. This also catches cases
6809eb4e2a4a94bcc76229c7b5108b96134537b6Eric Schrock * where vdev_remove_wanted is set and the device has
6809eb4e2a4a94bcc76229c7b5108b96134537b6Eric Schrock * not yet been asynchronously placed into the REMOVED
1d7132005da8d75994a6ad204e6ec05ef5ffaa4bEric Schrock if (zio->io_vd == vd && !vdev_accessible(vd, zio))
6809eb4e2a4a94bcc76229c7b5108b96134537b6Eric Schrock * Ignore checksum errors for reads from DTL regions of
6809eb4e2a4a94bcc76229c7b5108b96134537b6Eric Schrock * leaf vdevs.
6809eb4e2a4a94bcc76229c7b5108b96134537b6Eric Schrock vdev_dtl_contains(vd, DTL_MISSING, zio->io_txg, 1))
1d7132005da8d75994a6ad204e6ec05ef5ffaa4bEric Schrock * For probe failure, we want to avoid posting ereports if we've
1d7132005da8d75994a6ad204e6ec05ef5ffaa4bEric Schrock * already removed the device in the meantime.
1d7132005da8d75994a6ad204e6ec05ef5ffaa4bEric Schrock strcmp(subclass, FM_EREPORT_ZFS_PROBE_FAILURE) == 0 &&
1d7132005da8d75994a6ad204e6ec05ef5ffaa4bEric Schrock (vd->vdev_remove_wanted || vd->vdev_state == VDEV_STATE_REMOVED))
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Serialize ereport generation
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Determine the ENA to use for this event. If we are in a loading
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * state, use a SPA-wide ENA. Otherwise, if we are in an I/O state, use
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * a root zio-wide ENA. Otherwise, simply use a unique ENA.
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock } else if (zio != NULL && zio->io_logical != NULL) {
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Construct the full class, detector, and other standard FMA fields.
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock fm_fmri_zfs_set(detector, FM_ZFS_SCHEME_VERSION, spa_guid(spa),
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock fm_ereport_set(ereport, FM_EREPORT_VERSION, class, ena, detector, NULL);
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Construct the per-ereport payload, depending on which parameters are
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * passed in.
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Generic payload members common to all ereports.
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock fm_payload_set(ereport, FM_EREPORT_PAYLOAD_ZFS_POOL,
e14bb3258d05c1b1077e2db7cf77088924e56919Jeff Bonwick DATA_TYPE_STRING, spa_name(spa), FM_EREPORT_PAYLOAD_ZFS_POOL_GUID,
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock FM_EREPORT_PAYLOAD_ZFS_POOL_CONTEXT, DATA_TYPE_INT32,
32b87932f3ef0887d873b7f6d2d1943799b2afc0ek fm_payload_set(ereport, FM_EREPORT_PAYLOAD_ZFS_POOL_FAILMODE,
32b87932f3ef0887d873b7f6d2d1943799b2afc0ek FM_EREPORT_FAILMODE_CONTINUE : FM_EREPORT_FAILMODE_PANIC,
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock fm_payload_set(ereport, FM_EREPORT_PAYLOAD_ZFS_VDEV_GUID,
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock DATA_TYPE_STRING, vd->vdev_ops->vdev_op_type, NULL);
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Payload common to all I/Os.
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock fm_payload_set(ereport, FM_EREPORT_PAYLOAD_ZFS_ZIO_ERR,
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * If the 'size' parameter is non-zero, it indicates this is a
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * RAID-Z or other I/O where the physical offset and length are
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * provided for us, instead of within the zio_t.
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Payload for I/Os with corresponding logical information.
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * If we have a vdev but no zio, this is a device fault, and the
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * 'stateoroffset' parameter indicates the previous state of the
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams/* if it's <= 128 bytes, save the corruption directly */
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams#define ZFM_MAX_INLINE (128 / sizeof (uint64_t))
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams /* histograms of set and cleared bits by bit number in a 64-bit word */
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams uint16_t zei_histogram_set[sizeof (uint64_t) * NBBY];
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams uint16_t zei_histogram_cleared[sizeof (uint64_t) * NBBY];
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams /* inline arrays of bits set and cleared. */
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams * for each range, the number of bits set and cleared. The Hamming
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams * distance between the good and bad buffers is the sum of them all.
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adamsupdate_histogram(uint64_t value_arg, uint16_t *hist, uint32_t *count)
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams /* We store the bits in big-endian (largest-first) order */
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams for (i = 0; i < 64; i++) {
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams /* update the count of bits changed */
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams * We've now filled up the range array, and need to increase "mingap" and
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams * shrink the range list accordingly. zei_mingap is always the smallest
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams * distance between array entries, so we set the new_allowed_gap to be
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams * one greater than that. We then go through the list, joining together
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams * any ranges which are closer than the new_allowed_gap.
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams * By construction, there will be at least one. We also update zei_mingap
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams * to the new smallest gap, to prepare for our next invocation.
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams uint32_t new_allowed_gap = eip->zei_mingap + 1;
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams ASSERT3U(eip->zei_range_count, <=, MAX_RANGES);
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adamsadd_range(zfs_ecksum_info_t *eip, int start, int end)
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adamsannotate_ecksum(nvlist_t *ereport, zio_bad_cksum_t *info,
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams const uint8_t *goodbuf, const uint8_t *badbuf, size_t size,
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams const uint64_t *good = (const uint64_t *)goodbuf;
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams const uint64_t *bad = (const uint64_t *)badbuf;
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams zfs_ecksum_info_t *eip = kmem_zalloc(sizeof (*eip), KM_SLEEP);
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams /* don't do any annotation for injected checksum errors */
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams sizeof (info->zbc_expected) / sizeof (uint64_t),
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams sizeof (info->zbc_actual) / sizeof (uint64_t),
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams ASSERT3U(size, ==, nui64s * sizeof (uint64_t));
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams /* build up the range list by comparing the two buffers. */
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams /* See if it will fit in our inline buffers */
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams * If there is no change and we want to drop if the buffers are
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams * identical, do so.
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams * Now walk through the ranges, filling in the details of the
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams * differences. Also convert our uint64_t-array offsets to byte
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams for (range = 0; range < eip->zei_range_count; range++) {
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams size_t start = eip->zei_ranges[range].zr_start;
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams // bits set in bad, but not in good
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams // bits set in good, but not in bad
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams update_histogram(set, eip->zei_histogram_set,
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams update_histogram(cleared, eip->zei_histogram_cleared,
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams /* convert to byte offsets */
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams eip->zei_ranges[range].zr_start *= sizeof (uint64_t);
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams eip->zei_ranges[range].zr_end *= sizeof (uint64_t);
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams eip->zei_allowed_mingap *= sizeof (uint64_t);
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams /* fill in ereport */
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams DATA_TYPE_UINT32_ARRAY, 2 * eip->zei_range_count,
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams DATA_TYPE_UINT32_ARRAY, eip->zei_range_count, eip->zei_range_sets,
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams DATA_TYPE_UINT32_ARRAY, eip->zei_range_count, eip->zei_range_clears,
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams inline_size, (uint8_t *)eip->zei_bits_cleared,
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams NBBY * sizeof (uint64_t), eip->zei_histogram_set,
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams FM_EREPORT_PAYLOAD_ZFS_BAD_CLEARED_HISTOGRAM,
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams NBBY * sizeof (uint64_t), eip->zei_histogram_cleared,
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adamszfs_ereport_post(const char *subclass, spa_t *spa, vdev_t *vd, zio_t *zio,
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams subclass, spa, vd, zio, stateoroffset, size);
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adamszfs_ereport_start_checksum(spa_t *spa, vdev_t *vd,
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams struct zio *zio, uint64_t offset, uint64_t length, void *arg,
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams zio_cksum_report_t *report = kmem_zalloc(sizeof (*report), KM_SLEEP);
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams zio->io_vsd_ops->vsd_cksum_report(zio, report, arg);
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams zio_vsd_default_cksum_report(zio, report, arg);
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams /* copy the checksum failure information if it was provided */
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams report->zcr_ckinfo = kmem_zalloc(sizeof (*info), KM_SLEEP);
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams bcopy(info, report->zcr_ckinfo, sizeof (*info));
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick report->zcr_align = 1ULL << vd->vdev_top->vdev_ashift;
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams zfs_ereport_start(&report->zcr_ereport, &report->zcr_detector,
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams FM_EREPORT_ZFS_CHECKSUM, spa, vd, zio, offset, length);
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams report->zcr_free(report->zcr_cbdata, report->zcr_cbinfo);
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams report->zcr_next = zio->io_logical->io_cksum_report;
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adamszfs_ereport_finish_checksum(zio_cksum_report_t *report,
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams const void *good_data, const void *bad_data, boolean_t drop_if_identical)
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams info = annotate_ecksum(report->zcr_ereport, report->zcr_ckinfo,
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams good_data, bad_data, report->zcr_length, drop_if_identical);
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams fm_ereport_post(report->zcr_ereport, EVCH_SLEEP);
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams fm_nvlist_destroy(report->zcr_ereport, FM_NVA_FREE);
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams fm_nvlist_destroy(report->zcr_detector, FM_NVA_FREE);
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams report->zcr_ereport = report->zcr_detector = NULL;
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adamszfs_ereport_free_checksum(zio_cksum_report_t *rpt)
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams rpt->zcr_free(rpt->zcr_cbdata, rpt->zcr_cbinfo);
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams kmem_free(rpt->zcr_ckinfo, sizeof (*rpt->zcr_ckinfo));
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adamszfs_ereport_send_interim_checksum(zio_cksum_report_t *report)
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams fm_ereport_post(report->zcr_ereport, EVCH_SLEEP);
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adamszfs_ereport_post_checksum(spa_t *spa, vdev_t *vd,
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams struct zio *zio, uint64_t offset, uint64_t length,
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams const void *good_data, const void *bad_data, zio_bad_cksum_t *zbc)
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams FM_EREPORT_ZFS_CHECKSUM, spa, vd, zio, offset, length);
22fe2c8844be88ebae6478ca1b0b92c8ec2aef54Jonathan Adams info = annotate_ecksum(ereport, zbc, good_data, bad_data, length,
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrockzfs_post_common(spa_t *spa, vdev_t *vd, const char *name)
b16da2e29e074fb6eaeadc4fd7d17ae7340ba240George Wilson if (spa_load_state(spa) == SPA_LOAD_TRYIMPORT)
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock (void) snprintf(class, sizeof (class), "%s.%s.%s", FM_RSRC_RESOURCE,
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock VERIFY(nvlist_add_uint8(resource, FM_VERSION, FM_RSRC_VERSION) == 0);
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock VERIFY(nvlist_add_string(resource, FM_CLASS, class) == 0);
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock FM_EREPORT_PAYLOAD_ZFS_POOL_GUID, spa_guid(spa)) == 0);
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock FM_EREPORT_PAYLOAD_ZFS_VDEV_GUID, vd->vdev_guid) == 0);
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * The 'resource.fs.zfs.removed' event is an internal signal that the given vdev
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * has been removed from the system. This will cause the DE to ignore any
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * recent I/O errors, inferring that they are due to the asynchronous device
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * The 'resource.fs.zfs.autoreplace' event is an internal signal that the pool
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * has the 'autoreplace' property set, and therefore any broken vdevs will be
3d7072f8bd27709dba14f6fe336f149d25d9e207eschrock * handled by higher level logic, and no vdev fault should be generated.
069f55e237020c4a4907b235fc38fafc6442ce94Eric Schrock * The 'resource.fs.zfs.statechange' event is an internal signal that the
069f55e237020c4a4907b235fc38fafc6442ce94Eric Schrock * given vdev has transitioned its state to DEGRADED or HEALTHY. This will
069f55e237020c4a4907b235fc38fafc6442ce94Eric Schrock * cause the retire agent to repair any outstanding fault management cases
069f55e237020c4a4907b235fc38fafc6442ce94Eric Schrock * open because the device was not found (fault.fs.zfs.device).