Print this page
Fixup merge results
re #12393 rb3935 Kerberos and smbd disagree about who is our AD server (fix elf runtime attributes check)
re #11612 rb3907 Failing vdev of a mirrored pool should not take zfs operations out of action for extended periods of time.
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/fs/zfs/zfs_fm.c
+++ new/usr/src/uts/common/fs/zfs/zfs_fm.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
|
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 - */
25 -
26 -/*
27 24 * Copyright (c) 2012 by Delphix. All rights reserved.
25 + * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
28 26 */
29 27
30 28 #include <sys/spa.h>
31 29 #include <sys/spa_impl.h>
32 30 #include <sys/vdev.h>
33 31 #include <sys/vdev_impl.h>
34 32 #include <sys/zio.h>
35 33 #include <sys/zio_checksum.h>
36 34
37 35 #include <sys/fm/fs/zfs.h>
38 36 #include <sys/fm/protocol.h>
39 37 #include <sys/fm/util.h>
40 38 #include <sys/sysevent.h>
41 39
42 40 /*
43 41 * This general routine is responsible for generating all the different ZFS
44 42 * ereports. The payload is dependent on the class, and which arguments are
45 43 * supplied to the function:
46 44 *
47 45 * EREPORT POOL VDEV IO
48 46 * block X X X
49 47 * data X X
50 48 * device X X
51 49 * pool X
52 50 *
53 51 * If we are in a loading state, all errors are chained together by the same
54 52 * SPA-wide ENA (Error Numeric Association).
55 53 *
56 54 * For isolated I/O requests, we get the ENA from the zio_t. The propagation
57 55 * gets very complicated due to RAID-Z, gang blocks, and vdev caching. We want
58 56 * to chain together all ereports associated with a logical piece of data. For
59 57 * read I/Os, there are basically three 'types' of I/O, which form a roughly
60 58 * layered diagram:
61 59 *
62 60 * +---------------+
63 61 * | Aggregate I/O | No associated logical data or device
64 62 * +---------------+
65 63 * |
66 64 * V
67 65 * +---------------+ Reads associated with a piece of logical data.
68 66 * | Read I/O | This includes reads on behalf of RAID-Z,
69 67 * +---------------+ mirrors, gang blocks, retries, etc.
70 68 * |
71 69 * V
72 70 * +---------------+ Reads associated with a particular device, but
73 71 * | Physical I/O | no logical data. Issued as part of vdev caching
74 72 * +---------------+ and I/O aggregation.
75 73 *
76 74 * Note that 'physical I/O' here is not the same terminology as used in the rest
77 75 * of ZIO. Typically, 'physical I/O' simply means that there is no attached
78 76 * blockpointer. But I/O with no associated block pointer can still be related
79 77 * to a logical piece of data (i.e. RAID-Z requests).
80 78 *
81 79 * Purely physical I/O always have unique ENAs. They are not related to a
82 80 * particular piece of logical data, and therefore cannot be chained together.
83 81 * We still generate an ereport, but the DE doesn't correlate it with any
84 82 * logical piece of data. When such an I/O fails, the delegated I/O requests
85 83 * will issue a retry, which will trigger the 'real' ereport with the correct
86 84 * ENA.
87 85 *
88 86 * We keep track of the ENA for a ZIO chain through the 'io_logical' member.
89 87 * When a new logical I/O is issued, we set this to point to itself. Child I/Os
90 88 * then inherit this pointer, so that when it is first set subsequent failures
91 89 * will use the same ENA. For vdev cache fill and queue aggregation I/O,
92 90 * this pointer is set to NULL, and no ereport will be generated (since it
93 91 * doesn't actually correspond to any particular device or piece of data,
94 92 * and the caller will always retry without caching or queueing anyway).
95 93 *
96 94 * For checksum errors, we want to include more information about the actual
97 95 * error which occurs. Accordingly, we build an ereport when the error is
98 96 * noticed, but instead of sending it in immediately, we hang it off of the
99 97 * io_cksum_report field of the logical IO. When the logical IO completes
100 98 * (successfully or not), zfs_ereport_finish_checksum() is called with the
101 99 * good and bad versions of the buffer (if available), and we annotate the
102 100 * ereport with information about the differences.
103 101 */
104 102 #ifdef _KERNEL
105 103 static void
106 104 zfs_ereport_start(nvlist_t **ereport_out, nvlist_t **detector_out,
107 105 const char *subclass, spa_t *spa, vdev_t *vd, zio_t *zio,
108 106 uint64_t stateoroffset, uint64_t size)
109 107 {
110 108 nvlist_t *ereport, *detector;
111 109
112 110 uint64_t ena;
113 111 char class[64];
114 112
115 113 /*
116 114 * If we are doing a spa_tryimport() or in recovery mode,
117 115 * ignore errors.
118 116 */
119 117 if (spa_load_state(spa) == SPA_LOAD_TRYIMPORT ||
120 118 spa_load_state(spa) == SPA_LOAD_RECOVER)
121 119 return;
122 120
123 121 /*
124 122 * If we are in the middle of opening a pool, and the previous attempt
125 123 * failed, don't bother logging any new ereports - we're just going to
126 124 * get the same diagnosis anyway.
127 125 */
128 126 if (spa_load_state(spa) != SPA_LOAD_NONE &&
129 127 spa->spa_last_open_failed)
130 128 return;
131 129
132 130 if (zio != NULL) {
133 131 /*
134 132 * If this is not a read or write zio, ignore the error. This
135 133 * can occur if the DKIOCFLUSHWRITECACHE ioctl fails.
136 134 */
137 135 if (zio->io_type != ZIO_TYPE_READ &&
138 136 zio->io_type != ZIO_TYPE_WRITE)
139 137 return;
140 138
141 139 /*
142 140 * Ignore any errors from speculative I/Os, as failure is an
143 141 * expected result.
144 142 */
145 143 if (zio->io_flags & ZIO_FLAG_SPECULATIVE)
146 144 return;
147 145
148 146 /*
149 147 * If this I/O is not a retry I/O, don't post an ereport.
150 148 * Otherwise, we risk making bad diagnoses based on B_FAILFAST
151 149 * I/Os.
152 150 */
153 151 if (zio->io_error == EIO &&
154 152 !(zio->io_flags & ZIO_FLAG_IO_RETRY))
155 153 return;
156 154
157 155 if (vd != NULL) {
158 156 /*
159 157 * If the vdev has already been marked as failing due
160 158 * to a failed probe, then ignore any subsequent I/O
161 159 * errors, as the DE will automatically fault the vdev
162 160 * on the first such failure. This also catches cases
163 161 * where vdev_remove_wanted is set and the device has
164 162 * not yet been asynchronously placed into the REMOVED
165 163 * state.
166 164 */
167 165 if (zio->io_vd == vd && !vdev_accessible(vd, zio))
168 166 return;
169 167
170 168 /*
171 169 * Ignore checksum errors for reads from DTL regions of
172 170 * leaf vdevs.
173 171 */
174 172 if (zio->io_type == ZIO_TYPE_READ &&
175 173 zio->io_error == ECKSUM &&
176 174 vd->vdev_ops->vdev_op_leaf &&
177 175 vdev_dtl_contains(vd, DTL_MISSING, zio->io_txg, 1))
178 176 return;
179 177 }
180 178 }
181 179
182 180 /*
183 181 * For probe failure, we want to avoid posting ereports if we've
184 182 * already removed the device in the meantime.
185 183 */
186 184 if (vd != NULL &&
187 185 strcmp(subclass, FM_EREPORT_ZFS_PROBE_FAILURE) == 0 &&
188 186 (vd->vdev_remove_wanted || vd->vdev_state == VDEV_STATE_REMOVED))
189 187 return;
190 188
191 189 if ((ereport = fm_nvlist_create(NULL)) == NULL)
192 190 return;
193 191
194 192 if ((detector = fm_nvlist_create(NULL)) == NULL) {
195 193 fm_nvlist_destroy(ereport, FM_NVA_FREE);
196 194 return;
197 195 }
198 196
199 197 /*
200 198 * Serialize ereport generation
201 199 */
202 200 mutex_enter(&spa->spa_errlist_lock);
203 201
204 202 /*
205 203 * Determine the ENA to use for this event. If we are in a loading
206 204 * state, use a SPA-wide ENA. Otherwise, if we are in an I/O state, use
207 205 * a root zio-wide ENA. Otherwise, simply use a unique ENA.
208 206 */
209 207 if (spa_load_state(spa) != SPA_LOAD_NONE) {
210 208 if (spa->spa_ena == 0)
211 209 spa->spa_ena = fm_ena_generate(0, FM_ENA_FMT1);
212 210 ena = spa->spa_ena;
213 211 } else if (zio != NULL && zio->io_logical != NULL) {
214 212 if (zio->io_logical->io_ena == 0)
215 213 zio->io_logical->io_ena =
216 214 fm_ena_generate(0, FM_ENA_FMT1);
217 215 ena = zio->io_logical->io_ena;
218 216 } else {
219 217 ena = fm_ena_generate(0, FM_ENA_FMT1);
220 218 }
221 219
222 220 /*
223 221 * Construct the full class, detector, and other standard FMA fields.
224 222 */
225 223 (void) snprintf(class, sizeof (class), "%s.%s",
226 224 ZFS_ERROR_CLASS, subclass);
227 225
228 226 fm_fmri_zfs_set(detector, FM_ZFS_SCHEME_VERSION, spa_guid(spa),
229 227 vd != NULL ? vd->vdev_guid : 0);
230 228
231 229 fm_ereport_set(ereport, FM_EREPORT_VERSION, class, ena, detector, NULL);
232 230
233 231 /*
234 232 * Construct the per-ereport payload, depending on which parameters are
235 233 * passed in.
236 234 */
237 235
238 236 /*
239 237 * Generic payload members common to all ereports.
240 238 */
241 239 fm_payload_set(ereport, FM_EREPORT_PAYLOAD_ZFS_POOL,
242 240 DATA_TYPE_STRING, spa_name(spa), FM_EREPORT_PAYLOAD_ZFS_POOL_GUID,
243 241 DATA_TYPE_UINT64, spa_guid(spa),
244 242 FM_EREPORT_PAYLOAD_ZFS_POOL_CONTEXT, DATA_TYPE_INT32,
245 243 spa_load_state(spa), NULL);
246 244
247 245 if (spa != NULL) {
248 246 fm_payload_set(ereport, FM_EREPORT_PAYLOAD_ZFS_POOL_FAILMODE,
249 247 DATA_TYPE_STRING,
250 248 spa_get_failmode(spa) == ZIO_FAILURE_MODE_WAIT ?
251 249 FM_EREPORT_FAILMODE_WAIT :
252 250 spa_get_failmode(spa) == ZIO_FAILURE_MODE_CONTINUE ?
253 251 FM_EREPORT_FAILMODE_CONTINUE : FM_EREPORT_FAILMODE_PANIC,
254 252 NULL);
255 253 }
256 254
257 255 if (vd != NULL) {
258 256 vdev_t *pvd = vd->vdev_parent;
259 257
260 258 fm_payload_set(ereport, FM_EREPORT_PAYLOAD_ZFS_VDEV_GUID,
261 259 DATA_TYPE_UINT64, vd->vdev_guid,
262 260 FM_EREPORT_PAYLOAD_ZFS_VDEV_TYPE,
263 261 DATA_TYPE_STRING, vd->vdev_ops->vdev_op_type, NULL);
264 262 if (vd->vdev_path != NULL)
265 263 fm_payload_set(ereport,
266 264 FM_EREPORT_PAYLOAD_ZFS_VDEV_PATH,
267 265 DATA_TYPE_STRING, vd->vdev_path, NULL);
268 266 if (vd->vdev_devid != NULL)
269 267 fm_payload_set(ereport,
270 268 FM_EREPORT_PAYLOAD_ZFS_VDEV_DEVID,
271 269 DATA_TYPE_STRING, vd->vdev_devid, NULL);
272 270 if (vd->vdev_fru != NULL)
273 271 fm_payload_set(ereport,
274 272 FM_EREPORT_PAYLOAD_ZFS_VDEV_FRU,
275 273 DATA_TYPE_STRING, vd->vdev_fru, NULL);
276 274
277 275 if (pvd != NULL) {
278 276 fm_payload_set(ereport,
279 277 FM_EREPORT_PAYLOAD_ZFS_PARENT_GUID,
280 278 DATA_TYPE_UINT64, pvd->vdev_guid,
281 279 FM_EREPORT_PAYLOAD_ZFS_PARENT_TYPE,
282 280 DATA_TYPE_STRING, pvd->vdev_ops->vdev_op_type,
283 281 NULL);
284 282 if (pvd->vdev_path)
285 283 fm_payload_set(ereport,
286 284 FM_EREPORT_PAYLOAD_ZFS_PARENT_PATH,
287 285 DATA_TYPE_STRING, pvd->vdev_path, NULL);
288 286 if (pvd->vdev_devid)
289 287 fm_payload_set(ereport,
290 288 FM_EREPORT_PAYLOAD_ZFS_PARENT_DEVID,
291 289 DATA_TYPE_STRING, pvd->vdev_devid, NULL);
292 290 }
293 291 }
294 292
295 293 if (zio != NULL) {
296 294 /*
297 295 * Payload common to all I/Os.
|
↓ open down ↓ |
260 lines elided |
↑ open up ↑ |
298 296 */
299 297 fm_payload_set(ereport, FM_EREPORT_PAYLOAD_ZFS_ZIO_ERR,
300 298 DATA_TYPE_INT32, zio->io_error, NULL);
301 299
302 300 /*
303 301 * If the 'size' parameter is non-zero, it indicates this is a
304 302 * RAID-Z or other I/O where the physical offset and length are
305 303 * provided for us, instead of within the zio_t.
306 304 */
307 305 if (vd != NULL) {
308 - if (size)
306 + /*
307 + * The 'stateoroffset' and 'size' parameters are
308 + * overloaded to represent the timeout and latency,
309 + * respectively, in a timeout report.
310 + */
311 + if (strcmp(subclass, FM_EREPORT_ZFS_TIMEOUT) == 0)
309 312 fm_payload_set(ereport,
313 + FM_EREPORT_PAYLOAD_ZFS_ZIO_TIMEOUT,
314 + DATA_TYPE_UINT64, stateoroffset,
315 + FM_EREPORT_PAYLOAD_ZFS_ZIO_LATENCY,
316 + DATA_TYPE_UINT64, size, NULL);
317 + else if (size)
318 + fm_payload_set(ereport,
310 319 FM_EREPORT_PAYLOAD_ZFS_ZIO_OFFSET,
311 320 DATA_TYPE_UINT64, stateoroffset,
312 321 FM_EREPORT_PAYLOAD_ZFS_ZIO_SIZE,
313 322 DATA_TYPE_UINT64, size, NULL);
314 323 else
315 324 fm_payload_set(ereport,
316 325 FM_EREPORT_PAYLOAD_ZFS_ZIO_OFFSET,
317 326 DATA_TYPE_UINT64, zio->io_offset,
318 327 FM_EREPORT_PAYLOAD_ZFS_ZIO_SIZE,
319 328 DATA_TYPE_UINT64, zio->io_size, NULL);
320 329 }
321 330
322 331 /*
323 332 * Payload for I/Os with corresponding logical information.
324 333 */
325 334 if (zio->io_logical != NULL)
326 335 fm_payload_set(ereport,
327 336 FM_EREPORT_PAYLOAD_ZFS_ZIO_OBJSET,
328 337 DATA_TYPE_UINT64,
329 338 zio->io_logical->io_bookmark.zb_objset,
330 339 FM_EREPORT_PAYLOAD_ZFS_ZIO_OBJECT,
331 340 DATA_TYPE_UINT64,
332 341 zio->io_logical->io_bookmark.zb_object,
333 342 FM_EREPORT_PAYLOAD_ZFS_ZIO_LEVEL,
334 343 DATA_TYPE_INT64,
335 344 zio->io_logical->io_bookmark.zb_level,
336 345 FM_EREPORT_PAYLOAD_ZFS_ZIO_BLKID,
337 346 DATA_TYPE_UINT64,
338 347 zio->io_logical->io_bookmark.zb_blkid, NULL);
339 348 } else if (vd != NULL) {
340 349 /*
341 350 * If we have a vdev but no zio, this is a device fault, and the
342 351 * 'stateoroffset' parameter indicates the previous state of the
343 352 * vdev.
344 353 */
345 354 fm_payload_set(ereport,
346 355 FM_EREPORT_PAYLOAD_ZFS_PREV_STATE,
347 356 DATA_TYPE_UINT64, stateoroffset, NULL);
348 357 }
349 358
350 359 mutex_exit(&spa->spa_errlist_lock);
351 360
352 361 *ereport_out = ereport;
|
↓ open down ↓ |
33 lines elided |
↑ open up ↑ |
353 362 *detector_out = detector;
354 363 }
355 364
356 365 /* if it's <= 128 bytes, save the corruption directly */
357 366 #define ZFM_MAX_INLINE (128 / sizeof (uint64_t))
358 367
359 368 #define MAX_RANGES 16
360 369
361 370 typedef struct zfs_ecksum_info {
362 371 /* histograms of set and cleared bits by bit number in a 64-bit word */
363 - uint32_t zei_histogram_set[sizeof (uint64_t) * NBBY];
364 - uint32_t zei_histogram_cleared[sizeof (uint64_t) * NBBY];
372 + uint16_t zei_histogram_set[sizeof (uint64_t) * NBBY];
373 + uint16_t zei_histogram_cleared[sizeof (uint64_t) * NBBY];
365 374
366 375 /* inline arrays of bits set and cleared. */
367 376 uint64_t zei_bits_set[ZFM_MAX_INLINE];
368 377 uint64_t zei_bits_cleared[ZFM_MAX_INLINE];
369 378
370 379 /*
371 380 * for each range, the number of bits set and cleared. The Hamming
372 381 * distance between the good and bad buffers is the sum of them all.
373 382 */
374 383 uint32_t zei_range_sets[MAX_RANGES];
375 384 uint32_t zei_range_clears[MAX_RANGES];
376 385
377 386 struct zei_ranges {
378 387 uint32_t zr_start;
|
↓ open down ↓ |
4 lines elided |
↑ open up ↑ |
379 388 uint32_t zr_end;
380 389 } zei_ranges[MAX_RANGES];
381 390
382 391 size_t zei_range_count;
383 392 uint32_t zei_mingap;
384 393 uint32_t zei_allowed_mingap;
385 394
386 395 } zfs_ecksum_info_t;
387 396
388 397 static void
389 -update_histogram(uint64_t value_arg, uint32_t *hist, uint32_t *count)
398 +update_histogram(uint64_t value_arg, uint16_t *hist, uint32_t *count)
390 399 {
391 400 size_t i;
392 401 size_t bits = 0;
393 402 uint64_t value = BE_64(value_arg);
394 403
395 404 /* We store the bits in big-endian (largest-first) order */
396 405 for (i = 0; i < 64; i++) {
397 406 if (value & (1ull << i)) {
398 407 hist[63 - i]++;
399 408 ++bits;
400 409 }
401 410 }
402 411 /* update the count of bits changed */
403 412 *count += bits;
404 413 }
405 414
406 415 /*
407 416 * We've now filled up the range array, and need to increase "mingap" and
408 417 * shrink the range list accordingly. zei_mingap is always the smallest
409 418 * distance between array entries, so we set the new_allowed_gap to be
410 419 * one greater than that. We then go through the list, joining together
411 420 * any ranges which are closer than the new_allowed_gap.
412 421 *
413 422 * By construction, there will be at least one. We also update zei_mingap
414 423 * to the new smallest gap, to prepare for our next invocation.
415 424 */
416 425 static void
417 426 shrink_ranges(zfs_ecksum_info_t *eip)
418 427 {
419 428 uint32_t mingap = UINT32_MAX;
420 429 uint32_t new_allowed_gap = eip->zei_mingap + 1;
421 430
422 431 size_t idx, output;
423 432 size_t max = eip->zei_range_count;
424 433
425 434 struct zei_ranges *r = eip->zei_ranges;
426 435
427 436 ASSERT3U(eip->zei_range_count, >, 0);
428 437 ASSERT3U(eip->zei_range_count, <=, MAX_RANGES);
429 438
430 439 output = idx = 0;
431 440 while (idx < max - 1) {
432 441 uint32_t start = r[idx].zr_start;
433 442 uint32_t end = r[idx].zr_end;
434 443
435 444 while (idx < max - 1) {
436 445 idx++;
437 446
438 447 uint32_t nstart = r[idx].zr_start;
439 448 uint32_t nend = r[idx].zr_end;
440 449
441 450 uint32_t gap = nstart - end;
442 451 if (gap < new_allowed_gap) {
443 452 end = nend;
444 453 continue;
445 454 }
446 455 if (gap < mingap)
447 456 mingap = gap;
448 457 break;
449 458 }
450 459 r[output].zr_start = start;
451 460 r[output].zr_end = end;
452 461 output++;
453 462 }
454 463 ASSERT3U(output, <, eip->zei_range_count);
455 464 eip->zei_range_count = output;
456 465 eip->zei_mingap = mingap;
457 466 eip->zei_allowed_mingap = new_allowed_gap;
458 467 }
459 468
460 469 static void
461 470 add_range(zfs_ecksum_info_t *eip, int start, int end)
462 471 {
463 472 struct zei_ranges *r = eip->zei_ranges;
464 473 size_t count = eip->zei_range_count;
465 474
466 475 if (count >= MAX_RANGES) {
467 476 shrink_ranges(eip);
468 477 count = eip->zei_range_count;
469 478 }
470 479 if (count == 0) {
471 480 eip->zei_mingap = UINT32_MAX;
472 481 eip->zei_allowed_mingap = 1;
473 482 } else {
474 483 int gap = start - r[count - 1].zr_end;
475 484
476 485 if (gap < eip->zei_allowed_mingap) {
477 486 r[count - 1].zr_end = end;
478 487 return;
479 488 }
480 489 if (gap < eip->zei_mingap)
481 490 eip->zei_mingap = gap;
482 491 }
483 492 r[count].zr_start = start;
484 493 r[count].zr_end = end;
485 494 eip->zei_range_count++;
486 495 }
487 496
488 497 static size_t
489 498 range_total_size(zfs_ecksum_info_t *eip)
490 499 {
491 500 struct zei_ranges *r = eip->zei_ranges;
492 501 size_t count = eip->zei_range_count;
493 502 size_t result = 0;
494 503 size_t idx;
495 504
496 505 for (idx = 0; idx < count; idx++)
497 506 result += (r[idx].zr_end - r[idx].zr_start);
498 507
499 508 return (result);
500 509 }
501 510
502 511 static zfs_ecksum_info_t *
503 512 annotate_ecksum(nvlist_t *ereport, zio_bad_cksum_t *info,
504 513 const uint8_t *goodbuf, const uint8_t *badbuf, size_t size,
505 514 boolean_t drop_if_identical)
506 515 {
507 516 const uint64_t *good = (const uint64_t *)goodbuf;
508 517 const uint64_t *bad = (const uint64_t *)badbuf;
509 518
510 519 uint64_t allset = 0;
511 520 uint64_t allcleared = 0;
512 521
513 522 size_t nui64s = size / sizeof (uint64_t);
514 523
515 524 size_t inline_size;
516 525 int no_inline = 0;
517 526 size_t idx;
518 527 size_t range;
519 528
520 529 size_t offset = 0;
521 530 ssize_t start = -1;
522 531
523 532 zfs_ecksum_info_t *eip = kmem_zalloc(sizeof (*eip), KM_SLEEP);
524 533
525 534 /* don't do any annotation for injected checksum errors */
526 535 if (info != NULL && info->zbc_injected)
527 536 return (eip);
528 537
529 538 if (info != NULL && info->zbc_has_cksum) {
530 539 fm_payload_set(ereport,
531 540 FM_EREPORT_PAYLOAD_ZFS_CKSUM_EXPECTED,
532 541 DATA_TYPE_UINT64_ARRAY,
533 542 sizeof (info->zbc_expected) / sizeof (uint64_t),
534 543 (uint64_t *)&info->zbc_expected,
535 544 FM_EREPORT_PAYLOAD_ZFS_CKSUM_ACTUAL,
536 545 DATA_TYPE_UINT64_ARRAY,
537 546 sizeof (info->zbc_actual) / sizeof (uint64_t),
538 547 (uint64_t *)&info->zbc_actual,
539 548 FM_EREPORT_PAYLOAD_ZFS_CKSUM_ALGO,
540 549 DATA_TYPE_STRING,
541 550 info->zbc_checksum_name,
542 551 NULL);
543 552
544 553 if (info->zbc_byteswapped) {
|
↓ open down ↓ |
145 lines elided |
↑ open up ↑ |
545 554 fm_payload_set(ereport,
546 555 FM_EREPORT_PAYLOAD_ZFS_CKSUM_BYTESWAP,
547 556 DATA_TYPE_BOOLEAN, 1,
548 557 NULL);
549 558 }
550 559 }
551 560
552 561 if (badbuf == NULL || goodbuf == NULL)
553 562 return (eip);
554 563
555 - ASSERT3U(nui64s, <=, UINT32_MAX);
564 + ASSERT3U(nui64s, <=, UINT16_MAX);
556 565 ASSERT3U(size, ==, nui64s * sizeof (uint64_t));
557 566 ASSERT3U(size, <=, SPA_MAXBLOCKSIZE);
558 567 ASSERT3U(size, <=, UINT32_MAX);
559 568
560 569 /* build up the range list by comparing the two buffers. */
561 570 for (idx = 0; idx < nui64s; idx++) {
562 571 if (good[idx] == bad[idx]) {
563 572 if (start == -1)
564 573 continue;
565 574
566 575 add_range(eip, start, idx);
567 576 start = -1;
568 577 } else {
569 578 if (start != -1)
570 579 continue;
571 580
572 581 start = idx;
573 582 }
574 583 }
575 584 if (start != -1)
576 585 add_range(eip, start, idx);
577 586
578 587 /* See if it will fit in our inline buffers */
579 588 inline_size = range_total_size(eip);
580 589 if (inline_size > ZFM_MAX_INLINE)
581 590 no_inline = 1;
582 591
583 592 /*
584 593 * If there is no change and we want to drop if the buffers are
585 594 * identical, do so.
586 595 */
587 596 if (inline_size == 0 && drop_if_identical) {
588 597 kmem_free(eip, sizeof (*eip));
589 598 return (NULL);
590 599 }
591 600
592 601 /*
593 602 * Now walk through the ranges, filling in the details of the
594 603 * differences. Also convert our uint64_t-array offsets to byte
595 604 * offsets.
596 605 */
597 606 for (range = 0; range < eip->zei_range_count; range++) {
598 607 size_t start = eip->zei_ranges[range].zr_start;
599 608 size_t end = eip->zei_ranges[range].zr_end;
600 609
601 610 for (idx = start; idx < end; idx++) {
602 611 uint64_t set, cleared;
603 612
604 613 // bits set in bad, but not in good
605 614 set = ((~good[idx]) & bad[idx]);
606 615 // bits set in good, but not in bad
607 616 cleared = (good[idx] & (~bad[idx]));
608 617
609 618 allset |= set;
610 619 allcleared |= cleared;
611 620
612 621 if (!no_inline) {
613 622 ASSERT3U(offset, <, inline_size);
614 623 eip->zei_bits_set[offset] = set;
615 624 eip->zei_bits_cleared[offset] = cleared;
616 625 offset++;
617 626 }
618 627
619 628 update_histogram(set, eip->zei_histogram_set,
620 629 &eip->zei_range_sets[range]);
621 630 update_histogram(cleared, eip->zei_histogram_cleared,
622 631 &eip->zei_range_clears[range]);
623 632 }
624 633
625 634 /* convert to byte offsets */
626 635 eip->zei_ranges[range].zr_start *= sizeof (uint64_t);
627 636 eip->zei_ranges[range].zr_end *= sizeof (uint64_t);
628 637 }
629 638 eip->zei_allowed_mingap *= sizeof (uint64_t);
630 639 inline_size *= sizeof (uint64_t);
631 640
632 641 /* fill in ereport */
633 642 fm_payload_set(ereport,
634 643 FM_EREPORT_PAYLOAD_ZFS_BAD_OFFSET_RANGES,
635 644 DATA_TYPE_UINT32_ARRAY, 2 * eip->zei_range_count,
636 645 (uint32_t *)eip->zei_ranges,
637 646 FM_EREPORT_PAYLOAD_ZFS_BAD_RANGE_MIN_GAP,
638 647 DATA_TYPE_UINT32, eip->zei_allowed_mingap,
639 648 FM_EREPORT_PAYLOAD_ZFS_BAD_RANGE_SETS,
640 649 DATA_TYPE_UINT32_ARRAY, eip->zei_range_count, eip->zei_range_sets,
641 650 FM_EREPORT_PAYLOAD_ZFS_BAD_RANGE_CLEARS,
642 651 DATA_TYPE_UINT32_ARRAY, eip->zei_range_count, eip->zei_range_clears,
643 652 NULL);
644 653
645 654 if (!no_inline) {
646 655 fm_payload_set(ereport,
|
↓ open down ↓ |
81 lines elided |
↑ open up ↑ |
647 656 FM_EREPORT_PAYLOAD_ZFS_BAD_SET_BITS,
648 657 DATA_TYPE_UINT8_ARRAY,
649 658 inline_size, (uint8_t *)eip->zei_bits_set,
650 659 FM_EREPORT_PAYLOAD_ZFS_BAD_CLEARED_BITS,
651 660 DATA_TYPE_UINT8_ARRAY,
652 661 inline_size, (uint8_t *)eip->zei_bits_cleared,
653 662 NULL);
654 663 } else {
655 664 fm_payload_set(ereport,
656 665 FM_EREPORT_PAYLOAD_ZFS_BAD_SET_HISTOGRAM,
657 - DATA_TYPE_UINT32_ARRAY,
666 + DATA_TYPE_UINT16_ARRAY,
658 667 NBBY * sizeof (uint64_t), eip->zei_histogram_set,
659 668 FM_EREPORT_PAYLOAD_ZFS_BAD_CLEARED_HISTOGRAM,
660 - DATA_TYPE_UINT32_ARRAY,
669 + DATA_TYPE_UINT16_ARRAY,
661 670 NBBY * sizeof (uint64_t), eip->zei_histogram_cleared,
662 671 NULL);
663 672 }
664 673 return (eip);
665 674 }
666 675 #endif
667 676
668 677 void
669 678 zfs_ereport_post(const char *subclass, spa_t *spa, vdev_t *vd, zio_t *zio,
670 679 uint64_t stateoroffset, uint64_t size)
671 680 {
672 681 #ifdef _KERNEL
673 682 nvlist_t *ereport = NULL;
674 683 nvlist_t *detector = NULL;
675 684
676 685 zfs_ereport_start(&ereport, &detector,
677 686 subclass, spa, vd, zio, stateoroffset, size);
678 687
679 688 if (ereport == NULL)
680 689 return;
681 690
682 691 fm_ereport_post(ereport, EVCH_SLEEP);
683 692
684 693 fm_nvlist_destroy(ereport, FM_NVA_FREE);
685 694 fm_nvlist_destroy(detector, FM_NVA_FREE);
686 695 #endif
687 696 }
688 697
689 698 void
690 699 zfs_ereport_start_checksum(spa_t *spa, vdev_t *vd,
691 700 struct zio *zio, uint64_t offset, uint64_t length, void *arg,
692 701 zio_bad_cksum_t *info)
693 702 {
694 703 zio_cksum_report_t *report = kmem_zalloc(sizeof (*report), KM_SLEEP);
695 704
696 705 if (zio->io_vsd != NULL)
697 706 zio->io_vsd_ops->vsd_cksum_report(zio, report, arg);
698 707 else
699 708 zio_vsd_default_cksum_report(zio, report, arg);
700 709
701 710 /* copy the checksum failure information if it was provided */
702 711 if (info != NULL) {
703 712 report->zcr_ckinfo = kmem_zalloc(sizeof (*info), KM_SLEEP);
704 713 bcopy(info, report->zcr_ckinfo, sizeof (*info));
705 714 }
706 715
707 716 report->zcr_align = 1ULL << vd->vdev_top->vdev_ashift;
708 717 report->zcr_length = length;
709 718
710 719 #ifdef _KERNEL
711 720 zfs_ereport_start(&report->zcr_ereport, &report->zcr_detector,
712 721 FM_EREPORT_ZFS_CHECKSUM, spa, vd, zio, offset, length);
713 722
714 723 if (report->zcr_ereport == NULL) {
715 724 report->zcr_free(report->zcr_cbdata, report->zcr_cbinfo);
716 725 if (report->zcr_ckinfo != NULL) {
717 726 kmem_free(report->zcr_ckinfo,
718 727 sizeof (*report->zcr_ckinfo));
719 728 }
720 729 kmem_free(report, sizeof (*report));
721 730 return;
722 731 }
723 732 #endif
724 733
725 734 mutex_enter(&spa->spa_errlist_lock);
726 735 report->zcr_next = zio->io_logical->io_cksum_report;
727 736 zio->io_logical->io_cksum_report = report;
728 737 mutex_exit(&spa->spa_errlist_lock);
729 738 }
730 739
731 740 void
732 741 zfs_ereport_finish_checksum(zio_cksum_report_t *report,
733 742 const void *good_data, const void *bad_data, boolean_t drop_if_identical)
734 743 {
735 744 #ifdef _KERNEL
736 745 zfs_ecksum_info_t *info = NULL;
737 746 info = annotate_ecksum(report->zcr_ereport, report->zcr_ckinfo,
738 747 good_data, bad_data, report->zcr_length, drop_if_identical);
739 748
740 749 if (info != NULL)
741 750 fm_ereport_post(report->zcr_ereport, EVCH_SLEEP);
742 751
743 752 fm_nvlist_destroy(report->zcr_ereport, FM_NVA_FREE);
744 753 fm_nvlist_destroy(report->zcr_detector, FM_NVA_FREE);
745 754 report->zcr_ereport = report->zcr_detector = NULL;
746 755
747 756 if (info != NULL)
748 757 kmem_free(info, sizeof (*info));
749 758 #endif
750 759 }
751 760
752 761 void
753 762 zfs_ereport_free_checksum(zio_cksum_report_t *rpt)
754 763 {
755 764 #ifdef _KERNEL
756 765 if (rpt->zcr_ereport != NULL) {
757 766 fm_nvlist_destroy(rpt->zcr_ereport,
758 767 FM_NVA_FREE);
759 768 fm_nvlist_destroy(rpt->zcr_detector,
760 769 FM_NVA_FREE);
761 770 }
762 771 #endif
763 772 rpt->zcr_free(rpt->zcr_cbdata, rpt->zcr_cbinfo);
764 773
765 774 if (rpt->zcr_ckinfo != NULL)
766 775 kmem_free(rpt->zcr_ckinfo, sizeof (*rpt->zcr_ckinfo));
767 776
768 777 kmem_free(rpt, sizeof (*rpt));
769 778 }
770 779
771 780 void
772 781 zfs_ereport_send_interim_checksum(zio_cksum_report_t *report)
773 782 {
774 783 #ifdef _KERNEL
775 784 fm_ereport_post(report->zcr_ereport, EVCH_SLEEP);
776 785 #endif
777 786 }
778 787
779 788 void
780 789 zfs_ereport_post_checksum(spa_t *spa, vdev_t *vd,
781 790 struct zio *zio, uint64_t offset, uint64_t length,
782 791 const void *good_data, const void *bad_data, zio_bad_cksum_t *zbc)
783 792 {
784 793 #ifdef _KERNEL
785 794 nvlist_t *ereport = NULL;
786 795 nvlist_t *detector = NULL;
787 796 zfs_ecksum_info_t *info;
788 797
789 798 zfs_ereport_start(&ereport, &detector,
790 799 FM_EREPORT_ZFS_CHECKSUM, spa, vd, zio, offset, length);
791 800
792 801 if (ereport == NULL)
793 802 return;
794 803
795 804 info = annotate_ecksum(ereport, zbc, good_data, bad_data, length,
796 805 B_FALSE);
797 806
798 807 if (info != NULL)
799 808 fm_ereport_post(ereport, EVCH_SLEEP);
800 809
801 810 fm_nvlist_destroy(ereport, FM_NVA_FREE);
802 811 fm_nvlist_destroy(detector, FM_NVA_FREE);
803 812
804 813 if (info != NULL)
805 814 kmem_free(info, sizeof (*info));
806 815 #endif
807 816 }
808 817
809 818 static void
810 819 zfs_post_common(spa_t *spa, vdev_t *vd, const char *name)
811 820 {
812 821 #ifdef _KERNEL
813 822 nvlist_t *resource;
814 823 char class[64];
815 824
816 825 if (spa_load_state(spa) == SPA_LOAD_TRYIMPORT)
817 826 return;
818 827
819 828 if ((resource = fm_nvlist_create(NULL)) == NULL)
820 829 return;
821 830
822 831 (void) snprintf(class, sizeof (class), "%s.%s.%s", FM_RSRC_RESOURCE,
823 832 ZFS_ERROR_CLASS, name);
824 833 VERIFY(nvlist_add_uint8(resource, FM_VERSION, FM_RSRC_VERSION) == 0);
825 834 VERIFY(nvlist_add_string(resource, FM_CLASS, class) == 0);
826 835 VERIFY(nvlist_add_uint64(resource,
827 836 FM_EREPORT_PAYLOAD_ZFS_POOL_GUID, spa_guid(spa)) == 0);
828 837 if (vd)
829 838 VERIFY(nvlist_add_uint64(resource,
830 839 FM_EREPORT_PAYLOAD_ZFS_VDEV_GUID, vd->vdev_guid) == 0);
831 840
832 841 fm_ereport_post(resource, EVCH_SLEEP);
833 842
834 843 fm_nvlist_destroy(resource, FM_NVA_FREE);
835 844 #endif
836 845 }
837 846
838 847 /*
839 848 * The 'resource.fs.zfs.removed' event is an internal signal that the given vdev
840 849 * has been removed from the system. This will cause the DE to ignore any
841 850 * recent I/O errors, inferring that they are due to the asynchronous device
842 851 * removal.
843 852 */
844 853 void
845 854 zfs_post_remove(spa_t *spa, vdev_t *vd)
846 855 {
847 856 zfs_post_common(spa, vd, FM_RESOURCE_REMOVED);
848 857 }
849 858
850 859 /*
851 860 * The 'resource.fs.zfs.autoreplace' event is an internal signal that the pool
852 861 * has the 'autoreplace' property set, and therefore any broken vdevs will be
853 862 * handled by higher level logic, and no vdev fault should be generated.
854 863 */
855 864 void
856 865 zfs_post_autoreplace(spa_t *spa, vdev_t *vd)
857 866 {
858 867 zfs_post_common(spa, vd, FM_RESOURCE_AUTOREPLACE);
859 868 }
860 869
861 870 /*
862 871 * The 'resource.fs.zfs.statechange' event is an internal signal that the
863 872 * given vdev has transitioned its state to DEGRADED or HEALTHY. This will
864 873 * cause the retire agent to repair any outstanding fault management cases
865 874 * open because the device was not found (fault.fs.zfs.device).
866 875 */
867 876 void
868 877 zfs_post_state_change(spa_t *spa, vdev_t *vd)
869 878 {
870 879 zfs_post_common(spa, vd, FM_RESOURCE_STATECHANGE);
871 880 }
|
↓ open down ↓ |
201 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX