zio.h revision 288571
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22/* 23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 24 * Copyright 2011 Nexenta Systems, Inc. All rights reserved. 25 * Copyright (c) 2012, 2014 by Delphix. All rights reserved. 26 * Copyright (c) 2013 by Saso Kiselkov. All rights reserved. 27 */ 28 29#ifndef _ZIO_H 30#define _ZIO_H 31 32#include <sys/zio_priority.h> 33#include <sys/zfs_context.h> 34#include <sys/spa.h> 35#include <sys/txg.h> 36#include <sys/avl.h> 37#include <sys/kstat.h> 38#include <sys/fs/zfs.h> 39#include <sys/zio_impl.h> 40 41#ifdef __cplusplus 42extern "C" { 43#endif 44 45/* 46 * Embedded checksum 47 */ 48#define ZEC_MAGIC 0x210da7ab10c7a11ULL 49 50typedef struct zio_eck { 51 uint64_t zec_magic; /* for validation, endianness */ 52 zio_cksum_t zec_cksum; /* 256-bit checksum */ 53} zio_eck_t; 54 55/* 56 * Gang block headers are self-checksumming and contain an array 57 * of block pointers. 58 */ 59#define SPA_GANGBLOCKSIZE SPA_MINBLOCKSIZE 60#define SPA_GBH_NBLKPTRS ((SPA_GANGBLOCKSIZE - \ 61 sizeof (zio_eck_t)) / sizeof (blkptr_t)) 62#define SPA_GBH_FILLER ((SPA_GANGBLOCKSIZE - \ 63 sizeof (zio_eck_t) - \ 64 (SPA_GBH_NBLKPTRS * sizeof (blkptr_t))) /\ 65 sizeof (uint64_t)) 66 67typedef struct zio_gbh { 68 blkptr_t zg_blkptr[SPA_GBH_NBLKPTRS]; 69 uint64_t zg_filler[SPA_GBH_FILLER]; 70 zio_eck_t zg_tail; 71} zio_gbh_phys_t; 72 73enum zio_checksum { 74 ZIO_CHECKSUM_INHERIT = 0, 75 ZIO_CHECKSUM_ON, 76 ZIO_CHECKSUM_OFF, 77 ZIO_CHECKSUM_LABEL, 78 ZIO_CHECKSUM_GANG_HEADER, 79 ZIO_CHECKSUM_ZILOG, 80 ZIO_CHECKSUM_FLETCHER_2, 81 ZIO_CHECKSUM_FLETCHER_4, 82 ZIO_CHECKSUM_SHA256, 83 ZIO_CHECKSUM_ZILOG2, 84 ZIO_CHECKSUM_NOPARITY, 85 ZIO_CHECKSUM_FUNCTIONS 86}; 87 88/* 89 * The number of "legacy" compression functions which can be set on individual 90 * objects. 91 */ 92#define ZIO_CHECKSUM_LEGACY_FUNCTIONS ZIO_CHECKSUM_ZILOG2 93 94#define ZIO_CHECKSUM_ON_VALUE ZIO_CHECKSUM_FLETCHER_4 95#define ZIO_CHECKSUM_DEFAULT ZIO_CHECKSUM_ON 96 97#define ZIO_CHECKSUM_MASK 0xffULL 98#define ZIO_CHECKSUM_VERIFY (1 << 8) 99 100#define ZIO_DEDUPCHECKSUM ZIO_CHECKSUM_SHA256 101#define ZIO_DEDUPDITTO_MIN 100 102 103enum zio_compress { 104 ZIO_COMPRESS_INHERIT = 0, 105 ZIO_COMPRESS_ON, 106 ZIO_COMPRESS_OFF, 107 ZIO_COMPRESS_LZJB, 108 ZIO_COMPRESS_EMPTY, 109 ZIO_COMPRESS_GZIP_1, 110 ZIO_COMPRESS_GZIP_2, 111 ZIO_COMPRESS_GZIP_3, 112 ZIO_COMPRESS_GZIP_4, 113 ZIO_COMPRESS_GZIP_5, 114 ZIO_COMPRESS_GZIP_6, 115 ZIO_COMPRESS_GZIP_7, 116 ZIO_COMPRESS_GZIP_8, 117 ZIO_COMPRESS_GZIP_9, 118 ZIO_COMPRESS_ZLE, 119 ZIO_COMPRESS_LZ4, 120 ZIO_COMPRESS_FUNCTIONS 121}; 122 123/* 124 * The number of "legacy" compression functions which can be set on individual 125 * objects. 126 */ 127#define ZIO_COMPRESS_LEGACY_FUNCTIONS ZIO_COMPRESS_LZ4 128 129/* 130 * The meaning of "compress = on" selected by the compression features enabled 131 * on a given pool. 132 */ 133#define ZIO_COMPRESS_LEGACY_ON_VALUE ZIO_COMPRESS_LZJB 134#define ZIO_COMPRESS_LZ4_ON_VALUE ZIO_COMPRESS_LZ4 135 136#define ZIO_COMPRESS_DEFAULT ZIO_COMPRESS_OFF 137 138#define BOOTFS_COMPRESS_VALID(compress) \ 139 ((compress) == ZIO_COMPRESS_LZJB || \ 140 (compress) == ZIO_COMPRESS_LZ4 || \ 141 (compress) == ZIO_COMPRESS_ON || \ 142 (compress) == ZIO_COMPRESS_OFF) 143 144#define ZIO_FAILURE_MODE_WAIT 0 145#define ZIO_FAILURE_MODE_CONTINUE 1 146#define ZIO_FAILURE_MODE_PANIC 2 147 148#define ZIO_PIPELINE_CONTINUE 0x100 149#define ZIO_PIPELINE_STOP 0x101 150 151enum zio_flag { 152 /* 153 * Flags inherited by gang, ddt, and vdev children, 154 * and that must be equal for two zios to aggregate 155 */ 156 ZIO_FLAG_DONT_AGGREGATE = 1 << 0, 157 ZIO_FLAG_IO_REPAIR = 1 << 1, 158 ZIO_FLAG_SELF_HEAL = 1 << 2, 159 ZIO_FLAG_RESILVER = 1 << 3, 160 ZIO_FLAG_SCRUB = 1 << 4, 161 ZIO_FLAG_SCAN_THREAD = 1 << 5, 162 ZIO_FLAG_PHYSICAL = 1 << 6, 163 164#define ZIO_FLAG_AGG_INHERIT (ZIO_FLAG_CANFAIL - 1) 165 166 /* 167 * Flags inherited by ddt, gang, and vdev children. 168 */ 169 ZIO_FLAG_CANFAIL = 1 << 7, /* must be first for INHERIT */ 170 ZIO_FLAG_SPECULATIVE = 1 << 8, 171 ZIO_FLAG_CONFIG_WRITER = 1 << 9, 172 ZIO_FLAG_DONT_RETRY = 1 << 10, 173 ZIO_FLAG_DONT_CACHE = 1 << 11, 174 ZIO_FLAG_NODATA = 1 << 12, 175 ZIO_FLAG_INDUCE_DAMAGE = 1 << 13, 176 177#define ZIO_FLAG_DDT_INHERIT (ZIO_FLAG_IO_RETRY - 1) 178#define ZIO_FLAG_GANG_INHERIT (ZIO_FLAG_IO_RETRY - 1) 179 180 /* 181 * Flags inherited by vdev children. 182 */ 183 ZIO_FLAG_IO_RETRY = 1 << 14, /* must be first for INHERIT */ 184 ZIO_FLAG_PROBE = 1 << 15, 185 ZIO_FLAG_TRYHARD = 1 << 16, 186 ZIO_FLAG_OPTIONAL = 1 << 17, 187 188#define ZIO_FLAG_VDEV_INHERIT (ZIO_FLAG_DONT_QUEUE - 1) 189 190 /* 191 * Flags not inherited by any children. 192 */ 193 ZIO_FLAG_DONT_QUEUE = 1 << 18, /* must be first for INHERIT */ 194 ZIO_FLAG_DONT_PROPAGATE = 1 << 19, 195 ZIO_FLAG_IO_BYPASS = 1 << 20, 196 ZIO_FLAG_IO_REWRITE = 1 << 21, 197 ZIO_FLAG_RAW = 1 << 22, 198 ZIO_FLAG_GANG_CHILD = 1 << 23, 199 ZIO_FLAG_DDT_CHILD = 1 << 24, 200 ZIO_FLAG_GODFATHER = 1 << 25, 201 ZIO_FLAG_NOPWRITE = 1 << 26, 202 ZIO_FLAG_REEXECUTED = 1 << 27, 203 ZIO_FLAG_DELEGATED = 1 << 28, 204}; 205 206#define ZIO_FLAG_MUSTSUCCEED 0 207 208#define ZIO_DDT_CHILD_FLAGS(zio) \ 209 (((zio)->io_flags & ZIO_FLAG_DDT_INHERIT) | \ 210 ZIO_FLAG_DDT_CHILD | ZIO_FLAG_CANFAIL) 211 212#define ZIO_GANG_CHILD_FLAGS(zio) \ 213 (((zio)->io_flags & ZIO_FLAG_GANG_INHERIT) | \ 214 ZIO_FLAG_GANG_CHILD | ZIO_FLAG_CANFAIL) 215 216#define ZIO_VDEV_CHILD_FLAGS(zio) \ 217 (((zio)->io_flags & ZIO_FLAG_VDEV_INHERIT) | \ 218 ZIO_FLAG_CANFAIL) 219 220enum zio_child { 221 ZIO_CHILD_VDEV = 0, 222 ZIO_CHILD_GANG, 223 ZIO_CHILD_DDT, 224 ZIO_CHILD_LOGICAL, 225 ZIO_CHILD_TYPES 226}; 227 228enum zio_wait_type { 229 ZIO_WAIT_READY = 0, 230 ZIO_WAIT_DONE, 231 ZIO_WAIT_TYPES 232}; 233 234/* 235 * We'll take the number 122 and 123 to indicate checksum errors and 236 * fragmentation. Those doesn't collide with any errno values as they 237 * are greater than ELAST. 238 */ 239#define ECKSUM 122 240#define EFRAGS 123 241 242typedef void zio_done_func_t(zio_t *zio); 243 244extern const char *zio_type_name[ZIO_TYPES]; 245 246/* 247 * A bookmark is a four-tuple <objset, object, level, blkid> that uniquely 248 * identifies any block in the pool. By convention, the meta-objset (MOS) 249 * is objset 0, and the meta-dnode is object 0. This covers all blocks 250 * except root blocks and ZIL blocks, which are defined as follows: 251 * 252 * Root blocks (objset_phys_t) are object 0, level -1: <objset, 0, -1, 0>. 253 * ZIL blocks are bookmarked <objset, 0, -2, blkid == ZIL sequence number>. 254 * dmu_sync()ed ZIL data blocks are bookmarked <objset, object, -2, blkid>. 255 * dnode visit bookmarks are <objset, object id of dnode, -3, 0>. 256 * 257 * Note: this structure is called a bookmark because its original purpose 258 * was to remember where to resume a pool-wide traverse. 259 * 260 * Note: this structure is passed between userland and the kernel, and is 261 * stored on disk (by virtue of being incorporated into other on-disk 262 * structures, e.g. dsl_scan_phys_t). 263 */ 264typedef struct zbookmark_phys { 265 uint64_t zb_objset; 266 uint64_t zb_object; 267 int64_t zb_level; 268 uint64_t zb_blkid; 269} zbookmark_phys_t; 270 271#define SET_BOOKMARK(zb, objset, object, level, blkid) \ 272{ \ 273 (zb)->zb_objset = objset; \ 274 (zb)->zb_object = object; \ 275 (zb)->zb_level = level; \ 276 (zb)->zb_blkid = blkid; \ 277} 278 279#define ZB_DESTROYED_OBJSET (-1ULL) 280 281#define ZB_ROOT_OBJECT (0ULL) 282#define ZB_ROOT_LEVEL (-1LL) 283#define ZB_ROOT_BLKID (0ULL) 284 285#define ZB_ZIL_OBJECT (0ULL) 286#define ZB_ZIL_LEVEL (-2LL) 287 288#define ZB_DNODE_LEVEL (-3LL) 289#define ZB_DNODE_BLKID (0ULL) 290 291#define ZB_IS_ZERO(zb) \ 292 ((zb)->zb_objset == 0 && (zb)->zb_object == 0 && \ 293 (zb)->zb_level == 0 && (zb)->zb_blkid == 0) 294#define ZB_IS_ROOT(zb) \ 295 ((zb)->zb_object == ZB_ROOT_OBJECT && \ 296 (zb)->zb_level == ZB_ROOT_LEVEL && \ 297 (zb)->zb_blkid == ZB_ROOT_BLKID) 298 299typedef struct zio_prop { 300 enum zio_checksum zp_checksum; 301 enum zio_compress zp_compress; 302 dmu_object_type_t zp_type; 303 uint8_t zp_level; 304 uint8_t zp_copies; 305 boolean_t zp_dedup; 306 boolean_t zp_dedup_verify; 307 boolean_t zp_nopwrite; 308} zio_prop_t; 309 310typedef struct zio_cksum_report zio_cksum_report_t; 311 312typedef void zio_cksum_finish_f(zio_cksum_report_t *rep, 313 const void *good_data); 314typedef void zio_cksum_free_f(void *cbdata, size_t size); 315 316struct zio_bad_cksum; /* defined in zio_checksum.h */ 317struct dnode_phys; 318 319struct zio_cksum_report { 320 struct zio_cksum_report *zcr_next; 321 nvlist_t *zcr_ereport; 322 nvlist_t *zcr_detector; 323 void *zcr_cbdata; 324 size_t zcr_cbinfo; /* passed to zcr_free() */ 325 uint64_t zcr_align; 326 uint64_t zcr_length; 327 zio_cksum_finish_f *zcr_finish; 328 zio_cksum_free_f *zcr_free; 329 330 /* internal use only */ 331 struct zio_bad_cksum *zcr_ckinfo; /* information from failure */ 332}; 333 334typedef void zio_vsd_cksum_report_f(zio_t *zio, zio_cksum_report_t *zcr, 335 void *arg); 336 337zio_vsd_cksum_report_f zio_vsd_default_cksum_report; 338 339typedef struct zio_vsd_ops { 340 zio_done_func_t *vsd_free; 341 zio_vsd_cksum_report_f *vsd_cksum_report; 342} zio_vsd_ops_t; 343 344typedef struct zio_gang_node { 345 zio_gbh_phys_t *gn_gbh; 346 struct zio_gang_node *gn_child[SPA_GBH_NBLKPTRS]; 347} zio_gang_node_t; 348 349typedef zio_t *zio_gang_issue_func_t(zio_t *zio, blkptr_t *bp, 350 zio_gang_node_t *gn, void *data); 351 352typedef void zio_transform_func_t(zio_t *zio, void *data, uint64_t size); 353 354typedef struct zio_transform { 355 void *zt_orig_data; 356 uint64_t zt_orig_size; 357 uint64_t zt_bufsize; 358 zio_transform_func_t *zt_transform; 359 struct zio_transform *zt_next; 360} zio_transform_t; 361 362typedef int zio_pipe_stage_t(zio_t *zio); 363 364/* 365 * The io_reexecute flags are distinct from io_flags because the child must 366 * be able to propagate them to the parent. The normal io_flags are local 367 * to the zio, not protected by any lock, and not modifiable by children; 368 * the reexecute flags are protected by io_lock, modifiable by children, 369 * and always propagated -- even when ZIO_FLAG_DONT_PROPAGATE is set. 370 */ 371#define ZIO_REEXECUTE_NOW 0x01 372#define ZIO_REEXECUTE_SUSPEND 0x02 373 374typedef struct zio_link { 375 zio_t *zl_parent; 376 zio_t *zl_child; 377 list_node_t zl_parent_node; 378 list_node_t zl_child_node; 379} zio_link_t; 380 381/* 382 * Used for TRIM kstat. 383 */ 384typedef struct zio_trim_stats { 385 /* 386 * Number of bytes successfully TRIMmed. 387 */ 388 kstat_named_t bytes; 389 390 /* 391 * Number of successful TRIM requests. 392 */ 393 kstat_named_t success; 394 395 /* 396 * Number of TRIM requests that failed because TRIM is not 397 * supported. 398 */ 399 kstat_named_t unsupported; 400 401 /* 402 * Number of TRIM requests that failed for other reasons. 403 */ 404 kstat_named_t failed; 405} zio_trim_stats_t; 406 407extern zio_trim_stats_t zio_trim_stats; 408 409#define ZIO_TRIM_STAT_INCR(stat, val) \ 410 atomic_add_64(&zio_trim_stats.stat.value.ui64, (val)); 411#define ZIO_TRIM_STAT_BUMP(stat) \ 412 ZIO_TRIM_STAT_INCR(stat, 1); 413 414struct zio { 415 /* Core information about this I/O */ 416 zbookmark_phys_t io_bookmark; 417 zio_prop_t io_prop; 418 zio_type_t io_type; 419 enum zio_child io_child_type; 420 int io_cmd; 421 zio_priority_t io_priority; 422 uint8_t io_reexecute; 423 uint8_t io_state[ZIO_WAIT_TYPES]; 424 uint64_t io_txg; 425 spa_t *io_spa; 426 blkptr_t *io_bp; 427 blkptr_t *io_bp_override; 428 blkptr_t io_bp_copy; 429 list_t io_parent_list; 430 list_t io_child_list; 431 zio_link_t *io_walk_link; 432 zio_t *io_logical; 433 zio_transform_t *io_transform_stack; 434 435 /* Callback info */ 436 zio_done_func_t *io_ready; 437 zio_done_func_t *io_physdone; 438 zio_done_func_t *io_done; 439 void *io_private; 440 int64_t io_prev_space_delta; /* DMU private */ 441 blkptr_t io_bp_orig; 442 443 /* Data represented by this I/O */ 444 void *io_data; 445 void *io_orig_data; 446 uint64_t io_size; 447 uint64_t io_orig_size; 448 449 /* Stuff for the vdev stack */ 450 vdev_t *io_vd; 451 void *io_vsd; 452 const zio_vsd_ops_t *io_vsd_ops; 453 454 uint64_t io_offset; 455 hrtime_t io_timestamp; 456 avl_node_t io_queue_node; 457 avl_node_t io_offset_node; 458 459 /* Internal pipeline state */ 460 enum zio_flag io_flags; 461 enum zio_stage io_stage; 462 enum zio_stage io_pipeline; 463 enum zio_flag io_orig_flags; 464 enum zio_stage io_orig_stage; 465 enum zio_stage io_orig_pipeline; 466 int io_error; 467 int io_child_error[ZIO_CHILD_TYPES]; 468 uint64_t io_children[ZIO_CHILD_TYPES][ZIO_WAIT_TYPES]; 469 uint64_t io_child_count; 470 uint64_t io_phys_children; 471 uint64_t io_parent_count; 472 uint64_t *io_stall; 473 zio_t *io_gang_leader; 474 zio_gang_node_t *io_gang_tree; 475 void *io_executor; 476 void *io_waiter; 477 kmutex_t io_lock; 478 kcondvar_t io_cv; 479 480 /* FMA state */ 481 zio_cksum_report_t *io_cksum_report; 482 uint64_t io_ena; 483 484 /* Taskq dispatching state */ 485 taskq_ent_t io_tqent; 486 487 avl_node_t io_trim_node; 488 list_node_t io_trim_link; 489}; 490 491extern zio_t *zio_null(zio_t *pio, spa_t *spa, vdev_t *vd, 492 zio_done_func_t *done, void *priv, enum zio_flag flags); 493 494extern zio_t *zio_root(spa_t *spa, 495 zio_done_func_t *done, void *priv, enum zio_flag flags); 496 497extern zio_t *zio_read(zio_t *pio, spa_t *spa, const blkptr_t *bp, void *data, 498 uint64_t size, zio_done_func_t *done, void *priv, 499 zio_priority_t priority, enum zio_flag flags, const zbookmark_phys_t *zb); 500 501extern zio_t *zio_write(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp, 502 void *data, uint64_t size, const zio_prop_t *zp, 503 zio_done_func_t *ready, zio_done_func_t *physdone, zio_done_func_t *done, 504 void *priv, 505 zio_priority_t priority, enum zio_flag flags, const zbookmark_phys_t *zb); 506 507extern zio_t *zio_rewrite(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp, 508 void *data, uint64_t size, zio_done_func_t *done, void *priv, 509 zio_priority_t priority, enum zio_flag flags, zbookmark_phys_t *zb); 510 511extern void zio_write_override(zio_t *zio, blkptr_t *bp, int copies, 512 boolean_t nopwrite); 513 514extern void zio_free(spa_t *spa, uint64_t txg, const blkptr_t *bp); 515 516extern zio_t *zio_claim(zio_t *pio, spa_t *spa, uint64_t txg, 517 const blkptr_t *bp, 518 zio_done_func_t *done, void *priv, enum zio_flag flags); 519 520extern zio_t *zio_ioctl(zio_t *pio, spa_t *spa, vdev_t *vd, int cmd, 521 uint64_t offset, uint64_t size, zio_done_func_t *done, void *priv, 522 zio_priority_t priority, enum zio_flag flags); 523 524extern zio_t *zio_read_phys(zio_t *pio, vdev_t *vd, uint64_t offset, 525 uint64_t size, void *data, int checksum, 526 zio_done_func_t *done, void *priv, zio_priority_t priority, 527 enum zio_flag flags, boolean_t labels); 528 529extern zio_t *zio_write_phys(zio_t *pio, vdev_t *vd, uint64_t offset, 530 uint64_t size, void *data, int checksum, 531 zio_done_func_t *done, void *priv, zio_priority_t priority, 532 enum zio_flag flags, boolean_t labels); 533 534extern zio_t *zio_free_sync(zio_t *pio, spa_t *spa, uint64_t txg, 535 const blkptr_t *bp, uint64_t size, enum zio_flag flags); 536 537extern int zio_alloc_zil(spa_t *spa, uint64_t txg, blkptr_t *new_bp, 538 blkptr_t *old_bp, uint64_t size, boolean_t use_slog); 539extern void zio_free_zil(spa_t *spa, uint64_t txg, blkptr_t *bp); 540extern void zio_flush(zio_t *zio, vdev_t *vd); 541extern zio_t *zio_trim(zio_t *zio, spa_t *spa, vdev_t *vd, uint64_t offset, 542 uint64_t size); 543extern void zio_shrink(zio_t *zio, uint64_t size); 544 545extern int zio_wait(zio_t *zio); 546extern void zio_nowait(zio_t *zio); 547extern void zio_execute(zio_t *zio); 548extern void zio_interrupt(zio_t *zio); 549 550extern zio_t *zio_walk_parents(zio_t *cio); 551extern zio_t *zio_walk_children(zio_t *pio); 552extern zio_t *zio_unique_parent(zio_t *cio); 553extern void zio_add_child(zio_t *pio, zio_t *cio); 554 555extern void *zio_buf_alloc(size_t size); 556extern void zio_buf_free(void *buf, size_t size); 557extern void *zio_data_buf_alloc(size_t size); 558extern void zio_data_buf_free(void *buf, size_t size); 559 560extern void zio_resubmit_stage_async(void *); 561 562extern zio_t *zio_vdev_child_io(zio_t *zio, blkptr_t *bp, vdev_t *vd, 563 uint64_t offset, void *data, uint64_t size, int type, 564 zio_priority_t priority, enum zio_flag flags, 565 zio_done_func_t *done, void *priv); 566 567extern zio_t *zio_vdev_delegated_io(vdev_t *vd, uint64_t offset, 568 void *data, uint64_t size, int type, zio_priority_t priority, 569 enum zio_flag flags, zio_done_func_t *done, void *priv); 570 571extern void zio_vdev_io_bypass(zio_t *zio); 572extern void zio_vdev_io_reissue(zio_t *zio); 573extern void zio_vdev_io_redone(zio_t *zio); 574 575extern void zio_checksum_verified(zio_t *zio); 576extern int zio_worst_error(int e1, int e2); 577 578extern enum zio_checksum zio_checksum_select(enum zio_checksum child, 579 enum zio_checksum parent); 580extern enum zio_checksum zio_checksum_dedup_select(spa_t *spa, 581 enum zio_checksum child, enum zio_checksum parent); 582extern enum zio_compress zio_compress_select(spa_t *spa, 583 enum zio_compress child, enum zio_compress parent); 584 585extern void zio_suspend(spa_t *spa, zio_t *zio); 586extern int zio_resume(spa_t *spa); 587extern void zio_resume_wait(spa_t *spa); 588 589/* 590 * Initial setup and teardown. 591 */ 592extern void zio_init(void); 593extern void zio_fini(void); 594 595/* 596 * Fault injection 597 */ 598struct zinject_record; 599extern uint32_t zio_injection_enabled; 600extern int zio_inject_fault(char *name, int flags, int *id, 601 struct zinject_record *record); 602extern int zio_inject_list_next(int *id, char *name, size_t buflen, 603 struct zinject_record *record); 604extern int zio_clear_fault(int id); 605extern void zio_handle_panic_injection(spa_t *spa, char *tag, uint64_t type); 606extern int zio_handle_fault_injection(zio_t *zio, int error); 607extern int zio_handle_device_injection(vdev_t *vd, zio_t *zio, int error); 608extern int zio_handle_label_injection(zio_t *zio, int error); 609extern void zio_handle_ignored_writes(zio_t *zio); 610extern uint64_t zio_handle_io_delay(zio_t *zio); 611 612/* 613 * Checksum ereport functions 614 */ 615extern void zfs_ereport_start_checksum(spa_t *spa, vdev_t *vd, struct zio *zio, 616 uint64_t offset, uint64_t length, void *arg, struct zio_bad_cksum *info); 617extern void zfs_ereport_finish_checksum(zio_cksum_report_t *report, 618 const void *good_data, const void *bad_data, boolean_t drop_if_identical); 619 620extern void zfs_ereport_send_interim_checksum(zio_cksum_report_t *report); 621extern void zfs_ereport_free_checksum(zio_cksum_report_t *report); 622 623/* If we have the good data in hand, this function can be used */ 624extern void zfs_ereport_post_checksum(spa_t *spa, vdev_t *vd, 625 struct zio *zio, uint64_t offset, uint64_t length, 626 const void *good_data, const void *bad_data, struct zio_bad_cksum *info); 627 628/* Called from spa_sync(), but primarily an injection handler */ 629extern void spa_handle_ignored_writes(spa_t *spa); 630 631/* zbookmark_phys functions */ 632boolean_t zbookmark_subtree_completed(const struct dnode_phys *dnp, 633 const zbookmark_phys_t *subtree_root, const zbookmark_phys_t *last_block); 634int zbookmark_compare(uint16_t dbss1, uint8_t ibs1, uint16_t dbss2, 635 uint8_t ibs2, const zbookmark_phys_t *zb1, const zbookmark_phys_t *zb2); 636 637#ifdef __cplusplus 638} 639#endif 640 641#endif /* _ZIO_H */ 642