1fa9e4066Sahrens /* 2fa9e4066Sahrens * CDDL HEADER START 3fa9e4066Sahrens * 4fa9e4066Sahrens * The contents of this file are subject to the terms of the 5d80c45e0Sbonwick * Common Development and Distribution License (the "License"). 6d80c45e0Sbonwick * 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 */ 21fa9e4066Sahrens /* 22*1209a471SNeil Perrin * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23fa9e4066Sahrens * Use is subject to license terms. 24fa9e4066Sahrens */ 25fa9e4066Sahrens 26fa9e4066Sahrens #ifndef _SYS_ZIL_IMPL_H 27fa9e4066Sahrens #define _SYS_ZIL_IMPL_H 28fa9e4066Sahrens 29fa9e4066Sahrens #include <sys/zil.h> 30fa9e4066Sahrens #include <sys/dmu_objset.h> 31fa9e4066Sahrens 32fa9e4066Sahrens #ifdef __cplusplus 33fa9e4066Sahrens extern "C" { 34fa9e4066Sahrens #endif 35fa9e4066Sahrens 36fa9e4066Sahrens /* 37fa9e4066Sahrens * Log write buffer. 38fa9e4066Sahrens */ 39fa9e4066Sahrens typedef struct lwb { 40fa9e4066Sahrens zilog_t *lwb_zilog; /* back pointer to log struct */ 41fa9e4066Sahrens blkptr_t lwb_blk; /* on disk address of this log blk */ 42fa9e4066Sahrens int lwb_nused; /* # used bytes in buffer */ 43fa9e4066Sahrens int lwb_sz; /* size of block and buffer */ 44fa9e4066Sahrens char *lwb_buf; /* log write buffer */ 45c5c6ffa0Smaybee zio_t *lwb_zio; /* zio for this buffer */ 46fa9e4066Sahrens uint64_t lwb_max_txg; /* highest txg in this lwb */ 47fa9e4066Sahrens txg_handle_t lwb_txgh; /* txg handle for txg_exit() */ 48fa9e4066Sahrens list_node_t lwb_node; /* zilog->zl_lwb_list linkage */ 49fa9e4066Sahrens } lwb_t; 50fa9e4066Sahrens 51fa9e4066Sahrens /* 5217f17c2dSbonwick * Vdev flushing: during a zil_commit(), we build up an AVL tree of the vdevs 5317f17c2dSbonwick * we've touched so we know which ones need a write cache flush at the end. 54fa9e4066Sahrens */ 5517f17c2dSbonwick typedef struct zil_vdev_node { 5617f17c2dSbonwick uint64_t zv_vdev; /* vdev to be flushed */ 5717f17c2dSbonwick avl_node_t zv_node; /* AVL tree linkage */ 5817f17c2dSbonwick } zil_vdev_node_t; 59fa9e4066Sahrens 60fa9e4066Sahrens /* 61fa9e4066Sahrens * Stable storage intent log management structure. One per dataset. 62fa9e4066Sahrens */ 63fa9e4066Sahrens struct zilog { 64fa9e4066Sahrens kmutex_t zl_lock; /* protects most zilog_t fields */ 65fa9e4066Sahrens struct dsl_pool *zl_dmu_pool; /* DSL pool */ 66fa9e4066Sahrens spa_t *zl_spa; /* handle for read/write log */ 67d80c45e0Sbonwick const zil_header_t *zl_header; /* log header buffer */ 68fa9e4066Sahrens objset_t *zl_os; /* object set we're logging */ 69fa9e4066Sahrens zil_get_data_t *zl_get_data; /* callback to get object content */ 70b19a79ecSperrin zio_t *zl_root_zio; /* log writer root zio */ 7167bd71c6Sperrin uint64_t zl_itx_seq; /* next itx sequence number */ 7267bd71c6Sperrin uint64_t zl_commit_seq; /* committed upto this number */ 73b19a79ecSperrin uint64_t zl_lr_seq; /* log record sequence number */ 74fa9e4066Sahrens uint64_t zl_destroy_txg; /* txg of last zil_destroy() */ 75*1209a471SNeil Perrin uint64_t zl_replayed_seq[TXG_SIZE]; /* last replayed rec seq */ 76*1209a471SNeil Perrin uint64_t zl_replaying_seq; /* current replay seq number */ 77fa9e4066Sahrens uint32_t zl_suspend; /* log suspend count */ 78b19a79ecSperrin kcondvar_t zl_cv_writer; /* log writer thread completion */ 79d80c45e0Sbonwick kcondvar_t zl_cv_suspend; /* log suspend completion */ 80d80c45e0Sbonwick uint8_t zl_suspending; /* log is currently suspending */ 81d80c45e0Sbonwick uint8_t zl_keep_first; /* keep first log block in destroy */ 82*1209a471SNeil Perrin uint8_t zl_replay; /* replaying records while set */ 83fa9e4066Sahrens uint8_t zl_stop_sync; /* for debugging */ 84fa9e4066Sahrens uint8_t zl_writer; /* boolean: write setup in progress */ 85fa9e4066Sahrens uint8_t zl_log_error; /* boolean: log write error */ 86fa9e4066Sahrens list_t zl_itx_list; /* in-memory itx list */ 87fa9e4066Sahrens uint64_t zl_itx_list_sz; /* total size of records on list */ 8822ac5be4Sperrin uint64_t zl_cur_used; /* current commit log size used */ 8922ac5be4Sperrin uint64_t zl_prev_used; /* previous commit log size used */ 90fa9e4066Sahrens list_t zl_lwb_list; /* in-flight log write list */ 9117f17c2dSbonwick kmutex_t zl_vdev_lock; /* protects zl_vdev_tree */ 9217f17c2dSbonwick avl_tree_t zl_vdev_tree; /* vdevs to flush in zil_commit() */ 93fa9e4066Sahrens taskq_t *zl_clean_taskq; /* runs lwb and itx clean tasks */ 94fa9e4066Sahrens avl_tree_t zl_dva_tree; /* track DVAs during log parse */ 9567bd71c6Sperrin clock_t zl_replay_time; /* lbolt of when replay started */ 9667bd71c6Sperrin uint64_t zl_replay_blks; /* number of log blocks replayed */ 97fa9e4066Sahrens }; 98fa9e4066Sahrens 99fa9e4066Sahrens typedef struct zil_dva_node { 100fa9e4066Sahrens dva_t zn_dva; 101fa9e4066Sahrens avl_node_t zn_node; 102fa9e4066Sahrens } zil_dva_node_t; 103fa9e4066Sahrens 104fa9e4066Sahrens #ifdef __cplusplus 105fa9e4066Sahrens } 106fa9e4066Sahrens #endif 107fa9e4066Sahrens 108fa9e4066Sahrens #endif /* _SYS_ZIL_IMPL_H */ 109