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 8210922SJeff.Bonwick@Sun.COM #define ZIO_CHECKSUM_MASK 0xffULL 8310922SJeff.Bonwick@Sun.COM #define ZIO_CHECKSUM_VERIFY (1 << 8) 8410922SJeff.Bonwick@Sun.COM 8510922SJeff.Bonwick@Sun.COM #define ZIO_DEDUPCHECKSUM ZIO_CHECKSUM_SHA256 8610922SJeff.Bonwick@Sun.COM #define ZIO_DEDUPDITTO_MIN 100 8710922SJeff.Bonwick@Sun.COM 88789Sahrens enum zio_compress { 89789Sahrens ZIO_COMPRESS_INHERIT = 0, 90789Sahrens ZIO_COMPRESS_ON, 91789Sahrens ZIO_COMPRESS_OFF, 92789Sahrens ZIO_COMPRESS_LZJB, 932986Sek110237 ZIO_COMPRESS_EMPTY, 943886Sahl ZIO_COMPRESS_GZIP_1, 953886Sahl ZIO_COMPRESS_GZIP_2, 963886Sahl ZIO_COMPRESS_GZIP_3, 973886Sahl ZIO_COMPRESS_GZIP_4, 983886Sahl ZIO_COMPRESS_GZIP_5, 993886Sahl ZIO_COMPRESS_GZIP_6, 1003886Sahl ZIO_COMPRESS_GZIP_7, 1013886Sahl ZIO_COMPRESS_GZIP_8, 1023886Sahl ZIO_COMPRESS_GZIP_9, 10310922SJeff.Bonwick@Sun.COM ZIO_COMPRESS_ZLE, 104789Sahrens ZIO_COMPRESS_FUNCTIONS 105789Sahrens }; 106789Sahrens 107789Sahrens #define ZIO_COMPRESS_ON_VALUE ZIO_COMPRESS_LZJB 108789Sahrens #define ZIO_COMPRESS_DEFAULT ZIO_COMPRESS_OFF 109789Sahrens 11010922SJeff.Bonwick@Sun.COM #define BOOTFS_COMPRESS_VALID(compress) \ 11110922SJeff.Bonwick@Sun.COM ((compress) == ZIO_COMPRESS_LZJB || \ 11210922SJeff.Bonwick@Sun.COM ((compress) == ZIO_COMPRESS_ON && \ 11310922SJeff.Bonwick@Sun.COM ZIO_COMPRESS_ON_VALUE == ZIO_COMPRESS_LZJB) || \ 11410922SJeff.Bonwick@Sun.COM (compress) == ZIO_COMPRESS_OFF) 11510922SJeff.Bonwick@Sun.COM 1165329Sgw25295 #define ZIO_FAILURE_MODE_WAIT 0 1175329Sgw25295 #define ZIO_FAILURE_MODE_CONTINUE 1 1185329Sgw25295 #define ZIO_FAILURE_MODE_PANIC 2 1195329Sgw25295 120789Sahrens #define ZIO_PRIORITY_NOW (zio_priority_table[0]) 121789Sahrens #define ZIO_PRIORITY_SYNC_READ (zio_priority_table[1]) 122789Sahrens #define ZIO_PRIORITY_SYNC_WRITE (zio_priority_table[2]) 123*11146SGeorge.Wilson@Sun.COM #define ZIO_PRIORITY_LOG_WRITE (zio_priority_table[3]) 124*11146SGeorge.Wilson@Sun.COM #define ZIO_PRIORITY_CACHE_FILL (zio_priority_table[4]) 125*11146SGeorge.Wilson@Sun.COM #define ZIO_PRIORITY_AGG (zio_priority_table[5]) 126*11146SGeorge.Wilson@Sun.COM #define ZIO_PRIORITY_FREE (zio_priority_table[6]) 127*11146SGeorge.Wilson@Sun.COM #define ZIO_PRIORITY_ASYNC_WRITE (zio_priority_table[7]) 128*11146SGeorge.Wilson@Sun.COM #define ZIO_PRIORITY_ASYNC_READ (zio_priority_table[8]) 129*11146SGeorge.Wilson@Sun.COM #define ZIO_PRIORITY_RESILVER (zio_priority_table[9]) 130*11146SGeorge.Wilson@Sun.COM #define ZIO_PRIORITY_SCRUB (zio_priority_table[10]) 131*11146SGeorge.Wilson@Sun.COM #define ZIO_PRIORITY_TABLE_SIZE 11 132789Sahrens 1335530Sbonwick #define ZIO_PIPELINE_CONTINUE 0x100 1345530Sbonwick #define ZIO_PIPELINE_STOP 0x101 1355530Sbonwick 13610922SJeff.Bonwick@Sun.COM enum zio_flag { 13710922SJeff.Bonwick@Sun.COM /* 13810922SJeff.Bonwick@Sun.COM * Flags inherited by gang, ddt, and vdev children, 13910922SJeff.Bonwick@Sun.COM * and that must be equal for two zios to aggregate 14010922SJeff.Bonwick@Sun.COM */ 14110922SJeff.Bonwick@Sun.COM ZIO_FLAG_DONT_AGGREGATE = 1 << 0, 14210922SJeff.Bonwick@Sun.COM ZIO_FLAG_IO_REPAIR = 1 << 1, 14310922SJeff.Bonwick@Sun.COM ZIO_FLAG_SELF_HEAL = 1 << 2, 14410922SJeff.Bonwick@Sun.COM ZIO_FLAG_RESILVER = 1 << 3, 14510922SJeff.Bonwick@Sun.COM ZIO_FLAG_SCRUB = 1 << 4, 14610922SJeff.Bonwick@Sun.COM ZIO_FLAG_SCRUB_THREAD = 1 << 5, 14710922SJeff.Bonwick@Sun.COM 14810922SJeff.Bonwick@Sun.COM #define ZIO_FLAG_AGG_INHERIT (ZIO_FLAG_CANFAIL - 1) 14910922SJeff.Bonwick@Sun.COM 15010922SJeff.Bonwick@Sun.COM /* 15110922SJeff.Bonwick@Sun.COM * Flags inherited by ddt, gang, and vdev children. 15210922SJeff.Bonwick@Sun.COM */ 15310922SJeff.Bonwick@Sun.COM ZIO_FLAG_CANFAIL = 1 << 6, /* must be first for INHERIT */ 15410922SJeff.Bonwick@Sun.COM ZIO_FLAG_SPECULATIVE = 1 << 7, 15510922SJeff.Bonwick@Sun.COM ZIO_FLAG_CONFIG_WRITER = 1 << 8, 15610922SJeff.Bonwick@Sun.COM ZIO_FLAG_DONT_RETRY = 1 << 9, 15710922SJeff.Bonwick@Sun.COM ZIO_FLAG_DONT_CACHE = 1 << 10, 15810922SJeff.Bonwick@Sun.COM ZIO_FLAG_NODATA = 1 << 11, 15910922SJeff.Bonwick@Sun.COM ZIO_FLAG_INDUCE_DAMAGE = 1 << 12, 16010922SJeff.Bonwick@Sun.COM 16110922SJeff.Bonwick@Sun.COM #define ZIO_FLAG_DDT_INHERIT (ZIO_FLAG_IO_RETRY - 1) 16210922SJeff.Bonwick@Sun.COM #define ZIO_FLAG_GANG_INHERIT (ZIO_FLAG_IO_RETRY - 1) 16310922SJeff.Bonwick@Sun.COM 16410922SJeff.Bonwick@Sun.COM /* 16510922SJeff.Bonwick@Sun.COM * Flags inherited by vdev children. 16610922SJeff.Bonwick@Sun.COM */ 16710922SJeff.Bonwick@Sun.COM ZIO_FLAG_IO_RETRY = 1 << 13, /* must be first for INHERIT */ 16810922SJeff.Bonwick@Sun.COM ZIO_FLAG_PROBE = 1 << 14, 16910922SJeff.Bonwick@Sun.COM ZIO_FLAG_TRYHARD = 1 << 15, 17010922SJeff.Bonwick@Sun.COM ZIO_FLAG_OPTIONAL = 1 << 16, 17110922SJeff.Bonwick@Sun.COM 17210922SJeff.Bonwick@Sun.COM #define ZIO_FLAG_VDEV_INHERIT (ZIO_FLAG_DONT_QUEUE - 1) 17310922SJeff.Bonwick@Sun.COM 17410922SJeff.Bonwick@Sun.COM /* 17510922SJeff.Bonwick@Sun.COM * Flags not inherited by any children. 17610922SJeff.Bonwick@Sun.COM */ 17710922SJeff.Bonwick@Sun.COM ZIO_FLAG_DONT_QUEUE = 1 << 17, /* must be first for INHERIT */ 17810922SJeff.Bonwick@Sun.COM ZIO_FLAG_DONT_PROPAGATE = 1 << 18, 17910922SJeff.Bonwick@Sun.COM ZIO_FLAG_IO_BYPASS = 1 << 19, 18010922SJeff.Bonwick@Sun.COM ZIO_FLAG_IO_REWRITE = 1 << 20, 18110922SJeff.Bonwick@Sun.COM ZIO_FLAG_RAW = 1 << 21, 18210922SJeff.Bonwick@Sun.COM ZIO_FLAG_GANG_CHILD = 1 << 22, 18310922SJeff.Bonwick@Sun.COM ZIO_FLAG_DDT_CHILD = 1 << 23, 18410922SJeff.Bonwick@Sun.COM ZIO_FLAG_GODFATHER = 1 << 24 18510922SJeff.Bonwick@Sun.COM }; 18610922SJeff.Bonwick@Sun.COM 18710922SJeff.Bonwick@Sun.COM #define ZIO_FLAG_MUSTSUCCEED 0 18810922SJeff.Bonwick@Sun.COM 18910922SJeff.Bonwick@Sun.COM #define ZIO_DDT_CHILD_FLAGS(zio) \ 19010922SJeff.Bonwick@Sun.COM (((zio)->io_flags & ZIO_FLAG_DDT_INHERIT) | \ 19110922SJeff.Bonwick@Sun.COM ZIO_FLAG_DDT_CHILD | ZIO_FLAG_CANFAIL) 19210922SJeff.Bonwick@Sun.COM 1937754SJeff.Bonwick@Sun.COM #define ZIO_GANG_CHILD_FLAGS(zio) \ 1947754SJeff.Bonwick@Sun.COM (((zio)->io_flags & ZIO_FLAG_GANG_INHERIT) | \ 1957754SJeff.Bonwick@Sun.COM ZIO_FLAG_GANG_CHILD | ZIO_FLAG_CANFAIL) 1967754SJeff.Bonwick@Sun.COM 19710922SJeff.Bonwick@Sun.COM #define ZIO_VDEV_CHILD_FLAGS(zio) \ 19810922SJeff.Bonwick@Sun.COM (((zio)->io_flags & ZIO_FLAG_VDEV_INHERIT) | \ 19910922SJeff.Bonwick@Sun.COM ZIO_FLAG_CANFAIL) 20010922SJeff.Bonwick@Sun.COM 2017754SJeff.Bonwick@Sun.COM enum zio_child { 2027754SJeff.Bonwick@Sun.COM ZIO_CHILD_VDEV = 0, 2037754SJeff.Bonwick@Sun.COM ZIO_CHILD_GANG, 20410922SJeff.Bonwick@Sun.COM ZIO_CHILD_DDT, 2057754SJeff.Bonwick@Sun.COM ZIO_CHILD_LOGICAL, 2067754SJeff.Bonwick@Sun.COM ZIO_CHILD_TYPES 2077754SJeff.Bonwick@Sun.COM }; 2087754SJeff.Bonwick@Sun.COM 2097754SJeff.Bonwick@Sun.COM enum zio_wait_type { 2107754SJeff.Bonwick@Sun.COM ZIO_WAIT_READY = 0, 2117754SJeff.Bonwick@Sun.COM ZIO_WAIT_DONE, 2127754SJeff.Bonwick@Sun.COM ZIO_WAIT_TYPES 2137754SJeff.Bonwick@Sun.COM }; 2147754SJeff.Bonwick@Sun.COM 215789Sahrens /* 2166423Sgw25295 * We'll take the unused errnos, 'EBADE' and 'EBADR' (from the Convergent 2176423Sgw25295 * graveyard) to indicate checksum errors and fragmentation. 218789Sahrens */ 219789Sahrens #define ECKSUM EBADE 2206423Sgw25295 #define EFRAGS EBADR 221789Sahrens 222789Sahrens typedef void zio_done_func_t(zio_t *zio); 223789Sahrens 224789Sahrens extern uint8_t zio_priority_table[ZIO_PRIORITY_TABLE_SIZE]; 225789Sahrens extern char *zio_type_name[ZIO_TYPES]; 226789Sahrens 2271544Seschrock /* 2281544Seschrock * A bookmark is a four-tuple <objset, object, level, blkid> that uniquely 2291544Seschrock * identifies any block in the pool. By convention, the meta-objset (MOS) 23010922SJeff.Bonwick@Sun.COM * is objset 0, and the meta-dnode is object 0. This covers all blocks 23110922SJeff.Bonwick@Sun.COM * except root blocks and ZIL blocks, which are defined as follows: 2321544Seschrock * 23310922SJeff.Bonwick@Sun.COM * Root blocks (objset_phys_t) are object 0, level -1: <objset, 0, -1, 0>. 23410922SJeff.Bonwick@Sun.COM * ZIL blocks are bookmarked <objset, 0, -2, blkid == ZIL sequence number>. 23510922SJeff.Bonwick@Sun.COM * dmu_sync()ed ZIL data blocks are bookmarked <objset, object, -2, blkid>. 2361544Seschrock * 23710922SJeff.Bonwick@Sun.COM * Note: this structure is called a bookmark because its original purpose 23810922SJeff.Bonwick@Sun.COM * was to remember where to resume a pool-wide traverse. 2391544Seschrock * 2401544Seschrock * Note: this structure is passed between userland and the kernel. 2411544Seschrock * Therefore it must not change size or alignment between 32/64 bit 2421544Seschrock * compilation options. 2431544Seschrock */ 2441544Seschrock typedef struct zbookmark { 2451544Seschrock uint64_t zb_objset; 2461544Seschrock uint64_t zb_object; 2471544Seschrock int64_t zb_level; 2481544Seschrock uint64_t zb_blkid; 2491544Seschrock } zbookmark_t; 2501544Seschrock 25110922SJeff.Bonwick@Sun.COM #define SET_BOOKMARK(zb, objset, object, level, blkid) \ 25210922SJeff.Bonwick@Sun.COM { \ 25310922SJeff.Bonwick@Sun.COM (zb)->zb_objset = objset; \ 25410922SJeff.Bonwick@Sun.COM (zb)->zb_object = object; \ 25510922SJeff.Bonwick@Sun.COM (zb)->zb_level = level; \ 25610922SJeff.Bonwick@Sun.COM (zb)->zb_blkid = blkid; \ 25710922SJeff.Bonwick@Sun.COM } 25810922SJeff.Bonwick@Sun.COM 25910922SJeff.Bonwick@Sun.COM #define ZB_DESTROYED_OBJSET (-1ULL) 26010922SJeff.Bonwick@Sun.COM 26110922SJeff.Bonwick@Sun.COM #define ZB_ROOT_OBJECT (0ULL) 26210922SJeff.Bonwick@Sun.COM #define ZB_ROOT_LEVEL (-1LL) 26310922SJeff.Bonwick@Sun.COM #define ZB_ROOT_BLKID (0ULL) 26410922SJeff.Bonwick@Sun.COM 26510922SJeff.Bonwick@Sun.COM #define ZB_ZIL_OBJECT (0ULL) 26610922SJeff.Bonwick@Sun.COM #define ZB_ZIL_LEVEL (-2LL) 26710922SJeff.Bonwick@Sun.COM 2687754SJeff.Bonwick@Sun.COM typedef struct zio_prop { 2697754SJeff.Bonwick@Sun.COM enum zio_checksum zp_checksum; 2707754SJeff.Bonwick@Sun.COM enum zio_compress zp_compress; 2717754SJeff.Bonwick@Sun.COM dmu_object_type_t zp_type; 2727754SJeff.Bonwick@Sun.COM uint8_t zp_level; 27310922SJeff.Bonwick@Sun.COM uint8_t zp_copies; 27410922SJeff.Bonwick@Sun.COM uint8_t zp_dedup; 27510922SJeff.Bonwick@Sun.COM uint8_t zp_dedup_verify; 2767754SJeff.Bonwick@Sun.COM } zio_prop_t; 2777754SJeff.Bonwick@Sun.COM 27810614SJonathan.Adams@Sun.COM typedef struct zio_cksum_report zio_cksum_report_t; 27910614SJonathan.Adams@Sun.COM 28010614SJonathan.Adams@Sun.COM typedef void zio_cksum_finish_f(zio_cksum_report_t *rep, 28110614SJonathan.Adams@Sun.COM const void *good_data); 28210614SJonathan.Adams@Sun.COM typedef void zio_cksum_free_f(void *cbdata, size_t size); 28310614SJonathan.Adams@Sun.COM 28410614SJonathan.Adams@Sun.COM struct zio_bad_cksum; /* defined in zio_checksum.h */ 28510614SJonathan.Adams@Sun.COM 28610614SJonathan.Adams@Sun.COM struct zio_cksum_report { 28710614SJonathan.Adams@Sun.COM struct zio_cksum_report *zcr_next; 28810614SJonathan.Adams@Sun.COM nvlist_t *zcr_ereport; 28910614SJonathan.Adams@Sun.COM nvlist_t *zcr_detector; 29010614SJonathan.Adams@Sun.COM void *zcr_cbdata; 29110614SJonathan.Adams@Sun.COM size_t zcr_cbinfo; /* passed to zcr_free() */ 29210922SJeff.Bonwick@Sun.COM uint64_t zcr_align; 29310614SJonathan.Adams@Sun.COM uint64_t zcr_length; 29410614SJonathan.Adams@Sun.COM zio_cksum_finish_f *zcr_finish; 29510614SJonathan.Adams@Sun.COM zio_cksum_free_f *zcr_free; 29610614SJonathan.Adams@Sun.COM 29710614SJonathan.Adams@Sun.COM /* internal use only */ 29810614SJonathan.Adams@Sun.COM struct zio_bad_cksum *zcr_ckinfo; /* information from failure */ 29910614SJonathan.Adams@Sun.COM }; 30010614SJonathan.Adams@Sun.COM 30110614SJonathan.Adams@Sun.COM typedef void zio_vsd_cksum_report_f(zio_t *zio, zio_cksum_report_t *zcr, 30210614SJonathan.Adams@Sun.COM void *arg); 30310614SJonathan.Adams@Sun.COM 30410614SJonathan.Adams@Sun.COM zio_vsd_cksum_report_f zio_vsd_default_cksum_report; 30510614SJonathan.Adams@Sun.COM 30610614SJonathan.Adams@Sun.COM typedef struct zio_vsd_ops { 30710614SJonathan.Adams@Sun.COM zio_done_func_t *vsd_free; 30810614SJonathan.Adams@Sun.COM zio_vsd_cksum_report_f *vsd_cksum_report; 30910614SJonathan.Adams@Sun.COM } zio_vsd_ops_t; 31010614SJonathan.Adams@Sun.COM 3117754SJeff.Bonwick@Sun.COM typedef struct zio_gang_node { 3127754SJeff.Bonwick@Sun.COM zio_gbh_phys_t *gn_gbh; 3137754SJeff.Bonwick@Sun.COM struct zio_gang_node *gn_child[SPA_GBH_NBLKPTRS]; 3147754SJeff.Bonwick@Sun.COM } zio_gang_node_t; 3157754SJeff.Bonwick@Sun.COM 3167754SJeff.Bonwick@Sun.COM typedef zio_t *zio_gang_issue_func_t(zio_t *zio, blkptr_t *bp, 3177754SJeff.Bonwick@Sun.COM zio_gang_node_t *gn, void *data); 3187754SJeff.Bonwick@Sun.COM 3197754SJeff.Bonwick@Sun.COM typedef void zio_transform_func_t(zio_t *zio, void *data, uint64_t size); 3207754SJeff.Bonwick@Sun.COM 3217754SJeff.Bonwick@Sun.COM typedef struct zio_transform { 3227754SJeff.Bonwick@Sun.COM void *zt_orig_data; 3237754SJeff.Bonwick@Sun.COM uint64_t zt_orig_size; 3247754SJeff.Bonwick@Sun.COM uint64_t zt_bufsize; 3257754SJeff.Bonwick@Sun.COM zio_transform_func_t *zt_transform; 3267754SJeff.Bonwick@Sun.COM struct zio_transform *zt_next; 3277754SJeff.Bonwick@Sun.COM } zio_transform_t; 3287754SJeff.Bonwick@Sun.COM 3297754SJeff.Bonwick@Sun.COM typedef int zio_pipe_stage_t(zio_t *zio); 3307754SJeff.Bonwick@Sun.COM 3317754SJeff.Bonwick@Sun.COM /* 3327754SJeff.Bonwick@Sun.COM * The io_reexecute flags are distinct from io_flags because the child must 3337754SJeff.Bonwick@Sun.COM * be able to propagate them to the parent. The normal io_flags are local 3347754SJeff.Bonwick@Sun.COM * to the zio, not protected by any lock, and not modifiable by children; 3357754SJeff.Bonwick@Sun.COM * the reexecute flags are protected by io_lock, modifiable by children, 3367754SJeff.Bonwick@Sun.COM * and always propagated -- even when ZIO_FLAG_DONT_PROPAGATE is set. 3377754SJeff.Bonwick@Sun.COM */ 3387754SJeff.Bonwick@Sun.COM #define ZIO_REEXECUTE_NOW 0x01 3397754SJeff.Bonwick@Sun.COM #define ZIO_REEXECUTE_SUSPEND 0x02 3407754SJeff.Bonwick@Sun.COM 3418632SBill.Moore@Sun.COM typedef struct zio_link { 3428632SBill.Moore@Sun.COM zio_t *zl_parent; 3438632SBill.Moore@Sun.COM zio_t *zl_child; 3448632SBill.Moore@Sun.COM list_node_t zl_parent_node; 3458632SBill.Moore@Sun.COM list_node_t zl_child_node; 3468632SBill.Moore@Sun.COM } zio_link_t; 3478632SBill.Moore@Sun.COM 348789Sahrens struct zio { 349789Sahrens /* Core information about this I/O */ 3507754SJeff.Bonwick@Sun.COM zbookmark_t io_bookmark; 3517754SJeff.Bonwick@Sun.COM zio_prop_t io_prop; 3527754SJeff.Bonwick@Sun.COM zio_type_t io_type; 3537754SJeff.Bonwick@Sun.COM enum zio_child io_child_type; 3547754SJeff.Bonwick@Sun.COM int io_cmd; 3557754SJeff.Bonwick@Sun.COM uint8_t io_priority; 3567754SJeff.Bonwick@Sun.COM uint8_t io_reexecute; 3578632SBill.Moore@Sun.COM uint8_t io_state[ZIO_WAIT_TYPES]; 3587754SJeff.Bonwick@Sun.COM uint64_t io_txg; 359789Sahrens spa_t *io_spa; 360789Sahrens blkptr_t *io_bp; 36110922SJeff.Bonwick@Sun.COM blkptr_t *io_bp_override; 362789Sahrens blkptr_t io_bp_copy; 3638632SBill.Moore@Sun.COM list_t io_parent_list; 3648632SBill.Moore@Sun.COM list_t io_child_list; 3658632SBill.Moore@Sun.COM zio_link_t *io_walk_link; 3667754SJeff.Bonwick@Sun.COM zio_t *io_logical; 367789Sahrens zio_transform_t *io_transform_stack; 368789Sahrens 369789Sahrens /* Callback info */ 3703547Smaybee zio_done_func_t *io_ready; 371789Sahrens zio_done_func_t *io_done; 372789Sahrens void *io_private; 37310922SJeff.Bonwick@Sun.COM int64_t io_prev_space_delta; /* DMU private */ 374789Sahrens blkptr_t io_bp_orig; 375789Sahrens 376789Sahrens /* Data represented by this I/O */ 377789Sahrens void *io_data; 37810922SJeff.Bonwick@Sun.COM void *io_orig_data; 379789Sahrens uint64_t io_size; 38010922SJeff.Bonwick@Sun.COM uint64_t io_orig_size; 381789Sahrens 382789Sahrens /* Stuff for the vdev stack */ 383789Sahrens vdev_t *io_vd; 384789Sahrens void *io_vsd; 38510614SJonathan.Adams@Sun.COM const zio_vsd_ops_t *io_vsd_ops; 38610614SJonathan.Adams@Sun.COM 387789Sahrens uint64_t io_offset; 388789Sahrens uint64_t io_deadline; 389789Sahrens avl_node_t io_offset_node; 390789Sahrens avl_node_t io_deadline_node; 391789Sahrens avl_tree_t *io_vdev_tree; 392789Sahrens 393789Sahrens /* Internal pipeline state */ 39410922SJeff.Bonwick@Sun.COM enum zio_flag io_flags; 39510922SJeff.Bonwick@Sun.COM enum zio_stage io_stage; 39610922SJeff.Bonwick@Sun.COM enum zio_stage io_pipeline; 39710922SJeff.Bonwick@Sun.COM enum zio_flag io_orig_flags; 39810922SJeff.Bonwick@Sun.COM enum zio_stage io_orig_stage; 39910922SJeff.Bonwick@Sun.COM enum zio_stage io_orig_pipeline; 400789Sahrens int io_error; 4017754SJeff.Bonwick@Sun.COM int io_child_error[ZIO_CHILD_TYPES]; 4027754SJeff.Bonwick@Sun.COM uint64_t io_children[ZIO_CHILD_TYPES][ZIO_WAIT_TYPES]; 40310922SJeff.Bonwick@Sun.COM uint64_t io_child_count; 40410922SJeff.Bonwick@Sun.COM uint64_t io_parent_count; 4057754SJeff.Bonwick@Sun.COM uint64_t *io_stall; 4069443SBill.Moore@Sun.COM zio_t *io_gang_leader; 4077754SJeff.Bonwick@Sun.COM zio_gang_node_t *io_gang_tree; 4087754SJeff.Bonwick@Sun.COM void *io_executor; 409789Sahrens void *io_waiter; 410789Sahrens kmutex_t io_lock; 411789Sahrens kcondvar_t io_cv; 4121544Seschrock 4131544Seschrock /* FMA state */ 41410614SJonathan.Adams@Sun.COM zio_cksum_report_t *io_cksum_report; 4151544Seschrock uint64_t io_ena; 416789Sahrens }; 417789Sahrens 4188632SBill.Moore@Sun.COM extern zio_t *zio_null(zio_t *pio, spa_t *spa, vdev_t *vd, 41910922SJeff.Bonwick@Sun.COM zio_done_func_t *done, void *private, enum zio_flag flags); 420789Sahrens 421789Sahrens extern zio_t *zio_root(spa_t *spa, 42210922SJeff.Bonwick@Sun.COM zio_done_func_t *done, void *private, enum zio_flag flags); 423789Sahrens 4247046Sahrens extern zio_t *zio_read(zio_t *pio, spa_t *spa, const blkptr_t *bp, void *data, 425789Sahrens uint64_t size, zio_done_func_t *done, void *private, 42610922SJeff.Bonwick@Sun.COM int priority, enum zio_flag flags, const zbookmark_t *zb); 427789Sahrens 4287754SJeff.Bonwick@Sun.COM extern zio_t *zio_write(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp, 42910922SJeff.Bonwick@Sun.COM void *data, uint64_t size, const zio_prop_t *zp, 4307754SJeff.Bonwick@Sun.COM zio_done_func_t *ready, zio_done_func_t *done, void *private, 43110922SJeff.Bonwick@Sun.COM int priority, enum zio_flag flags, const zbookmark_t *zb); 432789Sahrens 4337754SJeff.Bonwick@Sun.COM extern zio_t *zio_rewrite(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp, 4347754SJeff.Bonwick@Sun.COM void *data, uint64_t size, zio_done_func_t *done, void *private, 43510922SJeff.Bonwick@Sun.COM int priority, enum zio_flag flags, zbookmark_t *zb); 436789Sahrens 43710922SJeff.Bonwick@Sun.COM extern void zio_write_override(zio_t *zio, blkptr_t *bp, int copies); 4387872STim.Haley@Sun.COM 43910922SJeff.Bonwick@Sun.COM extern void zio_free(spa_t *spa, uint64_t txg, const blkptr_t *bp); 440789Sahrens 44110922SJeff.Bonwick@Sun.COM extern zio_t *zio_claim(zio_t *pio, spa_t *spa, uint64_t txg, 44210922SJeff.Bonwick@Sun.COM const blkptr_t *bp, 44310922SJeff.Bonwick@Sun.COM zio_done_func_t *done, void *private, enum zio_flag flags); 444789Sahrens 445789Sahrens extern zio_t *zio_ioctl(zio_t *pio, spa_t *spa, vdev_t *vd, int cmd, 44610922SJeff.Bonwick@Sun.COM zio_done_func_t *done, void *private, int priority, enum zio_flag flags); 447789Sahrens 448789Sahrens extern zio_t *zio_read_phys(zio_t *pio, vdev_t *vd, uint64_t offset, 449789Sahrens uint64_t size, void *data, int checksum, 45010922SJeff.Bonwick@Sun.COM zio_done_func_t *done, void *private, int priority, enum zio_flag flags, 4515450Sbrendan boolean_t labels); 452789Sahrens 453789Sahrens extern zio_t *zio_write_phys(zio_t *pio, vdev_t *vd, uint64_t offset, 454789Sahrens uint64_t size, void *data, int checksum, 45510922SJeff.Bonwick@Sun.COM zio_done_func_t *done, void *private, int priority, enum zio_flag flags, 4565450Sbrendan boolean_t labels); 457789Sahrens 45810922SJeff.Bonwick@Sun.COM extern zio_t *zio_free_sync(zio_t *pio, spa_t *spa, uint64_t txg, 45910922SJeff.Bonwick@Sun.COM const blkptr_t *bp, enum zio_flag flags); 46010922SJeff.Bonwick@Sun.COM 46110922SJeff.Bonwick@Sun.COM extern int zio_alloc_zil(spa_t *spa, uint64_t txg, blkptr_t *new_bp, 46210922SJeff.Bonwick@Sun.COM blkptr_t *old_bp, uint64_t size, boolean_t use_slog); 46310922SJeff.Bonwick@Sun.COM extern void zio_free_zil(spa_t *spa, uint64_t txg, blkptr_t *bp); 4645688Sbonwick extern void zio_flush(zio_t *zio, vdev_t *vd); 465789Sahrens 466789Sahrens extern int zio_wait(zio_t *zio); 467789Sahrens extern void zio_nowait(zio_t *zio); 4685530Sbonwick extern void zio_execute(zio_t *zio); 4695530Sbonwick extern void zio_interrupt(zio_t *zio); 4705530Sbonwick 4718632SBill.Moore@Sun.COM extern zio_t *zio_walk_parents(zio_t *cio); 4728632SBill.Moore@Sun.COM extern zio_t *zio_walk_children(zio_t *pio); 4738632SBill.Moore@Sun.COM extern zio_t *zio_unique_parent(zio_t *cio); 4748632SBill.Moore@Sun.COM extern void zio_add_child(zio_t *pio, zio_t *cio); 4758632SBill.Moore@Sun.COM 476789Sahrens extern void *zio_buf_alloc(size_t size); 477789Sahrens extern void zio_buf_free(void *buf, size_t size); 4783290Sjohansen extern void *zio_data_buf_alloc(size_t size); 4793290Sjohansen extern void zio_data_buf_free(void *buf, size_t size); 480789Sahrens 4815329Sgw25295 extern void zio_resubmit_stage_async(void *); 482789Sahrens 483789Sahrens extern zio_t *zio_vdev_child_io(zio_t *zio, blkptr_t *bp, vdev_t *vd, 484789Sahrens uint64_t offset, void *data, uint64_t size, int type, int priority, 48510922SJeff.Bonwick@Sun.COM enum zio_flag flags, zio_done_func_t *done, void *private); 486789Sahrens 4877754SJeff.Bonwick@Sun.COM extern zio_t *zio_vdev_delegated_io(vdev_t *vd, uint64_t offset, 4887754SJeff.Bonwick@Sun.COM void *data, uint64_t size, int type, int priority, 48910922SJeff.Bonwick@Sun.COM enum zio_flag flags, zio_done_func_t *done, void *private); 4907754SJeff.Bonwick@Sun.COM 491789Sahrens extern void zio_vdev_io_bypass(zio_t *zio); 492789Sahrens extern void zio_vdev_io_reissue(zio_t *zio); 493789Sahrens extern void zio_vdev_io_redone(zio_t *zio); 494789Sahrens 495789Sahrens extern void zio_checksum_verified(zio_t *zio); 4967754SJeff.Bonwick@Sun.COM extern int zio_worst_error(int e1, int e2); 497789Sahrens 49810922SJeff.Bonwick@Sun.COM extern enum zio_checksum zio_checksum_select(enum zio_checksum child, 49910922SJeff.Bonwick@Sun.COM enum zio_checksum parent); 50010922SJeff.Bonwick@Sun.COM extern enum zio_checksum zio_checksum_dedup_select(spa_t *spa, 50110922SJeff.Bonwick@Sun.COM enum zio_checksum child, enum zio_checksum parent); 50210922SJeff.Bonwick@Sun.COM extern enum zio_compress zio_compress_select(enum zio_compress child, 50310922SJeff.Bonwick@Sun.COM enum zio_compress parent); 504789Sahrens 5057754SJeff.Bonwick@Sun.COM extern void zio_suspend(spa_t *spa, zio_t *zio); 5069234SGeorge.Wilson@Sun.COM extern int zio_resume(spa_t *spa); 5077754SJeff.Bonwick@Sun.COM extern void zio_resume_wait(spa_t *spa); 5081544Seschrock 509789Sahrens /* 510789Sahrens * Initial setup and teardown. 511789Sahrens */ 512789Sahrens extern void zio_init(void); 513789Sahrens extern void zio_fini(void); 514789Sahrens 5151544Seschrock /* 5161544Seschrock * Fault injection 5171544Seschrock */ 5181544Seschrock struct zinject_record; 5191544Seschrock extern uint32_t zio_injection_enabled; 5201544Seschrock extern int zio_inject_fault(char *name, int flags, int *id, 5211544Seschrock struct zinject_record *record); 5221544Seschrock extern int zio_inject_list_next(int *id, char *name, size_t buflen, 5231544Seschrock struct zinject_record *record); 5241544Seschrock extern int zio_clear_fault(int id); 52510594SGeorge.Wilson@Sun.COM extern void zio_handle_panic_injection(spa_t *spa, char *tag); 5261544Seschrock extern int zio_handle_fault_injection(zio_t *zio, int error); 5279725SEric.Schrock@Sun.COM extern int zio_handle_device_injection(vdev_t *vd, zio_t *zio, int error); 5286615Sgw25295 extern int zio_handle_label_injection(zio_t *zio, int error); 52910921STim.Haley@Sun.COM extern void zio_handle_ignored_writes(zio_t *zio); 5301544Seschrock 53110614SJonathan.Adams@Sun.COM /* 53210614SJonathan.Adams@Sun.COM * Checksum ereport functions 53310614SJonathan.Adams@Sun.COM */ 53410614SJonathan.Adams@Sun.COM extern void zfs_ereport_start_checksum(spa_t *spa, vdev_t *vd, struct zio *zio, 53510614SJonathan.Adams@Sun.COM uint64_t offset, uint64_t length, void *arg, struct zio_bad_cksum *info); 53610614SJonathan.Adams@Sun.COM extern void zfs_ereport_finish_checksum(zio_cksum_report_t *report, 53710614SJonathan.Adams@Sun.COM const void *good_data, const void *bad_data, boolean_t drop_if_identical); 53810614SJonathan.Adams@Sun.COM 53910614SJonathan.Adams@Sun.COM extern void zfs_ereport_send_interim_checksum(zio_cksum_report_t *report); 54010614SJonathan.Adams@Sun.COM extern void zfs_ereport_free_checksum(zio_cksum_report_t *report); 54110614SJonathan.Adams@Sun.COM 54210614SJonathan.Adams@Sun.COM /* If we have the good data in hand, this function can be used */ 54310614SJonathan.Adams@Sun.COM extern void zfs_ereport_post_checksum(spa_t *spa, vdev_t *vd, 54410614SJonathan.Adams@Sun.COM struct zio *zio, uint64_t offset, uint64_t length, 54510614SJonathan.Adams@Sun.COM const void *good_data, const void *bad_data, struct zio_bad_cksum *info); 54610614SJonathan.Adams@Sun.COM 54710921STim.Haley@Sun.COM /* Called from spa_sync(), but primarily an injection handler */ 54810921STim.Haley@Sun.COM extern void spa_handle_ignored_writes(spa_t *spa); 54910921STim.Haley@Sun.COM 550789Sahrens #ifdef __cplusplus 551789Sahrens } 552789Sahrens #endif 553789Sahrens 554789Sahrens #endif /* _ZIO_H */ 555