1 // SPDX-License-Identifier: CDDL-1.0 2 /* 3 * CDDL HEADER START 4 * 5 * The contents of this file are subject to the terms of the 6 * Common Development and Distribution License (the "License"). 7 * You may not use this file except in compliance with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or https://opensource.org/licenses/CDDL-1.0. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 24 * Copyright (c) 2012, 2018 by Delphix. All rights reserved. 25 */ 26 27 /* Portions Copyright 2010 Robert Milkowski */ 28 29 #ifndef _SYS_ZIL_H 30 #define _SYS_ZIL_H 31 32 #include <sys/types.h> 33 #include <sys/spa.h> 34 #include <sys/zio.h> 35 #include <sys/dmu.h> 36 #include <sys/zio_crypt.h> 37 #include <sys/wmsum.h> 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif 42 43 struct dsl_pool; 44 struct dsl_dataset; 45 struct lwb; 46 47 /* 48 * Intent log format: 49 * 50 * Each objset has its own intent log. The log header (zil_header_t) 51 * for objset N's intent log is kept in the Nth object of the SPA's 52 * intent_log objset. The log header points to a chain of log blocks, 53 * each of which contains log records (i.e., transactions) followed by 54 * a log block trailer (zil_trailer_t). The format of a log record 55 * depends on the record (or transaction) type, but all records begin 56 * with a common structure that defines the type, length, and txg. 57 */ 58 59 /* 60 * Intent log header - this on disk structure holds fields to manage 61 * the log. All fields are 64 bit to easily handle cross architectures. 62 */ 63 typedef struct zil_header { 64 uint64_t zh_claim_txg; /* txg in which log blocks were claimed */ 65 uint64_t zh_replay_seq; /* highest replayed sequence number */ 66 blkptr_t zh_log; /* log chain */ 67 uint64_t zh_claim_blk_seq; /* highest claimed block sequence number */ 68 uint64_t zh_flags; /* header flags */ 69 uint64_t zh_claim_lr_seq; /* highest claimed lr sequence number */ 70 uint64_t zh_pad[3]; 71 } zil_header_t; 72 73 /* 74 * zh_flags bit settings 75 */ 76 #define ZIL_REPLAY_NEEDED 0x1 /* replay needed - internal only */ 77 #define ZIL_CLAIM_LR_SEQ_VALID 0x2 /* zh_claim_lr_seq field is valid */ 78 79 /* 80 * Log block chaining. 81 * 82 * Log blocks are chained together. Originally they were chained at the 83 * end of the block. For performance reasons the chain was moved to the 84 * beginning of the block which allows writes for only the data being used. 85 * The older position is supported for backwards compatibility. 86 * 87 * The zio_eck_t contains a zec_cksum which for the intent log is 88 * the sequence number of this log block. A seq of 0 is invalid. 89 * The zec_cksum is checked by the SPA against the sequence 90 * number passed in the blk_cksum field of the blkptr_t 91 */ 92 typedef struct zil_chain { 93 uint64_t zc_pad; 94 blkptr_t zc_next_blk; /* next block in chain */ 95 uint64_t zc_nused; /* bytes in log block used */ 96 zio_eck_t zc_eck; /* block trailer */ 97 } zil_chain_t; 98 99 #define ZIL_MIN_BLKSZ 4096ULL 100 101 /* 102 * ziltest is by and large an ugly hack, but very useful in 103 * checking replay without tedious work. 104 * When running ziltest we want to keep all itx's and so maintain 105 * a single list in the zl_itxg[] that uses a high txg: ZILTEST_TXG 106 * We subtract TXG_CONCURRENT_STATES to allow for common code. 107 */ 108 #define ZILTEST_TXG (UINT64_MAX - TXG_CONCURRENT_STATES) 109 110 /* 111 * The words of a log block checksum. 112 */ 113 #define ZIL_ZC_GUID_0 0 114 #define ZIL_ZC_GUID_1 1 115 #define ZIL_ZC_OBJSET 2 116 #define ZIL_ZC_SEQ 3 117 118 typedef enum zil_create { 119 Z_FILE, 120 Z_DIR, 121 Z_XATTRDIR, 122 } zil_create_t; 123 124 /* 125 * size of xvattr log section. 126 * its composed of lr_attr_t + xvattr bitmap + 2 64 bit timestamps 127 * for create time and a single 64 bit integer for all of the attributes, 128 * and 4 64 bit integers (32 bytes) for the scanstamp. 129 * 130 */ 131 132 #define ZIL_XVAT_SIZE(mapsize) \ 133 sizeof (lr_attr_t) + (sizeof (uint32_t) * (mapsize - 1)) + \ 134 (sizeof (uint64_t) * 7) 135 136 /* 137 * Size of ACL in log. The ACE data is padded out to properly align 138 * on 8 byte boundary. 139 */ 140 141 #define ZIL_ACE_LENGTH(x) (roundup(x, sizeof (uint64_t))) 142 143 /* 144 * Intent log transaction types and record structures 145 */ 146 #define TX_COMMIT 0 /* Commit marker (no on-disk state) */ 147 #define TX_CREATE 1 /* Create file */ 148 #define TX_MKDIR 2 /* Make directory */ 149 #define TX_MKXATTR 3 /* Make XATTR directory */ 150 #define TX_SYMLINK 4 /* Create symbolic link to a file */ 151 #define TX_REMOVE 5 /* Remove file */ 152 #define TX_RMDIR 6 /* Remove directory */ 153 #define TX_LINK 7 /* Create hard link to a file */ 154 #define TX_RENAME 8 /* Rename a file */ 155 #define TX_WRITE 9 /* File write */ 156 #define TX_TRUNCATE 10 /* Truncate a file */ 157 #define TX_SETATTR 11 /* Set file attributes */ 158 #define TX_ACL_V0 12 /* Set old formatted ACL */ 159 #define TX_ACL 13 /* Set ACL */ 160 #define TX_CREATE_ACL 14 /* create with ACL */ 161 #define TX_CREATE_ATTR 15 /* create + attrs */ 162 #define TX_CREATE_ACL_ATTR 16 /* create with ACL + attrs */ 163 #define TX_MKDIR_ACL 17 /* mkdir with ACL */ 164 #define TX_MKDIR_ATTR 18 /* mkdir with attr */ 165 #define TX_MKDIR_ACL_ATTR 19 /* mkdir with ACL + attrs */ 166 #define TX_WRITE2 20 /* dmu_sync EALREADY write */ 167 #define TX_SETSAXATTR 21 /* Set sa xattrs on file */ 168 #define TX_RENAME_EXCHANGE 22 /* Atomic swap via renameat2 */ 169 #define TX_RENAME_WHITEOUT 23 /* Atomic whiteout via renameat2 */ 170 #define TX_CLONE_RANGE 24 /* Clone a file range */ 171 #define TX_MAX_TYPE 25 /* Max transaction type */ 172 173 /* 174 * The transactions for mkdir, symlink, remove, rmdir, link, and rename 175 * may have the following bit set, indicating the original request 176 * specified case-insensitive handling of names. 177 */ 178 #define TX_CI ((uint64_t)0x1 << 63) /* case-insensitive behavior requested */ 179 180 /* 181 * Transactions for operations below can be logged out of order. 182 * For convenience in the code, all such records must have lr_foid 183 * at the same offset. 184 */ 185 #define TX_OOO(txtype) \ 186 ((txtype) == TX_WRITE || \ 187 (txtype) == TX_TRUNCATE || \ 188 (txtype) == TX_SETATTR || \ 189 (txtype) == TX_ACL_V0 || \ 190 (txtype) == TX_ACL || \ 191 (txtype) == TX_WRITE2 || \ 192 (txtype) == TX_SETSAXATTR || \ 193 (txtype) == TX_CLONE_RANGE) 194 195 /* 196 * The number of dnode slots consumed by the object is stored in the 8 197 * unused upper bits of the object ID. We subtract 1 from the value 198 * stored on disk for compatibility with implementations that don't 199 * support large dnodes. The slot count for a single-slot dnode will 200 * contain 0 for those bits to preserve the log record format for 201 * "small" dnodes. 202 */ 203 #define LR_FOID_GET_SLOTS(oid) (BF64_GET((oid), 56, 8) + 1) 204 #define LR_FOID_SET_SLOTS(oid, x) BF64_SET((oid), 56, 8, (x) - 1) 205 #define LR_FOID_GET_OBJ(oid) BF64_GET((oid), 0, DN_MAX_OBJECT_SHIFT) 206 #define LR_FOID_SET_OBJ(oid, x) BF64_SET((oid), 0, DN_MAX_OBJECT_SHIFT, (x)) 207 208 /* 209 * Format of log records. 210 * The fields are carefully defined to allow them to be aligned 211 * and sized the same on sparc & intel architectures. 212 * Each log record has a common structure at the beginning. 213 * 214 * The log record on disk (lrc_seq) holds the sequence number of all log 215 * records which is used to ensure we don't replay the same record. 216 */ 217 typedef struct { /* common log record header */ 218 uint64_t lrc_txtype; /* intent log transaction type */ 219 uint64_t lrc_reclen; /* transaction record length */ 220 uint64_t lrc_txg; /* dmu transaction group number */ 221 uint64_t lrc_seq; /* see comment above */ 222 } lr_t; 223 224 /* 225 * Common start of all out-of-order record types (TX_OOO() above). 226 */ 227 typedef struct { 228 lr_t lr_common; /* common portion of log record */ 229 uint64_t lr_foid; /* object id */ 230 } lr_ooo_t; 231 232 /* 233 * Additional lr_attr_t fields. 234 */ 235 typedef struct { 236 uint64_t lr_attr_attrs; /* all of the attributes */ 237 uint64_t lr_attr_crtime[2]; /* create time */ 238 uint8_t lr_attr_scanstamp[32]; 239 } lr_attr_end_t; 240 241 /* 242 * Handle option extended vattr attributes. 243 * 244 * Whenever new attributes are added the version number 245 * will need to be updated as will code in 246 * zfs_log.c and zfs_replay.c 247 */ 248 typedef struct { 249 uint32_t lr_attr_masksize; /* number of elements in array */ 250 uint32_t lr_attr_bitmap; /* First entry of array */ 251 /* remainder of array and additional lr_attr_end_t fields */ 252 uint8_t lr_attr_data[]; 253 } lr_attr_t; 254 255 /* 256 * log record for creates without optional ACL. 257 * This log record does support optional xvattr_t attributes. 258 */ 259 typedef struct { 260 lr_t lr_common; /* common portion of log record */ 261 uint64_t lr_doid; /* object id of directory */ 262 uint64_t lr_foid; /* object id of created file object */ 263 uint64_t lr_mode; /* mode of object */ 264 uint64_t lr_uid; /* uid of object */ 265 uint64_t lr_gid; /* gid of object */ 266 uint64_t lr_gen; /* generation (txg of creation) */ 267 uint64_t lr_crtime[2]; /* creation time */ 268 uint64_t lr_rdev; /* rdev of object to create */ 269 } _lr_create_t; 270 271 typedef struct { 272 _lr_create_t lr_create; /* common create portion */ 273 /* name of object to create follows this */ 274 /* for symlinks, link content follows name */ 275 /* for creates with xvattr data, the name follows the xvattr info */ 276 uint8_t lr_data[]; 277 } lr_create_t; 278 279 /* 280 * FUID ACL record will be an array of ACEs from the original ACL. 281 * If this array includes ephemeral IDs, the record will also include 282 * an array of log-specific FUIDs to replace the ephemeral IDs. 283 * Only one copy of each unique domain will be present, so the log-specific 284 * FUIDs will use an index into a compressed domain table. On replay this 285 * information will be used to construct real FUIDs (and bypass idmap, 286 * since it may not be available). 287 */ 288 289 /* 290 * Log record for creates with optional ACL 291 * This log record is also used for recording any FUID 292 * information needed for replaying the create. If the 293 * file doesn't have any actual ACEs then the lr_aclcnt 294 * would be zero. 295 * 296 * After lr_acl_flags, there are a lr_acl_bytes number of variable sized ace's. 297 * If create is also setting xvattr's, then acl data follows xvattr. 298 * If ACE FUIDs are needed then they will follow the xvattr_t. Following 299 * the FUIDs will be the domain table information. The FUIDs for the owner 300 * and group will be in lr_create. Name follows ACL data. 301 */ 302 typedef struct { 303 _lr_create_t lr_create; /* common create portion */ 304 uint64_t lr_aclcnt; /* number of ACEs in ACL */ 305 uint64_t lr_domcnt; /* number of unique domains */ 306 uint64_t lr_fuidcnt; /* number of real fuids */ 307 uint64_t lr_acl_bytes; /* number of bytes in ACL */ 308 uint64_t lr_acl_flags; /* ACL flags */ 309 uint8_t lr_data[]; 310 } lr_acl_create_t; 311 312 typedef struct { 313 lr_t lr_common; /* common portion of log record */ 314 uint64_t lr_doid; /* obj id of directory */ 315 /* name of object to remove follows this */ 316 uint8_t lr_data[]; 317 } lr_remove_t; 318 319 typedef struct { 320 lr_t lr_common; /* common portion of log record */ 321 uint64_t lr_doid; /* obj id of directory */ 322 uint64_t lr_link_obj; /* obj id of link */ 323 /* name of object to link follows this */ 324 uint8_t lr_data[]; 325 } lr_link_t; 326 327 typedef struct { 328 lr_t lr_common; /* common portion of log record */ 329 uint64_t lr_sdoid; /* obj id of source directory */ 330 uint64_t lr_tdoid; /* obj id of target directory */ 331 } _lr_rename_t; 332 333 typedef struct { 334 _lr_rename_t lr_rename; /* common rename portion */ 335 /* 2 strings: names of source and destination follow this */ 336 uint8_t lr_data[]; 337 } lr_rename_t; 338 339 typedef struct { 340 _lr_rename_t lr_rename; /* common rename portion */ 341 /* members related to the whiteout file (based on _lr_create_t) */ 342 uint64_t lr_wfoid; /* obj id of the new whiteout file */ 343 uint64_t lr_wmode; /* mode of object */ 344 uint64_t lr_wuid; /* uid of whiteout */ 345 uint64_t lr_wgid; /* gid of whiteout */ 346 uint64_t lr_wgen; /* generation (txg of creation) */ 347 uint64_t lr_wcrtime[2]; /* creation time */ 348 uint64_t lr_wrdev; /* always makedev(0, 0) */ 349 /* 2 strings: names of source and destination follow this */ 350 uint8_t lr_data[]; 351 } lr_rename_whiteout_t; 352 353 typedef struct { 354 lr_t lr_common; /* common portion of log record */ 355 uint64_t lr_foid; /* file object to write */ 356 uint64_t lr_offset; /* offset to write to */ 357 uint64_t lr_length; /* user data length to write */ 358 uint64_t lr_blkoff; /* no longer used */ 359 blkptr_t lr_blkptr; /* spa block pointer for replay */ 360 /* write data will follow for small writes */ 361 uint8_t lr_data[]; 362 } lr_write_t; 363 364 typedef struct { 365 lr_t lr_common; /* common portion of log record */ 366 uint64_t lr_foid; /* object id of file to truncate */ 367 uint64_t lr_offset; /* offset to truncate from */ 368 uint64_t lr_length; /* length to truncate */ 369 } lr_truncate_t; 370 371 typedef struct { 372 lr_t lr_common; /* common portion of log record */ 373 uint64_t lr_foid; /* file object to change attributes */ 374 uint64_t lr_mask; /* mask of attributes to set */ 375 uint64_t lr_mode; /* mode to set */ 376 uint64_t lr_uid; /* uid to set */ 377 uint64_t lr_gid; /* gid to set */ 378 uint64_t lr_size; /* size to set */ 379 uint64_t lr_atime[2]; /* access time */ 380 uint64_t lr_mtime[2]; /* modification time */ 381 /* optional attribute lr_attr_t may be here */ 382 uint8_t lr_data[]; 383 } lr_setattr_t; 384 385 typedef struct { 386 lr_t lr_common; /* common portion of log record */ 387 uint64_t lr_foid; /* file object to change attributes */ 388 uint64_t lr_size; 389 /* xattr name and value follows */ 390 uint8_t lr_data[]; 391 } lr_setsaxattr_t; 392 393 typedef struct { 394 lr_t lr_common; /* common portion of log record */ 395 uint64_t lr_foid; /* obj id of file */ 396 uint64_t lr_aclcnt; /* number of acl entries */ 397 /* lr_aclcnt number of ace_t entries follow this */ 398 uint8_t lr_data[]; 399 } lr_acl_v0_t; 400 401 typedef struct { 402 lr_t lr_common; /* common portion of log record */ 403 uint64_t lr_foid; /* obj id of file */ 404 uint64_t lr_aclcnt; /* number of ACEs in ACL */ 405 uint64_t lr_domcnt; /* number of unique domains */ 406 uint64_t lr_fuidcnt; /* number of real fuids */ 407 uint64_t lr_acl_bytes; /* number of bytes in ACL */ 408 uint64_t lr_acl_flags; /* ACL flags */ 409 /* lr_acl_bytes number of variable sized ace's follows */ 410 uint8_t lr_data[]; 411 } lr_acl_t; 412 413 typedef struct { 414 lr_t lr_common; /* common portion of log record */ 415 uint64_t lr_foid; /* file object to clone into */ 416 uint64_t lr_offset; /* offset to clone to */ 417 uint64_t lr_length; /* length of the blocks to clone */ 418 uint64_t lr_blksz; /* file's block size */ 419 uint64_t lr_nbps; /* number of block pointers */ 420 /* block pointers of the blocks to clone follows */ 421 blkptr_t lr_bps[]; 422 } lr_clone_range_t; 423 424 /* 425 * ZIL structure definitions, interface function prototype and globals. 426 */ 427 428 /* 429 * Writes are handled in three different ways: 430 * 431 * WR_INDIRECT: 432 * In this mode, if we need to commit the write later, then the block 433 * is immediately written into the file system (using dmu_sync), 434 * and a pointer to the block is put into the log record. 435 * When the txg commits the block is linked in. 436 * This saves additionally writing the data into the log record. 437 * There are a few requirements for this to occur: 438 * - write is greater than zfs/zvol_immediate_write_sz 439 * - not using slogs (as slogs are assumed to always be faster 440 * than writing into the main pool) 441 * - the write occupies only one block 442 * WR_COPIED: 443 * If we know we'll immediately be committing the 444 * transaction (O_SYNC or O_DSYNC), then we allocate a larger 445 * log record here for the data and copy the data in. 446 * WR_NEED_COPY: 447 * Otherwise we don't allocate a buffer, and *if* we need to 448 * flush the write later then a buffer is allocated and 449 * we retrieve the data using the dmu. 450 */ 451 typedef enum { 452 WR_INDIRECT, /* indirect - a large write (dmu_sync() data */ 453 /* and put blkptr in log, rather than actual data) */ 454 WR_COPIED, /* immediate - data is copied into lr_write_t */ 455 WR_NEED_COPY, /* immediate - data needs to be copied if pushed */ 456 WR_NUM_STATES /* number of states */ 457 } itx_wr_state_t; 458 459 typedef void (*zil_callback_t)(void *data); 460 461 typedef struct itx { 462 list_node_t itx_node; /* linkage on zl_itx_list */ 463 void *itx_private; /* type-specific opaque data */ 464 itx_wr_state_t itx_wr_state; /* write state */ 465 uint8_t itx_sync; /* synchronous transaction */ 466 zil_callback_t itx_callback; /* Called when the itx is persistent */ 467 void *itx_callback_data; /* User data for the callback */ 468 size_t itx_size; /* allocated itx structure size */ 469 uint64_t itx_oid; /* object id */ 470 uint64_t itx_gen; /* gen number for zfs_get_data */ 471 lr_t itx_lr; /* common part of log record */ 472 uint8_t itx_lr_data[]; /* type-specific part of lr_xx_t */ 473 } itx_t; 474 475 /* 476 * Used for zil kstat. 477 */ 478 typedef struct zil_stats { 479 /* 480 * Number of times a ZIL commit (e.g. fsync) has been requested. 481 */ 482 kstat_named_t zil_commit_count; 483 484 /* 485 * Number of times the ZIL has been flushed to stable storage. 486 * This is less than zil_commit_count when commits are "merged" 487 * (see the documentation above zil_commit()). 488 */ 489 kstat_named_t zil_commit_writer_count; 490 491 /* 492 * Number of times a ZIL commit failed and the ZIL was forced to fall 493 * back to txg_wait_synced(). The separate counts are for different 494 * reasons: 495 * - error: ZIL IO (write/flush) returned an error 496 * (see zil_commit_impl()) 497 * - stall: LWB block allocation failed, ZIL chain abandoned 498 * (see zil_commit_writer_stall()) 499 * - suspend: ZIL suspended 500 * (see zil_commit(), zil_get_commit_list()) 501 */ 502 kstat_named_t zil_commit_error_count; 503 kstat_named_t zil_commit_stall_count; 504 kstat_named_t zil_commit_suspend_count; 505 506 /* 507 * Number of transactions (reads, writes, renames, etc.) 508 * that have been committed. 509 */ 510 kstat_named_t zil_itx_count; 511 512 /* 513 * See the documentation for itx_wr_state_t above. 514 * Note that "bytes" accumulates the length of the transactions 515 * (i.e. data), not the actual log record sizes. 516 */ 517 kstat_named_t zil_itx_indirect_count; 518 kstat_named_t zil_itx_indirect_bytes; 519 kstat_named_t zil_itx_copied_count; 520 kstat_named_t zil_itx_copied_bytes; 521 kstat_named_t zil_itx_needcopy_count; 522 kstat_named_t zil_itx_needcopy_bytes; 523 524 /* 525 * Transactions which have been allocated to the "normal" 526 * (i.e. not slog) storage pool. Note that "bytes" accumulate 527 * the actual log record sizes - which do not include the actual 528 * data in case of indirect writes. bytes <= write <= alloc. 529 */ 530 kstat_named_t zil_itx_metaslab_normal_count; 531 kstat_named_t zil_itx_metaslab_normal_bytes; 532 kstat_named_t zil_itx_metaslab_normal_write; 533 kstat_named_t zil_itx_metaslab_normal_alloc; 534 535 /* 536 * Transactions which have been allocated to the "slog" storage pool. 537 * If there are no separate log devices, this is the same as the 538 * "normal" pool. bytes <= write <= alloc. 539 */ 540 kstat_named_t zil_itx_metaslab_slog_count; 541 kstat_named_t zil_itx_metaslab_slog_bytes; 542 kstat_named_t zil_itx_metaslab_slog_write; 543 kstat_named_t zil_itx_metaslab_slog_alloc; 544 } zil_kstat_values_t; 545 546 typedef struct zil_sums { 547 wmsum_t zil_commit_count; 548 wmsum_t zil_commit_writer_count; 549 wmsum_t zil_commit_error_count; 550 wmsum_t zil_commit_stall_count; 551 wmsum_t zil_commit_suspend_count; 552 wmsum_t zil_itx_count; 553 wmsum_t zil_itx_indirect_count; 554 wmsum_t zil_itx_indirect_bytes; 555 wmsum_t zil_itx_copied_count; 556 wmsum_t zil_itx_copied_bytes; 557 wmsum_t zil_itx_needcopy_count; 558 wmsum_t zil_itx_needcopy_bytes; 559 wmsum_t zil_itx_metaslab_normal_count; 560 wmsum_t zil_itx_metaslab_normal_bytes; 561 wmsum_t zil_itx_metaslab_normal_write; 562 wmsum_t zil_itx_metaslab_normal_alloc; 563 wmsum_t zil_itx_metaslab_slog_count; 564 wmsum_t zil_itx_metaslab_slog_bytes; 565 wmsum_t zil_itx_metaslab_slog_write; 566 wmsum_t zil_itx_metaslab_slog_alloc; 567 } zil_sums_t; 568 569 #define ZIL_STAT_INCR(zil, stat, val) \ 570 do { \ 571 int64_t tmpval = (val); \ 572 wmsum_add(&(zil_sums_global.stat), tmpval); \ 573 if ((zil)->zl_sums) \ 574 wmsum_add(&((zil)->zl_sums->stat), tmpval); \ 575 } while (0) 576 577 #define ZIL_STAT_BUMP(zil, stat) \ 578 ZIL_STAT_INCR(zil, stat, 1); 579 580 typedef int zil_parse_blk_func_t(zilog_t *zilog, const blkptr_t *bp, void *arg, 581 uint64_t txg); 582 typedef int zil_parse_lr_func_t(zilog_t *zilog, const lr_t *lr, void *arg, 583 uint64_t txg); 584 typedef int zil_replay_func_t(void *arg1, void *arg2, boolean_t byteswap); 585 typedef int zil_get_data_t(void *arg, uint64_t arg2, lr_write_t *lr, char *dbuf, 586 struct lwb *lwb, zio_t *zio); 587 588 extern int zil_parse(zilog_t *zilog, zil_parse_blk_func_t *parse_blk_func, 589 zil_parse_lr_func_t *parse_lr_func, void *arg, uint64_t txg, 590 boolean_t decrypt); 591 592 extern void zil_init(void); 593 extern void zil_fini(void); 594 595 extern zilog_t *zil_alloc(objset_t *os, zil_header_t *zh_phys); 596 extern void zil_free(zilog_t *zilog); 597 598 extern zilog_t *zil_open(objset_t *os, zil_get_data_t *get_data, 599 zil_sums_t *zil_sums); 600 extern void zil_close(zilog_t *zilog); 601 602 extern boolean_t zil_replay(objset_t *os, void *arg, 603 zil_replay_func_t *const replay_func[TX_MAX_TYPE]); 604 extern boolean_t zil_replaying(zilog_t *zilog, dmu_tx_t *tx); 605 extern boolean_t zil_destroy(zilog_t *zilog, boolean_t keep_first); 606 extern void zil_destroy_sync(zilog_t *zilog, dmu_tx_t *tx); 607 608 extern itx_t *zil_itx_create(uint64_t txtype, size_t lrsize); 609 extern void zil_itx_destroy(itx_t *itx); 610 extern void zil_itx_assign(zilog_t *zilog, itx_t *itx, dmu_tx_t *tx); 611 612 extern void zil_async_to_sync(zilog_t *zilog, uint64_t oid); 613 extern void zil_commit(zilog_t *zilog, uint64_t oid); 614 extern void zil_commit_impl(zilog_t *zilog, uint64_t oid); 615 extern void zil_remove_async(zilog_t *zilog, uint64_t oid); 616 617 extern int zil_reset(const char *osname, void *txarg); 618 extern int zil_claim(struct dsl_pool *dp, 619 struct dsl_dataset *ds, void *txarg); 620 extern int zil_check_log_chain(struct dsl_pool *dp, 621 struct dsl_dataset *ds, void *tx); 622 extern void zil_sync(zilog_t *zilog, dmu_tx_t *tx); 623 extern void zil_clean(zilog_t *zilog, uint64_t synced_txg); 624 625 extern int zil_suspend(const char *osname, void **cookiep); 626 extern void zil_resume(void *cookie); 627 628 extern void zil_lwb_add_block(struct lwb *lwb, const blkptr_t *bp); 629 extern void zil_lwb_add_txg(struct lwb *lwb, uint64_t txg); 630 extern int zil_bp_tree_add(zilog_t *zilog, const blkptr_t *bp); 631 632 extern void zil_set_sync(zilog_t *zilog, uint64_t syncval); 633 634 extern void zil_set_logbias(zilog_t *zilog, uint64_t slogval); 635 636 extern uint64_t zil_max_copied_data(zilog_t *zilog); 637 extern uint64_t zil_max_log_data(zilog_t *zilog, size_t hdrsize); 638 639 extern void zil_sums_init(zil_sums_t *zs); 640 extern void zil_sums_fini(zil_sums_t *zs); 641 extern void zil_kstat_values_update(zil_kstat_values_t *zs, 642 zil_sums_t *zil_sums); 643 644 extern int zil_replay_disable; 645 646 #ifdef __cplusplus 647 } 648 #endif 649 650 #endif /* _SYS_ZIL_H */ 651