1fa9e4066Sahrens /* 2fa9e4066Sahrens * CDDL HEADER START 3fa9e4066Sahrens * 4fa9e4066Sahrens * The contents of this file are subject to the terms of the 5ea8dc4b6Seschrock * Common Development and Distribution License (the "License"). 6ea8dc4b6Seschrock * You may not use this file except in compliance with the License. 7fa9e4066Sahrens * 8fa9e4066Sahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9fa9e4066Sahrens * or http://www.opensolaris.org/os/licensing. 10fa9e4066Sahrens * See the License for the specific language governing permissions 11fa9e4066Sahrens * and limitations under the License. 12fa9e4066Sahrens * 13fa9e4066Sahrens * When distributing Covered Code, include this CDDL HEADER in each 14fa9e4066Sahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15fa9e4066Sahrens * If applicable, add the following below this CDDL HEADER, with the 16fa9e4066Sahrens * fields enclosed by brackets "[]" replaced with your own identifying 17fa9e4066Sahrens * information: Portions Copyright [yyyy] [name of copyright owner] 18fa9e4066Sahrens * 19fa9e4066Sahrens * CDDL HEADER END 20fa9e4066Sahrens */ 21c9431fa1Sahl 22fa9e4066Sahrens /* 23e7cbe64fSgw * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24fa9e4066Sahrens * Use is subject to license terms. 25fa9e4066Sahrens */ 26fa9e4066Sahrens 27fa9e4066Sahrens #ifndef _ZIO_H 28fa9e4066Sahrens #define _ZIO_H 29fa9e4066Sahrens 30fa9e4066Sahrens #include <sys/zfs_context.h> 31fa9e4066Sahrens #include <sys/spa.h> 32fa9e4066Sahrens #include <sys/txg.h> 33fa9e4066Sahrens #include <sys/avl.h> 34fa9e4066Sahrens #include <sys/fs/zfs.h> 3544cd46caSbillm #include <sys/zio_impl.h> 36fa9e4066Sahrens 37fa9e4066Sahrens #ifdef __cplusplus 38fa9e4066Sahrens extern "C" { 39fa9e4066Sahrens #endif 40fa9e4066Sahrens 41fa9e4066Sahrens #define ZBT_MAGIC 0x210da7ab10c7a11ULL /* zio data bloc tail */ 42fa9e4066Sahrens 43fa9e4066Sahrens typedef struct zio_block_tail { 44fa9e4066Sahrens uint64_t zbt_magic; /* for validation, endianness */ 45fa9e4066Sahrens zio_cksum_t zbt_cksum; /* 256-bit checksum */ 46fa9e4066Sahrens } zio_block_tail_t; 47fa9e4066Sahrens 48fa9e4066Sahrens /* 49fa9e4066Sahrens * Gang block headers are self-checksumming and contain an array 50fa9e4066Sahrens * of block pointers. 51fa9e4066Sahrens */ 52fa9e4066Sahrens #define SPA_GANGBLOCKSIZE SPA_MINBLOCKSIZE 53fa9e4066Sahrens #define SPA_GBH_NBLKPTRS ((SPA_GANGBLOCKSIZE - \ 54fa9e4066Sahrens sizeof (zio_block_tail_t)) / sizeof (blkptr_t)) 55fa9e4066Sahrens #define SPA_GBH_FILLER ((SPA_GANGBLOCKSIZE - \ 56fa9e4066Sahrens sizeof (zio_block_tail_t) - \ 57fa9e4066Sahrens (SPA_GBH_NBLKPTRS * sizeof (blkptr_t))) /\ 58fa9e4066Sahrens sizeof (uint64_t)) 59fa9e4066Sahrens 60fa9e4066Sahrens typedef struct zio_gbh { 61fa9e4066Sahrens blkptr_t zg_blkptr[SPA_GBH_NBLKPTRS]; 62fa9e4066Sahrens uint64_t zg_filler[SPA_GBH_FILLER]; 63fa9e4066Sahrens zio_block_tail_t zg_tail; 64fa9e4066Sahrens } zio_gbh_phys_t; 65fa9e4066Sahrens 66fa9e4066Sahrens enum zio_checksum { 67fa9e4066Sahrens ZIO_CHECKSUM_INHERIT = 0, 68fa9e4066Sahrens ZIO_CHECKSUM_ON, 69fa9e4066Sahrens ZIO_CHECKSUM_OFF, 70fa9e4066Sahrens ZIO_CHECKSUM_LABEL, 71fa9e4066Sahrens ZIO_CHECKSUM_GANG_HEADER, 72fa9e4066Sahrens ZIO_CHECKSUM_ZILOG, 73fa9e4066Sahrens ZIO_CHECKSUM_FLETCHER_2, 74fa9e4066Sahrens ZIO_CHECKSUM_FLETCHER_4, 75fa9e4066Sahrens ZIO_CHECKSUM_SHA256, 76fa9e4066Sahrens ZIO_CHECKSUM_FUNCTIONS 77fa9e4066Sahrens }; 78fa9e4066Sahrens 79fa9e4066Sahrens #define ZIO_CHECKSUM_ON_VALUE ZIO_CHECKSUM_FLETCHER_2 80fa9e4066Sahrens #define ZIO_CHECKSUM_DEFAULT ZIO_CHECKSUM_ON 81fa9e4066Sahrens 82fa9e4066Sahrens enum zio_compress { 83fa9e4066Sahrens ZIO_COMPRESS_INHERIT = 0, 84fa9e4066Sahrens ZIO_COMPRESS_ON, 85fa9e4066Sahrens ZIO_COMPRESS_OFF, 86fa9e4066Sahrens ZIO_COMPRESS_LZJB, 87416e0cd8Sek ZIO_COMPRESS_EMPTY, 88c9431fa1Sahl ZIO_COMPRESS_GZIP_1, 89c9431fa1Sahl ZIO_COMPRESS_GZIP_2, 90c9431fa1Sahl ZIO_COMPRESS_GZIP_3, 91c9431fa1Sahl ZIO_COMPRESS_GZIP_4, 92c9431fa1Sahl ZIO_COMPRESS_GZIP_5, 93c9431fa1Sahl ZIO_COMPRESS_GZIP_6, 94c9431fa1Sahl ZIO_COMPRESS_GZIP_7, 95c9431fa1Sahl ZIO_COMPRESS_GZIP_8, 96c9431fa1Sahl ZIO_COMPRESS_GZIP_9, 97fa9e4066Sahrens ZIO_COMPRESS_FUNCTIONS 98fa9e4066Sahrens }; 99fa9e4066Sahrens 100fa9e4066Sahrens #define ZIO_COMPRESS_ON_VALUE ZIO_COMPRESS_LZJB 101fa9e4066Sahrens #define ZIO_COMPRESS_DEFAULT ZIO_COMPRESS_OFF 102fa9e4066Sahrens 1030a4e9518Sgw #define ZIO_FAILURE_MODE_WAIT 0 1040a4e9518Sgw #define ZIO_FAILURE_MODE_CONTINUE 1 1050a4e9518Sgw #define ZIO_FAILURE_MODE_PANIC 2 1060a4e9518Sgw 107fa9e4066Sahrens #define ZIO_PRIORITY_NOW (zio_priority_table[0]) 108fa9e4066Sahrens #define ZIO_PRIORITY_SYNC_READ (zio_priority_table[1]) 109fa9e4066Sahrens #define ZIO_PRIORITY_SYNC_WRITE (zio_priority_table[2]) 110fa9e4066Sahrens #define ZIO_PRIORITY_ASYNC_READ (zio_priority_table[3]) 111fa9e4066Sahrens #define ZIO_PRIORITY_ASYNC_WRITE (zio_priority_table[4]) 112fa9e4066Sahrens #define ZIO_PRIORITY_FREE (zio_priority_table[5]) 113fa9e4066Sahrens #define ZIO_PRIORITY_CACHE_FILL (zio_priority_table[6]) 114fa9e4066Sahrens #define ZIO_PRIORITY_LOG_WRITE (zio_priority_table[7]) 115fa9e4066Sahrens #define ZIO_PRIORITY_RESILVER (zio_priority_table[8]) 116fa9e4066Sahrens #define ZIO_PRIORITY_SCRUB (zio_priority_table[9]) 117fa9e4066Sahrens #define ZIO_PRIORITY_TABLE_SIZE 10 118fa9e4066Sahrens 119ea8dc4b6Seschrock #define ZIO_FLAG_MUSTSUCCEED 0x00000 120ea8dc4b6Seschrock #define ZIO_FLAG_CANFAIL 0x00001 121e14bb325SJeff Bonwick #define ZIO_FLAG_SPECULATIVE 0x00002 122e14bb325SJeff Bonwick #define ZIO_FLAG_CONFIG_WRITER 0x00004 123e14bb325SJeff Bonwick #define ZIO_FLAG_DONT_RETRY 0x00008 124fa9e4066Sahrens 125ea8dc4b6Seschrock #define ZIO_FLAG_DONT_CACHE 0x00010 126ea8dc4b6Seschrock #define ZIO_FLAG_DONT_QUEUE 0x00020 127e14bb325SJeff Bonwick #define ZIO_FLAG_DONT_AGGREGATE 0x00040 128e14bb325SJeff Bonwick #define ZIO_FLAG_DONT_PROPAGATE 0x00080 129fa9e4066Sahrens 130e14bb325SJeff Bonwick #define ZIO_FLAG_IO_BYPASS 0x00100 131e14bb325SJeff Bonwick #define ZIO_FLAG_IO_REPAIR 0x00200 132e14bb325SJeff Bonwick #define ZIO_FLAG_IO_RETRY 0x00400 133e14bb325SJeff Bonwick #define ZIO_FLAG_IO_REWRITE 0x00800 134fa9e4066Sahrens 135e14bb325SJeff Bonwick #define ZIO_FLAG_PROBE 0x01000 136e14bb325SJeff Bonwick #define ZIO_FLAG_RESILVER 0x02000 137e14bb325SJeff Bonwick #define ZIO_FLAG_SCRUB 0x04000 138e14bb325SJeff Bonwick #define ZIO_FLAG_SCRUB_THREAD 0x08000 139ea8dc4b6Seschrock 140e14bb325SJeff Bonwick #define ZIO_FLAG_GANG_CHILD 0x10000 1419bc11082Sek 142fa9e4066Sahrens #define ZIO_FLAG_GANG_INHERIT \ 143fa9e4066Sahrens (ZIO_FLAG_CANFAIL | \ 144fa9e4066Sahrens ZIO_FLAG_SPECULATIVE | \ 145e14bb325SJeff Bonwick ZIO_FLAG_CONFIG_WRITER | \ 146e14bb325SJeff Bonwick ZIO_FLAG_DONT_RETRY | \ 147e14bb325SJeff Bonwick ZIO_FLAG_DONT_CACHE | \ 148e14bb325SJeff Bonwick ZIO_FLAG_DONT_AGGREGATE | \ 149fa9e4066Sahrens ZIO_FLAG_RESILVER | \ 150d80c45e0Sbonwick ZIO_FLAG_SCRUB | \ 151e14bb325SJeff Bonwick ZIO_FLAG_SCRUB_THREAD) 152fa9e4066Sahrens 153fa9e4066Sahrens #define ZIO_FLAG_VDEV_INHERIT \ 154fa9e4066Sahrens (ZIO_FLAG_GANG_INHERIT | \ 155e14bb325SJeff Bonwick ZIO_FLAG_IO_REPAIR | \ 156e14bb325SJeff Bonwick ZIO_FLAG_IO_RETRY | \ 157e14bb325SJeff Bonwick ZIO_FLAG_PROBE) 15817f17c2dSbonwick 159e05725b1Sbonwick #define ZIO_PIPELINE_CONTINUE 0x100 160e05725b1Sbonwick #define ZIO_PIPELINE_STOP 0x101 161e05725b1Sbonwick 162e14bb325SJeff Bonwick #define ZIO_GANG_CHILD_FLAGS(zio) \ 163e14bb325SJeff Bonwick (((zio)->io_flags & ZIO_FLAG_GANG_INHERIT) | \ 164e14bb325SJeff Bonwick ZIO_FLAG_GANG_CHILD | ZIO_FLAG_CANFAIL) 165e14bb325SJeff Bonwick 166e14bb325SJeff Bonwick enum zio_child { 167e14bb325SJeff Bonwick ZIO_CHILD_VDEV = 0, 168e14bb325SJeff Bonwick ZIO_CHILD_GANG, 169e14bb325SJeff Bonwick ZIO_CHILD_LOGICAL, 170e14bb325SJeff Bonwick ZIO_CHILD_TYPES 171e14bb325SJeff Bonwick }; 172e14bb325SJeff Bonwick 173e14bb325SJeff Bonwick enum zio_wait_type { 174e14bb325SJeff Bonwick ZIO_WAIT_READY = 0, 175e14bb325SJeff Bonwick ZIO_WAIT_DONE, 176e14bb325SJeff Bonwick ZIO_WAIT_TYPES 177e14bb325SJeff Bonwick }; 178e14bb325SJeff Bonwick 179fa9e4066Sahrens /* 180e7cbe64fSgw * We'll take the unused errnos, 'EBADE' and 'EBADR' (from the Convergent 181e7cbe64fSgw * graveyard) to indicate checksum errors and fragmentation. 182fa9e4066Sahrens */ 183fa9e4066Sahrens #define ECKSUM EBADE 184e7cbe64fSgw #define EFRAGS EBADR 185fa9e4066Sahrens 186fa9e4066Sahrens typedef struct zio zio_t; 187fa9e4066Sahrens typedef void zio_done_func_t(zio_t *zio); 188fa9e4066Sahrens 189fa9e4066Sahrens extern uint8_t zio_priority_table[ZIO_PRIORITY_TABLE_SIZE]; 190fa9e4066Sahrens extern char *zio_type_name[ZIO_TYPES]; 191fa9e4066Sahrens 192ea8dc4b6Seschrock /* 193ea8dc4b6Seschrock * A bookmark is a four-tuple <objset, object, level, blkid> that uniquely 194ea8dc4b6Seschrock * identifies any block in the pool. By convention, the meta-objset (MOS) 195ea8dc4b6Seschrock * is objset 0, the meta-dnode is object 0, the root block (osphys_t) is 196ea8dc4b6Seschrock * level -1 of the meta-dnode, and intent log blocks (which are chained 197ea8dc4b6Seschrock * off the root block) have blkid == sequence number. In summary: 198ea8dc4b6Seschrock * 199ea8dc4b6Seschrock * mos is objset 0 200ea8dc4b6Seschrock * meta-dnode is object 0 201ea8dc4b6Seschrock * root block is <objset, 0, -1, 0> 202ea8dc4b6Seschrock * intent log is <objset, 0, -1, ZIL sequence number> 203ea8dc4b6Seschrock * 204ea8dc4b6Seschrock * Note: this structure is called a bookmark because its first purpose was 205ea8dc4b6Seschrock * to remember where to resume a pool-wide traverse. The absolute ordering 206ea8dc4b6Seschrock * for block visitation during traversal is defined in compare_bookmark(). 207ea8dc4b6Seschrock * 208ea8dc4b6Seschrock * Note: this structure is passed between userland and the kernel. 209ea8dc4b6Seschrock * Therefore it must not change size or alignment between 32/64 bit 210ea8dc4b6Seschrock * compilation options. 211ea8dc4b6Seschrock */ 212ea8dc4b6Seschrock typedef struct zbookmark { 213ea8dc4b6Seschrock uint64_t zb_objset; 214ea8dc4b6Seschrock uint64_t zb_object; 215ea8dc4b6Seschrock int64_t zb_level; 216ea8dc4b6Seschrock uint64_t zb_blkid; 217ea8dc4b6Seschrock } zbookmark_t; 218ea8dc4b6Seschrock 219e14bb325SJeff Bonwick typedef struct zio_prop { 220e14bb325SJeff Bonwick enum zio_checksum zp_checksum; 221e14bb325SJeff Bonwick enum zio_compress zp_compress; 222e14bb325SJeff Bonwick dmu_object_type_t zp_type; 223e14bb325SJeff Bonwick uint8_t zp_level; 224e14bb325SJeff Bonwick uint8_t zp_ndvas; 225e14bb325SJeff Bonwick } zio_prop_t; 226e14bb325SJeff Bonwick 227e14bb325SJeff Bonwick typedef struct zio_gang_node { 228e14bb325SJeff Bonwick zio_gbh_phys_t *gn_gbh; 229e14bb325SJeff Bonwick struct zio_gang_node *gn_child[SPA_GBH_NBLKPTRS]; 230e14bb325SJeff Bonwick } zio_gang_node_t; 231e14bb325SJeff Bonwick 232e14bb325SJeff Bonwick typedef zio_t *zio_gang_issue_func_t(zio_t *zio, blkptr_t *bp, 233e14bb325SJeff Bonwick zio_gang_node_t *gn, void *data); 234e14bb325SJeff Bonwick 235e14bb325SJeff Bonwick typedef void zio_transform_func_t(zio_t *zio, void *data, uint64_t size); 236e14bb325SJeff Bonwick 237e14bb325SJeff Bonwick typedef struct zio_transform { 238e14bb325SJeff Bonwick void *zt_orig_data; 239e14bb325SJeff Bonwick uint64_t zt_orig_size; 240e14bb325SJeff Bonwick uint64_t zt_bufsize; 241e14bb325SJeff Bonwick zio_transform_func_t *zt_transform; 242e14bb325SJeff Bonwick struct zio_transform *zt_next; 243e14bb325SJeff Bonwick } zio_transform_t; 244e14bb325SJeff Bonwick 245e14bb325SJeff Bonwick typedef int zio_pipe_stage_t(zio_t *zio); 246e14bb325SJeff Bonwick 247e14bb325SJeff Bonwick /* 248e14bb325SJeff Bonwick * The io_reexecute flags are distinct from io_flags because the child must 249e14bb325SJeff Bonwick * be able to propagate them to the parent. The normal io_flags are local 250e14bb325SJeff Bonwick * to the zio, not protected by any lock, and not modifiable by children; 251e14bb325SJeff Bonwick * the reexecute flags are protected by io_lock, modifiable by children, 252e14bb325SJeff Bonwick * and always propagated -- even when ZIO_FLAG_DONT_PROPAGATE is set. 253e14bb325SJeff Bonwick */ 254e14bb325SJeff Bonwick #define ZIO_REEXECUTE_NOW 0x01 255e14bb325SJeff Bonwick #define ZIO_REEXECUTE_SUSPEND 0x02 256e14bb325SJeff Bonwick 257fa9e4066Sahrens struct zio { 258fa9e4066Sahrens /* Core information about this I/O */ 259ea8dc4b6Seschrock zbookmark_t io_bookmark; 260e14bb325SJeff Bonwick zio_prop_t io_prop; 261e14bb325SJeff Bonwick zio_type_t io_type; 262e14bb325SJeff Bonwick enum zio_child io_child_type; 263e14bb325SJeff Bonwick int io_cmd; 264e14bb325SJeff Bonwick uint8_t io_priority; 265e14bb325SJeff Bonwick uint8_t io_reexecute; 266e14bb325SJeff Bonwick uint8_t io_async_root; 267fa9e4066Sahrens uint64_t io_txg; 268e14bb325SJeff Bonwick spa_t *io_spa; 269fa9e4066Sahrens blkptr_t *io_bp; 270fa9e4066Sahrens blkptr_t io_bp_copy; 271e14bb325SJeff Bonwick zio_t *io_parent; 272fa9e4066Sahrens zio_t *io_child; 273fa9e4066Sahrens zio_t *io_sibling_prev; 274fa9e4066Sahrens zio_t *io_sibling_next; 275ea8dc4b6Seschrock zio_t *io_logical; 276e14bb325SJeff Bonwick zio_transform_t *io_transform_stack; 277fa9e4066Sahrens 278fa9e4066Sahrens /* Callback info */ 279c717a561Smaybee zio_done_func_t *io_ready; 280fa9e4066Sahrens zio_done_func_t *io_done; 281fa9e4066Sahrens void *io_private; 282fa9e4066Sahrens blkptr_t io_bp_orig; 283fa9e4066Sahrens 284fa9e4066Sahrens /* Data represented by this I/O */ 285fa9e4066Sahrens void *io_data; 286fa9e4066Sahrens uint64_t io_size; 287fa9e4066Sahrens 288fa9e4066Sahrens /* Stuff for the vdev stack */ 289fa9e4066Sahrens vdev_t *io_vd; 290fa9e4066Sahrens void *io_vsd; 291e14bb325SJeff Bonwick zio_done_func_t *io_vsd_free; 292fa9e4066Sahrens uint64_t io_offset; 293fa9e4066Sahrens uint64_t io_deadline; 294fa9e4066Sahrens avl_node_t io_offset_node; 295fa9e4066Sahrens avl_node_t io_deadline_node; 296fa9e4066Sahrens avl_tree_t *io_vdev_tree; 297fa9e4066Sahrens zio_t *io_delegate_list; 298fa9e4066Sahrens zio_t *io_delegate_next; 299fa9e4066Sahrens 300fa9e4066Sahrens /* Internal pipeline state */ 301fa9e4066Sahrens int io_flags; 302e14bb325SJeff Bonwick zio_stage_t io_stage; 303fa9e4066Sahrens uint32_t io_pipeline; 304e14bb325SJeff Bonwick int io_orig_flags; 305e14bb325SJeff Bonwick zio_stage_t io_orig_stage; 3060a4e9518Sgw uint32_t io_orig_pipeline; 307e14bb325SJeff Bonwick int io_error; 308e14bb325SJeff Bonwick int io_child_error[ZIO_CHILD_TYPES]; 309e14bb325SJeff Bonwick uint64_t io_children[ZIO_CHILD_TYPES][ZIO_WAIT_TYPES]; 310e14bb325SJeff Bonwick uint64_t *io_stall; 311e14bb325SJeff Bonwick zio_gang_node_t *io_gang_tree; 312e14bb325SJeff Bonwick void *io_executor; 313fa9e4066Sahrens void *io_waiter; 314fa9e4066Sahrens kmutex_t io_lock; 315fa9e4066Sahrens kcondvar_t io_cv; 316ea8dc4b6Seschrock 317ea8dc4b6Seschrock /* FMA state */ 318ea8dc4b6Seschrock uint64_t io_ena; 319fa9e4066Sahrens }; 320fa9e4066Sahrens 321fa9e4066Sahrens extern zio_t *zio_null(zio_t *pio, spa_t *spa, 322fa9e4066Sahrens zio_done_func_t *done, void *private, int flags); 323fa9e4066Sahrens 324fa9e4066Sahrens extern zio_t *zio_root(spa_t *spa, 325fa9e4066Sahrens zio_done_func_t *done, void *private, int flags); 326fa9e4066Sahrens 327088f3894Sahrens extern zio_t *zio_read(zio_t *pio, spa_t *spa, const blkptr_t *bp, void *data, 328fa9e4066Sahrens uint64_t size, zio_done_func_t *done, void *private, 329088f3894Sahrens int priority, int flags, const zbookmark_t *zb); 330fa9e4066Sahrens 331e14bb325SJeff Bonwick extern zio_t *zio_write(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp, 332e14bb325SJeff Bonwick void *data, uint64_t size, zio_prop_t *zp, 333e14bb325SJeff Bonwick zio_done_func_t *ready, zio_done_func_t *done, void *private, 334e14bb325SJeff Bonwick int priority, int flags, const zbookmark_t *zb); 335fa9e4066Sahrens 336e14bb325SJeff Bonwick extern zio_t *zio_rewrite(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp, 337e14bb325SJeff Bonwick void *data, uint64_t size, zio_done_func_t *done, void *private, 338e14bb325SJeff Bonwick int priority, int flags, zbookmark_t *zb); 339fa9e4066Sahrens 340*82c9918fSTim Haley extern void zio_skip_write(zio_t *zio); 341*82c9918fSTim Haley 342fa9e4066Sahrens extern zio_t *zio_free(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp, 343e14bb325SJeff Bonwick zio_done_func_t *done, void *private, int flags); 344fa9e4066Sahrens 345fa9e4066Sahrens extern zio_t *zio_claim(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp, 346e14bb325SJeff Bonwick zio_done_func_t *done, void *private, int flags); 347fa9e4066Sahrens 348fa9e4066Sahrens extern zio_t *zio_ioctl(zio_t *pio, spa_t *spa, vdev_t *vd, int cmd, 349fa9e4066Sahrens zio_done_func_t *done, void *private, int priority, int flags); 350fa9e4066Sahrens 351fa9e4066Sahrens extern zio_t *zio_read_phys(zio_t *pio, vdev_t *vd, uint64_t offset, 352fa9e4066Sahrens uint64_t size, void *data, int checksum, 353fa94a07fSbrendan zio_done_func_t *done, void *private, int priority, int flags, 354fa94a07fSbrendan boolean_t labels); 355fa9e4066Sahrens 356fa9e4066Sahrens extern zio_t *zio_write_phys(zio_t *pio, vdev_t *vd, uint64_t offset, 357fa9e4066Sahrens uint64_t size, void *data, int checksum, 358fa94a07fSbrendan zio_done_func_t *done, void *private, int priority, int flags, 359fa94a07fSbrendan boolean_t labels); 360fa9e4066Sahrens 36167bd71c6Sperrin extern int zio_alloc_blk(spa_t *spa, uint64_t size, blkptr_t *new_bp, 36267bd71c6Sperrin blkptr_t *old_bp, uint64_t txg); 363fa9e4066Sahrens extern void zio_free_blk(spa_t *spa, blkptr_t *bp, uint64_t txg); 36417f17c2dSbonwick extern void zio_flush(zio_t *zio, vdev_t *vd); 365fa9e4066Sahrens 366fa9e4066Sahrens extern int zio_wait(zio_t *zio); 367fa9e4066Sahrens extern void zio_nowait(zio_t *zio); 368e05725b1Sbonwick extern void zio_execute(zio_t *zio); 369e05725b1Sbonwick extern void zio_interrupt(zio_t *zio); 370e05725b1Sbonwick 371fa9e4066Sahrens extern void *zio_buf_alloc(size_t size); 372fa9e4066Sahrens extern void zio_buf_free(void *buf, size_t size); 373ad23a2dbSjohansen extern void *zio_data_buf_alloc(size_t size); 374ad23a2dbSjohansen extern void zio_data_buf_free(void *buf, size_t size); 375fa9e4066Sahrens 3760a4e9518Sgw extern void zio_resubmit_stage_async(void *); 377fa9e4066Sahrens 378fa9e4066Sahrens extern zio_t *zio_vdev_child_io(zio_t *zio, blkptr_t *bp, vdev_t *vd, 379fa9e4066Sahrens uint64_t offset, void *data, uint64_t size, int type, int priority, 380fa9e4066Sahrens int flags, zio_done_func_t *done, void *private); 381fa9e4066Sahrens 382e14bb325SJeff Bonwick extern zio_t *zio_vdev_delegated_io(vdev_t *vd, uint64_t offset, 383e14bb325SJeff Bonwick void *data, uint64_t size, int type, int priority, 384e14bb325SJeff Bonwick int flags, zio_done_func_t *done, void *private); 385e14bb325SJeff Bonwick 386fa9e4066Sahrens extern void zio_vdev_io_bypass(zio_t *zio); 387fa9e4066Sahrens extern void zio_vdev_io_reissue(zio_t *zio); 388fa9e4066Sahrens extern void zio_vdev_io_redone(zio_t *zio); 389fa9e4066Sahrens 390fa9e4066Sahrens extern void zio_checksum_verified(zio_t *zio); 391e14bb325SJeff Bonwick extern int zio_worst_error(int e1, int e2); 392fa9e4066Sahrens 393fa9e4066Sahrens extern uint8_t zio_checksum_select(uint8_t child, uint8_t parent); 394fa9e4066Sahrens extern uint8_t zio_compress_select(uint8_t child, uint8_t parent); 395fa9e4066Sahrens 396e14bb325SJeff Bonwick extern void zio_suspend(spa_t *spa, zio_t *zio); 397e14bb325SJeff Bonwick extern void zio_resume(spa_t *spa); 398e14bb325SJeff Bonwick extern void zio_resume_wait(spa_t *spa); 399ea8dc4b6Seschrock 400fa9e4066Sahrens /* 401fa9e4066Sahrens * Initial setup and teardown. 402fa9e4066Sahrens */ 403fa9e4066Sahrens extern void zio_init(void); 404fa9e4066Sahrens extern void zio_fini(void); 405fa9e4066Sahrens 406ea8dc4b6Seschrock /* 407ea8dc4b6Seschrock * Fault injection 408ea8dc4b6Seschrock */ 409ea8dc4b6Seschrock struct zinject_record; 410ea8dc4b6Seschrock extern uint32_t zio_injection_enabled; 411ea8dc4b6Seschrock extern int zio_inject_fault(char *name, int flags, int *id, 412ea8dc4b6Seschrock struct zinject_record *record); 413ea8dc4b6Seschrock extern int zio_inject_list_next(int *id, char *name, size_t buflen, 414ea8dc4b6Seschrock struct zinject_record *record); 415ea8dc4b6Seschrock extern int zio_clear_fault(int id); 416ea8dc4b6Seschrock extern int zio_handle_fault_injection(zio_t *zio, int error); 417ea8dc4b6Seschrock extern int zio_handle_device_injection(vdev_t *vd, int error); 41821bf64a7Sgw extern int zio_handle_label_injection(zio_t *zio, int error); 419ea8dc4b6Seschrock 420fa9e4066Sahrens #ifdef __cplusplus 421fa9e4066Sahrens } 422fa9e4066Sahrens #endif 423fa9e4066Sahrens 424fa9e4066Sahrens #endif /* _ZIO_H */ 425