1789Sahrens /* 2789Sahrens * CDDL HEADER START 3789Sahrens * 4789Sahrens * The contents of this file are subject to the terms of the 51544Seschrock * Common Development and Distribution License (the "License"). 61544Seschrock * You may not use this file except in compliance with the License. 7789Sahrens * 8789Sahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9789Sahrens * or http://www.opensolaris.org/os/licensing. 10789Sahrens * See the License for the specific language governing permissions 11789Sahrens * and limitations under the License. 12789Sahrens * 13789Sahrens * When distributing Covered Code, include this CDDL HEADER in each 14789Sahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15789Sahrens * If applicable, add the following below this CDDL HEADER, with the 16789Sahrens * fields enclosed by brackets "[]" replaced with your own identifying 17789Sahrens * information: Portions Copyright [yyyy] [name of copyright owner] 18789Sahrens * 19789Sahrens * CDDL HEADER END 20789Sahrens */ 213886Sahl 22789Sahrens /* 238632SBill.Moore@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24789Sahrens * Use is subject to license terms. 25789Sahrens */ 26789Sahrens 27789Sahrens #ifndef _ZIO_H 28789Sahrens #define _ZIO_H 29789Sahrens 30789Sahrens #include <sys/zfs_context.h> 31789Sahrens #include <sys/spa.h> 32789Sahrens #include <sys/txg.h> 33789Sahrens #include <sys/avl.h> 34789Sahrens #include <sys/fs/zfs.h> 351775Sbillm #include <sys/zio_impl.h> 36789Sahrens 37789Sahrens #ifdef __cplusplus 38789Sahrens extern "C" { 39789Sahrens #endif 40789Sahrens 41789Sahrens #define ZBT_MAGIC 0x210da7ab10c7a11ULL /* zio data bloc tail */ 42789Sahrens 43789Sahrens typedef struct zio_block_tail { 44789Sahrens uint64_t zbt_magic; /* for validation, endianness */ 45789Sahrens zio_cksum_t zbt_cksum; /* 256-bit checksum */ 46789Sahrens } zio_block_tail_t; 47789Sahrens 48789Sahrens /* 49789Sahrens * Gang block headers are self-checksumming and contain an array 50789Sahrens * of block pointers. 51789Sahrens */ 52789Sahrens #define SPA_GANGBLOCKSIZE SPA_MINBLOCKSIZE 53789Sahrens #define SPA_GBH_NBLKPTRS ((SPA_GANGBLOCKSIZE - \ 54789Sahrens sizeof (zio_block_tail_t)) / sizeof (blkptr_t)) 55789Sahrens #define SPA_GBH_FILLER ((SPA_GANGBLOCKSIZE - \ 56789Sahrens sizeof (zio_block_tail_t) - \ 57789Sahrens (SPA_GBH_NBLKPTRS * sizeof (blkptr_t))) /\ 58789Sahrens sizeof (uint64_t)) 59789Sahrens 60789Sahrens typedef struct zio_gbh { 61789Sahrens blkptr_t zg_blkptr[SPA_GBH_NBLKPTRS]; 62789Sahrens uint64_t zg_filler[SPA_GBH_FILLER]; 63789Sahrens zio_block_tail_t zg_tail; 64789Sahrens } zio_gbh_phys_t; 65789Sahrens 66789Sahrens enum zio_checksum { 67789Sahrens ZIO_CHECKSUM_INHERIT = 0, 68789Sahrens ZIO_CHECKSUM_ON, 69789Sahrens ZIO_CHECKSUM_OFF, 70789Sahrens ZIO_CHECKSUM_LABEL, 71789Sahrens ZIO_CHECKSUM_GANG_HEADER, 72789Sahrens ZIO_CHECKSUM_ZILOG, 73789Sahrens ZIO_CHECKSUM_FLETCHER_2, 74789Sahrens ZIO_CHECKSUM_FLETCHER_4, 75789Sahrens ZIO_CHECKSUM_SHA256, 76789Sahrens ZIO_CHECKSUM_FUNCTIONS 77789Sahrens }; 78789Sahrens 799454SJonathan.Adams@Sun.COM #define ZIO_CHECKSUM_ON_VALUE ZIO_CHECKSUM_FLETCHER_4 80789Sahrens #define ZIO_CHECKSUM_DEFAULT ZIO_CHECKSUM_ON 81789Sahrens 82789Sahrens enum zio_compress { 83789Sahrens ZIO_COMPRESS_INHERIT = 0, 84789Sahrens ZIO_COMPRESS_ON, 85789Sahrens ZIO_COMPRESS_OFF, 86789Sahrens ZIO_COMPRESS_LZJB, 872986Sek110237 ZIO_COMPRESS_EMPTY, 883886Sahl ZIO_COMPRESS_GZIP_1, 893886Sahl ZIO_COMPRESS_GZIP_2, 903886Sahl ZIO_COMPRESS_GZIP_3, 913886Sahl ZIO_COMPRESS_GZIP_4, 923886Sahl ZIO_COMPRESS_GZIP_5, 933886Sahl ZIO_COMPRESS_GZIP_6, 943886Sahl ZIO_COMPRESS_GZIP_7, 953886Sahl ZIO_COMPRESS_GZIP_8, 963886Sahl ZIO_COMPRESS_GZIP_9, 97789Sahrens ZIO_COMPRESS_FUNCTIONS 98789Sahrens }; 99789Sahrens 100789Sahrens #define ZIO_COMPRESS_ON_VALUE ZIO_COMPRESS_LZJB 101789Sahrens #define ZIO_COMPRESS_DEFAULT ZIO_COMPRESS_OFF 102789Sahrens 1035329Sgw25295 #define ZIO_FAILURE_MODE_WAIT 0 1045329Sgw25295 #define ZIO_FAILURE_MODE_CONTINUE 1 1055329Sgw25295 #define ZIO_FAILURE_MODE_PANIC 2 1065329Sgw25295 107789Sahrens #define ZIO_PRIORITY_NOW (zio_priority_table[0]) 108789Sahrens #define ZIO_PRIORITY_SYNC_READ (zio_priority_table[1]) 109789Sahrens #define ZIO_PRIORITY_SYNC_WRITE (zio_priority_table[2]) 110789Sahrens #define ZIO_PRIORITY_ASYNC_READ (zio_priority_table[3]) 111789Sahrens #define ZIO_PRIORITY_ASYNC_WRITE (zio_priority_table[4]) 112789Sahrens #define ZIO_PRIORITY_FREE (zio_priority_table[5]) 113789Sahrens #define ZIO_PRIORITY_CACHE_FILL (zio_priority_table[6]) 114789Sahrens #define ZIO_PRIORITY_LOG_WRITE (zio_priority_table[7]) 115789Sahrens #define ZIO_PRIORITY_RESILVER (zio_priority_table[8]) 116789Sahrens #define ZIO_PRIORITY_SCRUB (zio_priority_table[9]) 117789Sahrens #define ZIO_PRIORITY_TABLE_SIZE 10 118789Sahrens 119*9725SEric.Schrock@Sun.COM #define ZIO_FLAG_MUSTSUCCEED 0x000000 120*9725SEric.Schrock@Sun.COM #define ZIO_FLAG_CANFAIL 0x000001 121*9725SEric.Schrock@Sun.COM #define ZIO_FLAG_SPECULATIVE 0x000002 122*9725SEric.Schrock@Sun.COM #define ZIO_FLAG_CONFIG_WRITER 0x000004 123*9725SEric.Schrock@Sun.COM #define ZIO_FLAG_DONT_RETRY 0x000008 1241544Seschrock 125*9725SEric.Schrock@Sun.COM #define ZIO_FLAG_DONT_CACHE 0x000010 126*9725SEric.Schrock@Sun.COM #define ZIO_FLAG_DONT_QUEUE 0x000020 127*9725SEric.Schrock@Sun.COM #define ZIO_FLAG_DONT_AGGREGATE 0x000040 128*9725SEric.Schrock@Sun.COM #define ZIO_FLAG_DONT_PROPAGATE 0x000080 129789Sahrens 130*9725SEric.Schrock@Sun.COM #define ZIO_FLAG_IO_BYPASS 0x000100 131*9725SEric.Schrock@Sun.COM #define ZIO_FLAG_IO_REPAIR 0x000200 132*9725SEric.Schrock@Sun.COM #define ZIO_FLAG_IO_RETRY 0x000400 133*9725SEric.Schrock@Sun.COM #define ZIO_FLAG_IO_REWRITE 0x000800 134789Sahrens 135*9725SEric.Schrock@Sun.COM #define ZIO_FLAG_SELF_HEAL 0x001000 136*9725SEric.Schrock@Sun.COM #define ZIO_FLAG_RESILVER 0x002000 137*9725SEric.Schrock@Sun.COM #define ZIO_FLAG_SCRUB 0x004000 138*9725SEric.Schrock@Sun.COM #define ZIO_FLAG_SCRUB_THREAD 0x008000 1397754SJeff.Bonwick@Sun.COM 140*9725SEric.Schrock@Sun.COM #define ZIO_FLAG_PROBE 0x010000 141*9725SEric.Schrock@Sun.COM #define ZIO_FLAG_GANG_CHILD 0x020000 142*9725SEric.Schrock@Sun.COM #define ZIO_FLAG_RAW 0x040000 143*9725SEric.Schrock@Sun.COM #define ZIO_FLAG_GODFATHER 0x080000 144*9725SEric.Schrock@Sun.COM 145*9725SEric.Schrock@Sun.COM #define ZIO_FLAG_TRYHARD 0x100000 1463689Sek110237 147789Sahrens #define ZIO_FLAG_GANG_INHERIT \ 148789Sahrens (ZIO_FLAG_CANFAIL | \ 1497754SJeff.Bonwick@Sun.COM ZIO_FLAG_SPECULATIVE | \ 1507754SJeff.Bonwick@Sun.COM ZIO_FLAG_CONFIG_WRITER | \ 1517754SJeff.Bonwick@Sun.COM ZIO_FLAG_DONT_RETRY | \ 1525530Sbonwick ZIO_FLAG_DONT_CACHE | \ 1537754SJeff.Bonwick@Sun.COM ZIO_FLAG_DONT_AGGREGATE | \ 1548241SJeff.Bonwick@Sun.COM ZIO_FLAG_SELF_HEAL | \ 155789Sahrens ZIO_FLAG_RESILVER | \ 1561807Sbonwick ZIO_FLAG_SCRUB | \ 1577754SJeff.Bonwick@Sun.COM ZIO_FLAG_SCRUB_THREAD) 158789Sahrens 159789Sahrens #define ZIO_FLAG_VDEV_INHERIT \ 160789Sahrens (ZIO_FLAG_GANG_INHERIT | \ 1617754SJeff.Bonwick@Sun.COM ZIO_FLAG_IO_REPAIR | \ 1627754SJeff.Bonwick@Sun.COM ZIO_FLAG_IO_RETRY | \ 163*9725SEric.Schrock@Sun.COM ZIO_FLAG_PROBE | \ 164*9725SEric.Schrock@Sun.COM ZIO_FLAG_TRYHARD) 1655688Sbonwick 1668241SJeff.Bonwick@Sun.COM #define ZIO_FLAG_AGG_INHERIT \ 1678241SJeff.Bonwick@Sun.COM (ZIO_FLAG_DONT_AGGREGATE | \ 1688241SJeff.Bonwick@Sun.COM ZIO_FLAG_IO_REPAIR | \ 1698241SJeff.Bonwick@Sun.COM ZIO_FLAG_SELF_HEAL | \ 1708241SJeff.Bonwick@Sun.COM ZIO_FLAG_RESILVER | \ 1718241SJeff.Bonwick@Sun.COM ZIO_FLAG_SCRUB | \ 1728241SJeff.Bonwick@Sun.COM ZIO_FLAG_SCRUB_THREAD) 1738241SJeff.Bonwick@Sun.COM 1745530Sbonwick #define ZIO_PIPELINE_CONTINUE 0x100 1755530Sbonwick #define ZIO_PIPELINE_STOP 0x101 1765530Sbonwick 1777754SJeff.Bonwick@Sun.COM #define ZIO_GANG_CHILD_FLAGS(zio) \ 1787754SJeff.Bonwick@Sun.COM (((zio)->io_flags & ZIO_FLAG_GANG_INHERIT) | \ 1797754SJeff.Bonwick@Sun.COM ZIO_FLAG_GANG_CHILD | ZIO_FLAG_CANFAIL) 1807754SJeff.Bonwick@Sun.COM 1817754SJeff.Bonwick@Sun.COM enum zio_child { 1827754SJeff.Bonwick@Sun.COM ZIO_CHILD_VDEV = 0, 1837754SJeff.Bonwick@Sun.COM ZIO_CHILD_GANG, 1847754SJeff.Bonwick@Sun.COM ZIO_CHILD_LOGICAL, 1857754SJeff.Bonwick@Sun.COM ZIO_CHILD_TYPES 1867754SJeff.Bonwick@Sun.COM }; 1877754SJeff.Bonwick@Sun.COM 1887754SJeff.Bonwick@Sun.COM enum zio_wait_type { 1897754SJeff.Bonwick@Sun.COM ZIO_WAIT_READY = 0, 1907754SJeff.Bonwick@Sun.COM ZIO_WAIT_DONE, 1917754SJeff.Bonwick@Sun.COM ZIO_WAIT_TYPES 1927754SJeff.Bonwick@Sun.COM }; 1937754SJeff.Bonwick@Sun.COM 194789Sahrens /* 1956423Sgw25295 * We'll take the unused errnos, 'EBADE' and 'EBADR' (from the Convergent 1966423Sgw25295 * graveyard) to indicate checksum errors and fragmentation. 197789Sahrens */ 198789Sahrens #define ECKSUM EBADE 1996423Sgw25295 #define EFRAGS EBADR 200789Sahrens 201789Sahrens typedef struct zio zio_t; 202789Sahrens typedef void zio_done_func_t(zio_t *zio); 203789Sahrens 204789Sahrens extern uint8_t zio_priority_table[ZIO_PRIORITY_TABLE_SIZE]; 205789Sahrens extern char *zio_type_name[ZIO_TYPES]; 206789Sahrens 2071544Seschrock /* 2081544Seschrock * A bookmark is a four-tuple <objset, object, level, blkid> that uniquely 2091544Seschrock * identifies any block in the pool. By convention, the meta-objset (MOS) 2101544Seschrock * is objset 0, the meta-dnode is object 0, the root block (osphys_t) is 2111544Seschrock * level -1 of the meta-dnode, and intent log blocks (which are chained 2121544Seschrock * off the root block) have blkid == sequence number. In summary: 2131544Seschrock * 2141544Seschrock * mos is objset 0 2151544Seschrock * meta-dnode is object 0 2161544Seschrock * root block is <objset, 0, -1, 0> 2171544Seschrock * intent log is <objset, 0, -1, ZIL sequence number> 2181544Seschrock * 2191544Seschrock * Note: this structure is called a bookmark because its first purpose was 2201544Seschrock * to remember where to resume a pool-wide traverse. The absolute ordering 2211544Seschrock * for block visitation during traversal is defined in compare_bookmark(). 2221544Seschrock * 2231544Seschrock * Note: this structure is passed between userland and the kernel. 2241544Seschrock * Therefore it must not change size or alignment between 32/64 bit 2251544Seschrock * compilation options. 2261544Seschrock */ 2271544Seschrock typedef struct zbookmark { 2281544Seschrock uint64_t zb_objset; 2291544Seschrock uint64_t zb_object; 2301544Seschrock int64_t zb_level; 2311544Seschrock uint64_t zb_blkid; 2321544Seschrock } zbookmark_t; 2331544Seschrock 2347754SJeff.Bonwick@Sun.COM typedef struct zio_prop { 2357754SJeff.Bonwick@Sun.COM enum zio_checksum zp_checksum; 2367754SJeff.Bonwick@Sun.COM enum zio_compress zp_compress; 2377754SJeff.Bonwick@Sun.COM dmu_object_type_t zp_type; 2387754SJeff.Bonwick@Sun.COM uint8_t zp_level; 2397754SJeff.Bonwick@Sun.COM uint8_t zp_ndvas; 2407754SJeff.Bonwick@Sun.COM } zio_prop_t; 2417754SJeff.Bonwick@Sun.COM 2427754SJeff.Bonwick@Sun.COM typedef struct zio_gang_node { 2437754SJeff.Bonwick@Sun.COM zio_gbh_phys_t *gn_gbh; 2447754SJeff.Bonwick@Sun.COM struct zio_gang_node *gn_child[SPA_GBH_NBLKPTRS]; 2457754SJeff.Bonwick@Sun.COM } zio_gang_node_t; 2467754SJeff.Bonwick@Sun.COM 2477754SJeff.Bonwick@Sun.COM typedef zio_t *zio_gang_issue_func_t(zio_t *zio, blkptr_t *bp, 2487754SJeff.Bonwick@Sun.COM zio_gang_node_t *gn, void *data); 2497754SJeff.Bonwick@Sun.COM 2507754SJeff.Bonwick@Sun.COM typedef void zio_transform_func_t(zio_t *zio, void *data, uint64_t size); 2517754SJeff.Bonwick@Sun.COM 2527754SJeff.Bonwick@Sun.COM typedef struct zio_transform { 2537754SJeff.Bonwick@Sun.COM void *zt_orig_data; 2547754SJeff.Bonwick@Sun.COM uint64_t zt_orig_size; 2557754SJeff.Bonwick@Sun.COM uint64_t zt_bufsize; 2567754SJeff.Bonwick@Sun.COM zio_transform_func_t *zt_transform; 2577754SJeff.Bonwick@Sun.COM struct zio_transform *zt_next; 2587754SJeff.Bonwick@Sun.COM } zio_transform_t; 2597754SJeff.Bonwick@Sun.COM 2607754SJeff.Bonwick@Sun.COM typedef int zio_pipe_stage_t(zio_t *zio); 2617754SJeff.Bonwick@Sun.COM 2627754SJeff.Bonwick@Sun.COM /* 2637754SJeff.Bonwick@Sun.COM * The io_reexecute flags are distinct from io_flags because the child must 2647754SJeff.Bonwick@Sun.COM * be able to propagate them to the parent. The normal io_flags are local 2657754SJeff.Bonwick@Sun.COM * to the zio, not protected by any lock, and not modifiable by children; 2667754SJeff.Bonwick@Sun.COM * the reexecute flags are protected by io_lock, modifiable by children, 2677754SJeff.Bonwick@Sun.COM * and always propagated -- even when ZIO_FLAG_DONT_PROPAGATE is set. 2687754SJeff.Bonwick@Sun.COM */ 2697754SJeff.Bonwick@Sun.COM #define ZIO_REEXECUTE_NOW 0x01 2707754SJeff.Bonwick@Sun.COM #define ZIO_REEXECUTE_SUSPEND 0x02 2717754SJeff.Bonwick@Sun.COM 2728632SBill.Moore@Sun.COM typedef struct zio_link { 2738632SBill.Moore@Sun.COM zio_t *zl_parent; 2748632SBill.Moore@Sun.COM zio_t *zl_child; 2758632SBill.Moore@Sun.COM list_node_t zl_parent_node; 2768632SBill.Moore@Sun.COM list_node_t zl_child_node; 2778632SBill.Moore@Sun.COM } zio_link_t; 2788632SBill.Moore@Sun.COM 279789Sahrens struct zio { 280789Sahrens /* Core information about this I/O */ 2817754SJeff.Bonwick@Sun.COM zbookmark_t io_bookmark; 2827754SJeff.Bonwick@Sun.COM zio_prop_t io_prop; 2837754SJeff.Bonwick@Sun.COM zio_type_t io_type; 2847754SJeff.Bonwick@Sun.COM enum zio_child io_child_type; 2857754SJeff.Bonwick@Sun.COM int io_cmd; 2867754SJeff.Bonwick@Sun.COM uint8_t io_priority; 2877754SJeff.Bonwick@Sun.COM uint8_t io_reexecute; 2888632SBill.Moore@Sun.COM uint8_t io_state[ZIO_WAIT_TYPES]; 2897754SJeff.Bonwick@Sun.COM uint64_t io_txg; 290789Sahrens spa_t *io_spa; 291789Sahrens blkptr_t *io_bp; 292789Sahrens blkptr_t io_bp_copy; 2938632SBill.Moore@Sun.COM list_t io_parent_list; 2948632SBill.Moore@Sun.COM list_t io_child_list; 2958632SBill.Moore@Sun.COM zio_link_t *io_walk_link; 2967754SJeff.Bonwick@Sun.COM zio_t *io_logical; 297789Sahrens zio_transform_t *io_transform_stack; 298789Sahrens 299789Sahrens /* Callback info */ 3003547Smaybee zio_done_func_t *io_ready; 301789Sahrens zio_done_func_t *io_done; 302789Sahrens void *io_private; 303789Sahrens blkptr_t io_bp_orig; 304789Sahrens 305789Sahrens /* Data represented by this I/O */ 306789Sahrens void *io_data; 307789Sahrens uint64_t io_size; 308789Sahrens 309789Sahrens /* Stuff for the vdev stack */ 310789Sahrens vdev_t *io_vd; 311789Sahrens void *io_vsd; 3127754SJeff.Bonwick@Sun.COM zio_done_func_t *io_vsd_free; 313789Sahrens uint64_t io_offset; 314789Sahrens uint64_t io_deadline; 315789Sahrens avl_node_t io_offset_node; 316789Sahrens avl_node_t io_deadline_node; 317789Sahrens avl_tree_t *io_vdev_tree; 318789Sahrens 319789Sahrens /* Internal pipeline state */ 320789Sahrens int io_flags; 3217754SJeff.Bonwick@Sun.COM zio_stage_t io_stage; 3227754SJeff.Bonwick@Sun.COM uint32_t io_pipeline; 3235329Sgw25295 int io_orig_flags; 3247754SJeff.Bonwick@Sun.COM zio_stage_t io_orig_stage; 3257754SJeff.Bonwick@Sun.COM uint32_t io_orig_pipeline; 326789Sahrens int io_error; 3277754SJeff.Bonwick@Sun.COM int io_child_error[ZIO_CHILD_TYPES]; 3287754SJeff.Bonwick@Sun.COM uint64_t io_children[ZIO_CHILD_TYPES][ZIO_WAIT_TYPES]; 3297754SJeff.Bonwick@Sun.COM uint64_t *io_stall; 3309443SBill.Moore@Sun.COM zio_t *io_gang_leader; 3317754SJeff.Bonwick@Sun.COM zio_gang_node_t *io_gang_tree; 3327754SJeff.Bonwick@Sun.COM void *io_executor; 333789Sahrens void *io_waiter; 334789Sahrens kmutex_t io_lock; 335789Sahrens kcondvar_t io_cv; 3361544Seschrock 3371544Seschrock /* FMA state */ 3381544Seschrock uint64_t io_ena; 339789Sahrens }; 340789Sahrens 3418632SBill.Moore@Sun.COM extern zio_t *zio_null(zio_t *pio, spa_t *spa, vdev_t *vd, 342789Sahrens zio_done_func_t *done, void *private, int flags); 343789Sahrens 344789Sahrens extern zio_t *zio_root(spa_t *spa, 345789Sahrens zio_done_func_t *done, void *private, int flags); 346789Sahrens 3477046Sahrens extern zio_t *zio_read(zio_t *pio, spa_t *spa, const blkptr_t *bp, void *data, 348789Sahrens uint64_t size, zio_done_func_t *done, void *private, 3497046Sahrens int priority, int flags, const zbookmark_t *zb); 350789Sahrens 3517754SJeff.Bonwick@Sun.COM extern zio_t *zio_write(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp, 3527754SJeff.Bonwick@Sun.COM void *data, uint64_t size, zio_prop_t *zp, 3537754SJeff.Bonwick@Sun.COM zio_done_func_t *ready, zio_done_func_t *done, void *private, 3547754SJeff.Bonwick@Sun.COM int priority, int flags, const zbookmark_t *zb); 355789Sahrens 3567754SJeff.Bonwick@Sun.COM extern zio_t *zio_rewrite(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp, 3577754SJeff.Bonwick@Sun.COM void *data, uint64_t size, zio_done_func_t *done, void *private, 3587754SJeff.Bonwick@Sun.COM int priority, int flags, zbookmark_t *zb); 359789Sahrens 3607872STim.Haley@Sun.COM extern void zio_skip_write(zio_t *zio); 3617872STim.Haley@Sun.COM 362789Sahrens extern zio_t *zio_free(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp, 3637754SJeff.Bonwick@Sun.COM zio_done_func_t *done, void *private, int flags); 364789Sahrens 365789Sahrens extern zio_t *zio_claim(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp, 3667754SJeff.Bonwick@Sun.COM zio_done_func_t *done, void *private, int flags); 367789Sahrens 368789Sahrens extern zio_t *zio_ioctl(zio_t *pio, spa_t *spa, vdev_t *vd, int cmd, 369789Sahrens zio_done_func_t *done, void *private, int priority, int flags); 370789Sahrens 371789Sahrens extern zio_t *zio_read_phys(zio_t *pio, vdev_t *vd, uint64_t offset, 372789Sahrens uint64_t size, void *data, int checksum, 3735450Sbrendan zio_done_func_t *done, void *private, int priority, int flags, 3745450Sbrendan boolean_t labels); 375789Sahrens 376789Sahrens extern zio_t *zio_write_phys(zio_t *pio, vdev_t *vd, uint64_t offset, 377789Sahrens uint64_t size, void *data, int checksum, 3785450Sbrendan zio_done_func_t *done, void *private, int priority, int flags, 3795450Sbrendan boolean_t labels); 380789Sahrens 3813063Sperrin extern int zio_alloc_blk(spa_t *spa, uint64_t size, blkptr_t *new_bp, 3823063Sperrin blkptr_t *old_bp, uint64_t txg); 383789Sahrens extern void zio_free_blk(spa_t *spa, blkptr_t *bp, uint64_t txg); 3845688Sbonwick extern void zio_flush(zio_t *zio, vdev_t *vd); 385789Sahrens 386789Sahrens extern int zio_wait(zio_t *zio); 387789Sahrens extern void zio_nowait(zio_t *zio); 3885530Sbonwick extern void zio_execute(zio_t *zio); 3895530Sbonwick extern void zio_interrupt(zio_t *zio); 3905530Sbonwick 3918632SBill.Moore@Sun.COM extern zio_t *zio_walk_parents(zio_t *cio); 3928632SBill.Moore@Sun.COM extern zio_t *zio_walk_children(zio_t *pio); 3938632SBill.Moore@Sun.COM extern zio_t *zio_unique_parent(zio_t *cio); 3948632SBill.Moore@Sun.COM extern void zio_add_child(zio_t *pio, zio_t *cio); 3958632SBill.Moore@Sun.COM 396789Sahrens extern void *zio_buf_alloc(size_t size); 397789Sahrens extern void zio_buf_free(void *buf, size_t size); 3983290Sjohansen extern void *zio_data_buf_alloc(size_t size); 3993290Sjohansen extern void zio_data_buf_free(void *buf, size_t size); 400789Sahrens 4015329Sgw25295 extern void zio_resubmit_stage_async(void *); 402789Sahrens 403789Sahrens extern zio_t *zio_vdev_child_io(zio_t *zio, blkptr_t *bp, vdev_t *vd, 404789Sahrens uint64_t offset, void *data, uint64_t size, int type, int priority, 405789Sahrens int flags, zio_done_func_t *done, void *private); 406789Sahrens 4077754SJeff.Bonwick@Sun.COM extern zio_t *zio_vdev_delegated_io(vdev_t *vd, uint64_t offset, 4087754SJeff.Bonwick@Sun.COM void *data, uint64_t size, int type, int priority, 4097754SJeff.Bonwick@Sun.COM int flags, zio_done_func_t *done, void *private); 4107754SJeff.Bonwick@Sun.COM 411789Sahrens extern void zio_vdev_io_bypass(zio_t *zio); 412789Sahrens extern void zio_vdev_io_reissue(zio_t *zio); 413789Sahrens extern void zio_vdev_io_redone(zio_t *zio); 414789Sahrens 415789Sahrens extern void zio_checksum_verified(zio_t *zio); 4167754SJeff.Bonwick@Sun.COM extern int zio_worst_error(int e1, int e2); 417789Sahrens 418789Sahrens extern uint8_t zio_checksum_select(uint8_t child, uint8_t parent); 419789Sahrens extern uint8_t zio_compress_select(uint8_t child, uint8_t parent); 420789Sahrens 4217754SJeff.Bonwick@Sun.COM extern void zio_suspend(spa_t *spa, zio_t *zio); 4229234SGeorge.Wilson@Sun.COM extern int zio_resume(spa_t *spa); 4237754SJeff.Bonwick@Sun.COM extern void zio_resume_wait(spa_t *spa); 4241544Seschrock 425789Sahrens /* 426789Sahrens * Initial setup and teardown. 427789Sahrens */ 428789Sahrens extern void zio_init(void); 429789Sahrens extern void zio_fini(void); 430789Sahrens 4311544Seschrock /* 4321544Seschrock * Fault injection 4331544Seschrock */ 4341544Seschrock struct zinject_record; 4351544Seschrock extern uint32_t zio_injection_enabled; 4361544Seschrock extern int zio_inject_fault(char *name, int flags, int *id, 4371544Seschrock struct zinject_record *record); 4381544Seschrock extern int zio_inject_list_next(int *id, char *name, size_t buflen, 4391544Seschrock struct zinject_record *record); 4401544Seschrock extern int zio_clear_fault(int id); 4411544Seschrock extern int zio_handle_fault_injection(zio_t *zio, int error); 442*9725SEric.Schrock@Sun.COM extern int zio_handle_device_injection(vdev_t *vd, zio_t *zio, int error); 4436615Sgw25295 extern int zio_handle_label_injection(zio_t *zio, int error); 4441544Seschrock 445789Sahrens #ifdef __cplusplus 446789Sahrens } 447789Sahrens #endif 448789Sahrens 449789Sahrens #endif /* _ZIO_H */ 450