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 /* 23a3f829aeSBill Moore * Copyright 2009 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 797e322df5SJonathan Adams #define ZIO_CHECKSUM_ON_VALUE ZIO_CHECKSUM_FLETCHER_4 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 1198956713aSEric Schrock #define ZIO_FLAG_MUSTSUCCEED 0x000000 1208956713aSEric Schrock #define ZIO_FLAG_CANFAIL 0x000001 1218956713aSEric Schrock #define ZIO_FLAG_SPECULATIVE 0x000002 1228956713aSEric Schrock #define ZIO_FLAG_CONFIG_WRITER 0x000004 1238956713aSEric Schrock #define ZIO_FLAG_DONT_RETRY 0x000008 1248956713aSEric Schrock 1258956713aSEric Schrock #define ZIO_FLAG_DONT_CACHE 0x000010 1268956713aSEric Schrock #define ZIO_FLAG_DONT_QUEUE 0x000020 1278956713aSEric Schrock #define ZIO_FLAG_DONT_AGGREGATE 0x000040 1288956713aSEric Schrock #define ZIO_FLAG_DONT_PROPAGATE 0x000080 1298956713aSEric Schrock 1308956713aSEric Schrock #define ZIO_FLAG_IO_BYPASS 0x000100 1318956713aSEric Schrock #define ZIO_FLAG_IO_REPAIR 0x000200 1328956713aSEric Schrock #define ZIO_FLAG_IO_RETRY 0x000400 1338956713aSEric Schrock #define ZIO_FLAG_IO_REWRITE 0x000800 1348956713aSEric Schrock 1358956713aSEric Schrock #define ZIO_FLAG_SELF_HEAL 0x001000 1368956713aSEric Schrock #define ZIO_FLAG_RESILVER 0x002000 1378956713aSEric Schrock #define ZIO_FLAG_SCRUB 0x004000 1388956713aSEric Schrock #define ZIO_FLAG_SCRUB_THREAD 0x008000 1398956713aSEric Schrock 1408956713aSEric Schrock #define ZIO_FLAG_PROBE 0x010000 1418956713aSEric Schrock #define ZIO_FLAG_GANG_CHILD 0x020000 1428956713aSEric Schrock #define ZIO_FLAG_RAW 0x040000 1438956713aSEric Schrock #define ZIO_FLAG_GODFATHER 0x080000 1448956713aSEric Schrock 1458956713aSEric Schrock #define ZIO_FLAG_TRYHARD 0x100000 146f94275ceSAdam Leventhal #define ZIO_FLAG_NODATA 0x200000 147f94275ceSAdam Leventhal #define ZIO_FLAG_OPTIONAL 0x400000 1489bc11082Sek 149fa9e4066Sahrens #define ZIO_FLAG_GANG_INHERIT \ 150fa9e4066Sahrens (ZIO_FLAG_CANFAIL | \ 151fa9e4066Sahrens ZIO_FLAG_SPECULATIVE | \ 152e14bb325SJeff Bonwick ZIO_FLAG_CONFIG_WRITER | \ 153e14bb325SJeff Bonwick ZIO_FLAG_DONT_RETRY | \ 154e14bb325SJeff Bonwick ZIO_FLAG_DONT_CACHE | \ 155e14bb325SJeff Bonwick ZIO_FLAG_DONT_AGGREGATE | \ 1568ad4d6ddSJeff Bonwick ZIO_FLAG_SELF_HEAL | \ 157fa9e4066Sahrens ZIO_FLAG_RESILVER | \ 158d80c45e0Sbonwick ZIO_FLAG_SCRUB | \ 159e14bb325SJeff Bonwick ZIO_FLAG_SCRUB_THREAD) 160fa9e4066Sahrens 161fa9e4066Sahrens #define ZIO_FLAG_VDEV_INHERIT \ 162fa9e4066Sahrens (ZIO_FLAG_GANG_INHERIT | \ 163e14bb325SJeff Bonwick ZIO_FLAG_IO_REPAIR | \ 164e14bb325SJeff Bonwick ZIO_FLAG_IO_RETRY | \ 1658956713aSEric Schrock ZIO_FLAG_PROBE | \ 166f94275ceSAdam Leventhal ZIO_FLAG_TRYHARD | \ 167f94275ceSAdam Leventhal ZIO_FLAG_NODATA | \ 168f94275ceSAdam Leventhal ZIO_FLAG_OPTIONAL) 16917f17c2dSbonwick 1708ad4d6ddSJeff Bonwick #define ZIO_FLAG_AGG_INHERIT \ 1718ad4d6ddSJeff Bonwick (ZIO_FLAG_DONT_AGGREGATE | \ 1728ad4d6ddSJeff Bonwick ZIO_FLAG_IO_REPAIR | \ 1738ad4d6ddSJeff Bonwick ZIO_FLAG_SELF_HEAL | \ 1748ad4d6ddSJeff Bonwick ZIO_FLAG_RESILVER | \ 1758ad4d6ddSJeff Bonwick ZIO_FLAG_SCRUB | \ 1768ad4d6ddSJeff Bonwick ZIO_FLAG_SCRUB_THREAD) 1778ad4d6ddSJeff Bonwick 178e05725b1Sbonwick #define ZIO_PIPELINE_CONTINUE 0x100 179e05725b1Sbonwick #define ZIO_PIPELINE_STOP 0x101 180e05725b1Sbonwick 181e14bb325SJeff Bonwick #define ZIO_GANG_CHILD_FLAGS(zio) \ 182e14bb325SJeff Bonwick (((zio)->io_flags & ZIO_FLAG_GANG_INHERIT) | \ 183e14bb325SJeff Bonwick ZIO_FLAG_GANG_CHILD | ZIO_FLAG_CANFAIL) 184e14bb325SJeff Bonwick 185e14bb325SJeff Bonwick enum zio_child { 186e14bb325SJeff Bonwick ZIO_CHILD_VDEV = 0, 187e14bb325SJeff Bonwick ZIO_CHILD_GANG, 188e14bb325SJeff Bonwick ZIO_CHILD_LOGICAL, 189e14bb325SJeff Bonwick ZIO_CHILD_TYPES 190e14bb325SJeff Bonwick }; 191e14bb325SJeff Bonwick 192e14bb325SJeff Bonwick enum zio_wait_type { 193e14bb325SJeff Bonwick ZIO_WAIT_READY = 0, 194e14bb325SJeff Bonwick ZIO_WAIT_DONE, 195e14bb325SJeff Bonwick ZIO_WAIT_TYPES 196e14bb325SJeff Bonwick }; 197e14bb325SJeff Bonwick 198fa9e4066Sahrens /* 199e7cbe64fSgw * We'll take the unused errnos, 'EBADE' and 'EBADR' (from the Convergent 200e7cbe64fSgw * graveyard) to indicate checksum errors and fragmentation. 201fa9e4066Sahrens */ 202fa9e4066Sahrens #define ECKSUM EBADE 203e7cbe64fSgw #define EFRAGS EBADR 204fa9e4066Sahrens 205fa9e4066Sahrens typedef struct zio zio_t; 206fa9e4066Sahrens typedef void zio_done_func_t(zio_t *zio); 207fa9e4066Sahrens 208fa9e4066Sahrens extern uint8_t zio_priority_table[ZIO_PRIORITY_TABLE_SIZE]; 209fa9e4066Sahrens extern char *zio_type_name[ZIO_TYPES]; 210fa9e4066Sahrens 211ea8dc4b6Seschrock /* 212ea8dc4b6Seschrock * A bookmark is a four-tuple <objset, object, level, blkid> that uniquely 213ea8dc4b6Seschrock * identifies any block in the pool. By convention, the meta-objset (MOS) 214ea8dc4b6Seschrock * is objset 0, the meta-dnode is object 0, the root block (osphys_t) is 215ea8dc4b6Seschrock * level -1 of the meta-dnode, and intent log blocks (which are chained 216ea8dc4b6Seschrock * off the root block) have blkid == sequence number. In summary: 217ea8dc4b6Seschrock * 218ea8dc4b6Seschrock * mos is objset 0 219ea8dc4b6Seschrock * meta-dnode is object 0 220ea8dc4b6Seschrock * root block is <objset, 0, -1, 0> 221ea8dc4b6Seschrock * intent log is <objset, 0, -1, ZIL sequence number> 222ea8dc4b6Seschrock * 223ea8dc4b6Seschrock * Note: this structure is called a bookmark because its first purpose was 224ea8dc4b6Seschrock * to remember where to resume a pool-wide traverse. The absolute ordering 225ea8dc4b6Seschrock * for block visitation during traversal is defined in compare_bookmark(). 226ea8dc4b6Seschrock * 227ea8dc4b6Seschrock * Note: this structure is passed between userland and the kernel. 228ea8dc4b6Seschrock * Therefore it must not change size or alignment between 32/64 bit 229ea8dc4b6Seschrock * compilation options. 230ea8dc4b6Seschrock */ 231ea8dc4b6Seschrock typedef struct zbookmark { 232ea8dc4b6Seschrock uint64_t zb_objset; 233ea8dc4b6Seschrock uint64_t zb_object; 234ea8dc4b6Seschrock int64_t zb_level; 235ea8dc4b6Seschrock uint64_t zb_blkid; 236ea8dc4b6Seschrock } zbookmark_t; 237ea8dc4b6Seschrock 238e14bb325SJeff Bonwick typedef struct zio_prop { 239e14bb325SJeff Bonwick enum zio_checksum zp_checksum; 240e14bb325SJeff Bonwick enum zio_compress zp_compress; 241e14bb325SJeff Bonwick dmu_object_type_t zp_type; 242e14bb325SJeff Bonwick uint8_t zp_level; 243e14bb325SJeff Bonwick uint8_t zp_ndvas; 244e14bb325SJeff Bonwick } zio_prop_t; 245e14bb325SJeff Bonwick 24622fe2c88SJonathan Adams typedef struct zio_cksum_report zio_cksum_report_t; 24722fe2c88SJonathan Adams 24822fe2c88SJonathan Adams typedef void zio_cksum_finish_f(zio_cksum_report_t *rep, 24922fe2c88SJonathan Adams const void *good_data); 25022fe2c88SJonathan Adams typedef void zio_cksum_free_f(void *cbdata, size_t size); 25122fe2c88SJonathan Adams 25222fe2c88SJonathan Adams struct zio_bad_cksum; /* defined in zio_checksum.h */ 25322fe2c88SJonathan Adams 25422fe2c88SJonathan Adams struct zio_cksum_report { 25522fe2c88SJonathan Adams struct zio_cksum_report *zcr_next; 25622fe2c88SJonathan Adams nvlist_t *zcr_ereport; 25722fe2c88SJonathan Adams nvlist_t *zcr_detector; 25822fe2c88SJonathan Adams 25922fe2c88SJonathan Adams void *zcr_cbdata; 26022fe2c88SJonathan Adams size_t zcr_cbinfo; /* passed to zcr_free() */ 26122fe2c88SJonathan Adams uint64_t zcr_length; 26222fe2c88SJonathan Adams zio_cksum_finish_f *zcr_finish; 26322fe2c88SJonathan Adams zio_cksum_free_f *zcr_free; 26422fe2c88SJonathan Adams 26522fe2c88SJonathan Adams /* internal use only */ 26622fe2c88SJonathan Adams struct zio_bad_cksum *zcr_ckinfo; /* information from failure */ 26722fe2c88SJonathan Adams }; 26822fe2c88SJonathan Adams 26922fe2c88SJonathan Adams typedef void zio_vsd_cksum_report_f(zio_t *zio, zio_cksum_report_t *zcr, 27022fe2c88SJonathan Adams void *arg); 27122fe2c88SJonathan Adams 27222fe2c88SJonathan Adams zio_vsd_cksum_report_f zio_vsd_default_cksum_report; 27322fe2c88SJonathan Adams 27422fe2c88SJonathan Adams typedef struct zio_vsd_ops { 27522fe2c88SJonathan Adams zio_done_func_t *vsd_free; 27622fe2c88SJonathan Adams zio_vsd_cksum_report_f *vsd_cksum_report; 27722fe2c88SJonathan Adams } zio_vsd_ops_t; 27822fe2c88SJonathan Adams 279e14bb325SJeff Bonwick typedef struct zio_gang_node { 280e14bb325SJeff Bonwick zio_gbh_phys_t *gn_gbh; 281e14bb325SJeff Bonwick struct zio_gang_node *gn_child[SPA_GBH_NBLKPTRS]; 282e14bb325SJeff Bonwick } zio_gang_node_t; 283e14bb325SJeff Bonwick 284e14bb325SJeff Bonwick typedef zio_t *zio_gang_issue_func_t(zio_t *zio, blkptr_t *bp, 285e14bb325SJeff Bonwick zio_gang_node_t *gn, void *data); 286e14bb325SJeff Bonwick 287e14bb325SJeff Bonwick typedef void zio_transform_func_t(zio_t *zio, void *data, uint64_t size); 288e14bb325SJeff Bonwick 289e14bb325SJeff Bonwick typedef struct zio_transform { 290e14bb325SJeff Bonwick void *zt_orig_data; 291e14bb325SJeff Bonwick uint64_t zt_orig_size; 292e14bb325SJeff Bonwick uint64_t zt_bufsize; 293e14bb325SJeff Bonwick zio_transform_func_t *zt_transform; 294e14bb325SJeff Bonwick struct zio_transform *zt_next; 295e14bb325SJeff Bonwick } zio_transform_t; 296e14bb325SJeff Bonwick 297e14bb325SJeff Bonwick typedef int zio_pipe_stage_t(zio_t *zio); 298e14bb325SJeff Bonwick 299e14bb325SJeff Bonwick /* 300e14bb325SJeff Bonwick * The io_reexecute flags are distinct from io_flags because the child must 301e14bb325SJeff Bonwick * be able to propagate them to the parent. The normal io_flags are local 302e14bb325SJeff Bonwick * to the zio, not protected by any lock, and not modifiable by children; 303e14bb325SJeff Bonwick * the reexecute flags are protected by io_lock, modifiable by children, 304e14bb325SJeff Bonwick * and always propagated -- even when ZIO_FLAG_DONT_PROPAGATE is set. 305e14bb325SJeff Bonwick */ 306e14bb325SJeff Bonwick #define ZIO_REEXECUTE_NOW 0x01 307e14bb325SJeff Bonwick #define ZIO_REEXECUTE_SUSPEND 0x02 308e14bb325SJeff Bonwick 309a3f829aeSBill Moore typedef struct zio_link { 310a3f829aeSBill Moore zio_t *zl_parent; 311a3f829aeSBill Moore zio_t *zl_child; 312a3f829aeSBill Moore list_node_t zl_parent_node; 313a3f829aeSBill Moore list_node_t zl_child_node; 314a3f829aeSBill Moore } zio_link_t; 315a3f829aeSBill Moore 316fa9e4066Sahrens struct zio { 317fa9e4066Sahrens /* Core information about this I/O */ 318ea8dc4b6Seschrock zbookmark_t io_bookmark; 319e14bb325SJeff Bonwick zio_prop_t io_prop; 320e14bb325SJeff Bonwick zio_type_t io_type; 321e14bb325SJeff Bonwick enum zio_child io_child_type; 322e14bb325SJeff Bonwick int io_cmd; 323e14bb325SJeff Bonwick uint8_t io_priority; 324e14bb325SJeff Bonwick uint8_t io_reexecute; 325a3f829aeSBill Moore uint8_t io_state[ZIO_WAIT_TYPES]; 326fa9e4066Sahrens uint64_t io_txg; 327e14bb325SJeff Bonwick spa_t *io_spa; 328fa9e4066Sahrens blkptr_t *io_bp; 329fa9e4066Sahrens blkptr_t io_bp_copy; 330a3f829aeSBill Moore list_t io_parent_list; 331a3f829aeSBill Moore list_t io_child_list; 332a3f829aeSBill Moore zio_link_t *io_walk_link; 333ea8dc4b6Seschrock zio_t *io_logical; 334e14bb325SJeff Bonwick zio_transform_t *io_transform_stack; 335fa9e4066Sahrens 336fa9e4066Sahrens /* Callback info */ 337c717a561Smaybee zio_done_func_t *io_ready; 338fa9e4066Sahrens zio_done_func_t *io_done; 339fa9e4066Sahrens void *io_private; 340fa9e4066Sahrens blkptr_t io_bp_orig; 341fa9e4066Sahrens 342fa9e4066Sahrens /* Data represented by this I/O */ 343fa9e4066Sahrens void *io_data; 344fa9e4066Sahrens uint64_t io_size; 345fa9e4066Sahrens 346fa9e4066Sahrens /* Stuff for the vdev stack */ 347fa9e4066Sahrens vdev_t *io_vd; 348fa9e4066Sahrens void *io_vsd; 34922fe2c88SJonathan Adams const zio_vsd_ops_t *io_vsd_ops; 35022fe2c88SJonathan Adams 351fa9e4066Sahrens uint64_t io_offset; 352fa9e4066Sahrens uint64_t io_deadline; 353fa9e4066Sahrens avl_node_t io_offset_node; 354fa9e4066Sahrens avl_node_t io_deadline_node; 355fa9e4066Sahrens avl_tree_t *io_vdev_tree; 356fa9e4066Sahrens 357fa9e4066Sahrens /* Internal pipeline state */ 358fa9e4066Sahrens int io_flags; 359e14bb325SJeff Bonwick zio_stage_t io_stage; 360fa9e4066Sahrens uint32_t io_pipeline; 361e14bb325SJeff Bonwick int io_orig_flags; 362e14bb325SJeff Bonwick zio_stage_t io_orig_stage; 3630a4e9518Sgw uint32_t io_orig_pipeline; 364e14bb325SJeff Bonwick int io_error; 365e14bb325SJeff Bonwick int io_child_error[ZIO_CHILD_TYPES]; 366e14bb325SJeff Bonwick uint64_t io_children[ZIO_CHILD_TYPES][ZIO_WAIT_TYPES]; 367e14bb325SJeff Bonwick uint64_t *io_stall; 368f5383399SBill Moore zio_t *io_gang_leader; 369e14bb325SJeff Bonwick zio_gang_node_t *io_gang_tree; 370e14bb325SJeff Bonwick void *io_executor; 371fa9e4066Sahrens void *io_waiter; 372fa9e4066Sahrens kmutex_t io_lock; 373fa9e4066Sahrens kcondvar_t io_cv; 374ea8dc4b6Seschrock 375ea8dc4b6Seschrock /* FMA state */ 37622fe2c88SJonathan Adams zio_cksum_report_t *io_cksum_report; 377ea8dc4b6Seschrock uint64_t io_ena; 378fa9e4066Sahrens }; 379fa9e4066Sahrens 380a3f829aeSBill Moore extern zio_t *zio_null(zio_t *pio, spa_t *spa, vdev_t *vd, 381fa9e4066Sahrens zio_done_func_t *done, void *private, int flags); 382fa9e4066Sahrens 383fa9e4066Sahrens extern zio_t *zio_root(spa_t *spa, 384fa9e4066Sahrens zio_done_func_t *done, void *private, int flags); 385fa9e4066Sahrens 386088f3894Sahrens extern zio_t *zio_read(zio_t *pio, spa_t *spa, const blkptr_t *bp, void *data, 387fa9e4066Sahrens uint64_t size, zio_done_func_t *done, void *private, 388088f3894Sahrens int priority, int flags, const zbookmark_t *zb); 389fa9e4066Sahrens 390e14bb325SJeff Bonwick extern zio_t *zio_write(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp, 391e14bb325SJeff Bonwick void *data, uint64_t size, zio_prop_t *zp, 392e14bb325SJeff Bonwick zio_done_func_t *ready, zio_done_func_t *done, void *private, 393e14bb325SJeff Bonwick int priority, int flags, const zbookmark_t *zb); 394fa9e4066Sahrens 395e14bb325SJeff Bonwick extern zio_t *zio_rewrite(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp, 396e14bb325SJeff Bonwick void *data, uint64_t size, zio_done_func_t *done, void *private, 397e14bb325SJeff Bonwick int priority, int flags, zbookmark_t *zb); 398fa9e4066Sahrens 39982c9918fSTim Haley extern void zio_skip_write(zio_t *zio); 40082c9918fSTim Haley 401fa9e4066Sahrens extern zio_t *zio_free(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp, 402e14bb325SJeff Bonwick zio_done_func_t *done, void *private, int flags); 403fa9e4066Sahrens 404fa9e4066Sahrens extern zio_t *zio_claim(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp, 405e14bb325SJeff Bonwick zio_done_func_t *done, void *private, int flags); 406fa9e4066Sahrens 407fa9e4066Sahrens extern zio_t *zio_ioctl(zio_t *pio, spa_t *spa, vdev_t *vd, int cmd, 408fa9e4066Sahrens zio_done_func_t *done, void *private, int priority, int flags); 409fa9e4066Sahrens 410fa9e4066Sahrens extern zio_t *zio_read_phys(zio_t *pio, vdev_t *vd, uint64_t offset, 411fa9e4066Sahrens uint64_t size, void *data, int checksum, 412fa94a07fSbrendan zio_done_func_t *done, void *private, int priority, int flags, 413fa94a07fSbrendan boolean_t labels); 414fa9e4066Sahrens 415fa9e4066Sahrens extern zio_t *zio_write_phys(zio_t *pio, vdev_t *vd, uint64_t offset, 416fa9e4066Sahrens uint64_t size, void *data, int checksum, 417fa94a07fSbrendan zio_done_func_t *done, void *private, int priority, int flags, 418fa94a07fSbrendan boolean_t labels); 419fa9e4066Sahrens 42067bd71c6Sperrin extern int zio_alloc_blk(spa_t *spa, uint64_t size, blkptr_t *new_bp, 421d48e086fSNeil Perrin blkptr_t *old_bp, uint64_t txg, boolean_t use_slog); 422fa9e4066Sahrens extern void zio_free_blk(spa_t *spa, blkptr_t *bp, uint64_t txg); 42317f17c2dSbonwick extern void zio_flush(zio_t *zio, vdev_t *vd); 424fa9e4066Sahrens 425fa9e4066Sahrens extern int zio_wait(zio_t *zio); 426fa9e4066Sahrens extern void zio_nowait(zio_t *zio); 427e05725b1Sbonwick extern void zio_execute(zio_t *zio); 428e05725b1Sbonwick extern void zio_interrupt(zio_t *zio); 429e05725b1Sbonwick 430a3f829aeSBill Moore extern zio_t *zio_walk_parents(zio_t *cio); 431a3f829aeSBill Moore extern zio_t *zio_walk_children(zio_t *pio); 432a3f829aeSBill Moore extern zio_t *zio_unique_parent(zio_t *cio); 433a3f829aeSBill Moore extern void zio_add_child(zio_t *pio, zio_t *cio); 434a3f829aeSBill Moore 435fa9e4066Sahrens extern void *zio_buf_alloc(size_t size); 436fa9e4066Sahrens extern void zio_buf_free(void *buf, size_t size); 437ad23a2dbSjohansen extern void *zio_data_buf_alloc(size_t size); 438ad23a2dbSjohansen extern void zio_data_buf_free(void *buf, size_t size); 439fa9e4066Sahrens 4400a4e9518Sgw extern void zio_resubmit_stage_async(void *); 441fa9e4066Sahrens 442fa9e4066Sahrens extern zio_t *zio_vdev_child_io(zio_t *zio, blkptr_t *bp, vdev_t *vd, 443fa9e4066Sahrens uint64_t offset, void *data, uint64_t size, int type, int priority, 444fa9e4066Sahrens int flags, zio_done_func_t *done, void *private); 445fa9e4066Sahrens 446e14bb325SJeff Bonwick extern zio_t *zio_vdev_delegated_io(vdev_t *vd, uint64_t offset, 447e14bb325SJeff Bonwick void *data, uint64_t size, int type, int priority, 448e14bb325SJeff Bonwick int flags, zio_done_func_t *done, void *private); 449e14bb325SJeff Bonwick 450fa9e4066Sahrens extern void zio_vdev_io_bypass(zio_t *zio); 451fa9e4066Sahrens extern void zio_vdev_io_reissue(zio_t *zio); 452fa9e4066Sahrens extern void zio_vdev_io_redone(zio_t *zio); 453fa9e4066Sahrens 454fa9e4066Sahrens extern void zio_checksum_verified(zio_t *zio); 455e14bb325SJeff Bonwick extern int zio_worst_error(int e1, int e2); 456fa9e4066Sahrens 457fa9e4066Sahrens extern uint8_t zio_checksum_select(uint8_t child, uint8_t parent); 458fa9e4066Sahrens extern uint8_t zio_compress_select(uint8_t child, uint8_t parent); 459fa9e4066Sahrens 460e14bb325SJeff Bonwick extern void zio_suspend(spa_t *spa, zio_t *zio); 46154d692b7SGeorge Wilson extern int zio_resume(spa_t *spa); 462e14bb325SJeff Bonwick extern void zio_resume_wait(spa_t *spa); 463ea8dc4b6Seschrock 464fa9e4066Sahrens /* 465fa9e4066Sahrens * Initial setup and teardown. 466fa9e4066Sahrens */ 467fa9e4066Sahrens extern void zio_init(void); 468fa9e4066Sahrens extern void zio_fini(void); 469fa9e4066Sahrens 470ea8dc4b6Seschrock /* 471ea8dc4b6Seschrock * Fault injection 472ea8dc4b6Seschrock */ 473ea8dc4b6Seschrock struct zinject_record; 474ea8dc4b6Seschrock extern uint32_t zio_injection_enabled; 475ea8dc4b6Seschrock extern int zio_inject_fault(char *name, int flags, int *id, 476ea8dc4b6Seschrock struct zinject_record *record); 477ea8dc4b6Seschrock extern int zio_inject_list_next(int *id, char *name, size_t buflen, 478ea8dc4b6Seschrock struct zinject_record *record); 479ea8dc4b6Seschrock extern int zio_clear_fault(int id); 48088ecc943SGeorge Wilson extern void zio_handle_panic_injection(spa_t *spa, char *tag); 481ea8dc4b6Seschrock extern int zio_handle_fault_injection(zio_t *zio, int error); 4828956713aSEric Schrock extern int zio_handle_device_injection(vdev_t *vd, zio_t *zio, int error); 48321bf64a7Sgw extern int zio_handle_label_injection(zio_t *zio, int error); 484*468c413aSTim Haley extern void zio_handle_ignored_writes(zio_t *zio); 485ea8dc4b6Seschrock 48622fe2c88SJonathan Adams /* 48722fe2c88SJonathan Adams * Checksum ereport functions 48822fe2c88SJonathan Adams */ 48922fe2c88SJonathan Adams extern void zfs_ereport_start_checksum(spa_t *spa, vdev_t *vd, struct zio *zio, 49022fe2c88SJonathan Adams uint64_t offset, uint64_t length, void *arg, struct zio_bad_cksum *info); 49122fe2c88SJonathan Adams extern void zfs_ereport_finish_checksum(zio_cksum_report_t *report, 49222fe2c88SJonathan Adams const void *good_data, const void *bad_data, boolean_t drop_if_identical); 49322fe2c88SJonathan Adams 49422fe2c88SJonathan Adams extern void zfs_ereport_send_interim_checksum(zio_cksum_report_t *report); 49522fe2c88SJonathan Adams extern void zfs_ereport_free_checksum(zio_cksum_report_t *report); 49622fe2c88SJonathan Adams 49722fe2c88SJonathan Adams /* If we have the good data in hand, this function can be used */ 49822fe2c88SJonathan Adams extern void zfs_ereport_post_checksum(spa_t *spa, vdev_t *vd, 49922fe2c88SJonathan Adams struct zio *zio, uint64_t offset, uint64_t length, 50022fe2c88SJonathan Adams const void *good_data, const void *bad_data, struct zio_bad_cksum *info); 50122fe2c88SJonathan Adams 502*468c413aSTim Haley /* Called from spa_sync(), but primarily an injection handler */ 503*468c413aSTim Haley extern void spa_handle_ignored_writes(spa_t *spa); 504*468c413aSTim Haley 505fa9e4066Sahrens #ifdef __cplusplus 506fa9e4066Sahrens } 507fa9e4066Sahrens #endif 508fa9e4066Sahrens 509fa9e4066Sahrens #endif /* _ZIO_H */ 510