1fa9e4066Sahrens /* 2fa9e4066Sahrens * CDDL HEADER START 3fa9e4066Sahrens * 4fa9e4066Sahrens * The contents of this file are subject to the terms of the 5*d80c45e0Sbonwick * Common Development and Distribution License (the "License"). 6*d80c45e0Sbonwick * 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*d80c45e0Sbonwick * Copyright 2006 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 #pragma ident "%Z%%M% %I% %E% SMI" 30fa9e4066Sahrens 31fa9e4066Sahrens #include <sys/zil.h> 32fa9e4066Sahrens #include <sys/dmu_objset.h> 33fa9e4066Sahrens 34fa9e4066Sahrens #ifdef __cplusplus 35fa9e4066Sahrens extern "C" { 36fa9e4066Sahrens #endif 37fa9e4066Sahrens 38fa9e4066Sahrens typedef enum lwb_state_type { 39fa9e4066Sahrens UNWRITTEN, /* buffer yet to be written */ 40fa9e4066Sahrens SEQ_INCOMPLETE, /* buffer written, but there's an unwritten buffer in */ 41fa9e4066Sahrens /* the sequence before this */ 42fa9e4066Sahrens SEQ_COMPLETE, /* no unwritten buffers before this */ 43fa9e4066Sahrens } lwb_state_t; 44fa9e4066Sahrens 45fa9e4066Sahrens /* 46fa9e4066Sahrens * Log write buffer. 47fa9e4066Sahrens */ 48fa9e4066Sahrens typedef struct lwb { 49fa9e4066Sahrens zilog_t *lwb_zilog; /* back pointer to log struct */ 50fa9e4066Sahrens blkptr_t lwb_blk; /* on disk address of this log blk */ 51fa9e4066Sahrens int lwb_nused; /* # used bytes in buffer */ 52fa9e4066Sahrens int lwb_sz; /* size of block and buffer */ 53fa9e4066Sahrens char *lwb_buf; /* log write buffer */ 54fa9e4066Sahrens uint64_t lwb_max_txg; /* highest txg in this lwb */ 55fa9e4066Sahrens uint64_t lwb_seq; /* highest log record seq number */ 56fa9e4066Sahrens txg_handle_t lwb_txgh; /* txg handle for txg_exit() */ 57fa9e4066Sahrens list_node_t lwb_node; /* zilog->zl_lwb_list linkage */ 58fa9e4066Sahrens lwb_state_t lwb_state; /* buffer state */ 59fa9e4066Sahrens } lwb_t; 60fa9e4066Sahrens 61fa9e4066Sahrens /* 62fa9e4066Sahrens * [vdev, seq] element for use in flushing device write caches 63fa9e4066Sahrens */ 64fa9e4066Sahrens typedef struct zil_vdev { 65fa9e4066Sahrens uint64_t vdev; /* device written */ 66fa9e4066Sahrens uint64_t seq; /* itx sequence */ 67fa9e4066Sahrens list_node_t vdev_seq_node; /* zilog->zl_vdev_list linkage */ 68fa9e4066Sahrens } zil_vdev_t; 69fa9e4066Sahrens 70fa9e4066Sahrens /* 71fa9e4066Sahrens * Stable storage intent log management structure. One per dataset. 72fa9e4066Sahrens */ 73fa9e4066Sahrens struct zilog { 74fa9e4066Sahrens kmutex_t zl_lock; /* protects most zilog_t fields */ 75fa9e4066Sahrens struct dsl_pool *zl_dmu_pool; /* DSL pool */ 76fa9e4066Sahrens spa_t *zl_spa; /* handle for read/write log */ 77*d80c45e0Sbonwick const zil_header_t *zl_header; /* log header buffer */ 78fa9e4066Sahrens objset_t *zl_os; /* object set we're logging */ 79fa9e4066Sahrens zil_get_data_t *zl_get_data; /* callback to get object content */ 80fa9e4066Sahrens uint64_t zl_itx_seq; /* itx sequence number */ 81fa9e4066Sahrens uint64_t zl_ss_seq; /* last tx on stable storage */ 82fa9e4066Sahrens uint64_t zl_destroy_txg; /* txg of last zil_destroy() */ 83fa9e4066Sahrens uint64_t zl_replay_seq[TXG_SIZE]; /* seq of last replayed rec */ 84fa9e4066Sahrens uint32_t zl_suspend; /* log suspend count */ 85fa9e4066Sahrens kcondvar_t zl_cv_write; /* for waiting to write to log */ 86fa9e4066Sahrens kcondvar_t zl_cv_seq; /* for committing a sequence */ 87*d80c45e0Sbonwick kcondvar_t zl_cv_suspend; /* log suspend completion */ 88*d80c45e0Sbonwick uint8_t zl_suspending; /* log is currently suspending */ 89*d80c45e0Sbonwick uint8_t zl_keep_first; /* keep first log block in destroy */ 90fa9e4066Sahrens uint8_t zl_stop_replay; /* don't replay any further */ 91fa9e4066Sahrens uint8_t zl_stop_sync; /* for debugging */ 92fa9e4066Sahrens uint8_t zl_writer; /* boolean: write setup in progress */ 93fa9e4066Sahrens uint8_t zl_log_error; /* boolean: log write error */ 94fa9e4066Sahrens list_t zl_itx_list; /* in-memory itx list */ 95fa9e4066Sahrens uint64_t zl_itx_list_sz; /* total size of records on list */ 9622ac5be4Sperrin uint64_t zl_cur_used; /* current commit log size used */ 9722ac5be4Sperrin uint64_t zl_prev_used; /* previous commit log size used */ 98fa9e4066Sahrens list_t zl_lwb_list; /* in-flight log write list */ 99fa9e4066Sahrens list_t zl_vdev_list; /* list of [vdev, seq] pairs */ 100fa9e4066Sahrens taskq_t *zl_clean_taskq; /* runs lwb and itx clean tasks */ 101fa9e4066Sahrens avl_tree_t zl_dva_tree; /* track DVAs during log parse */ 102fa9e4066Sahrens }; 103fa9e4066Sahrens 104fa9e4066Sahrens typedef struct zil_dva_node { 105fa9e4066Sahrens dva_t zn_dva; 106fa9e4066Sahrens avl_node_t zn_node; 107fa9e4066Sahrens } zil_dva_node_t; 108fa9e4066Sahrens 109fa9e4066Sahrens #ifdef __cplusplus 110fa9e4066Sahrens } 111fa9e4066Sahrens #endif 112fa9e4066Sahrens 113fa9e4066Sahrens #endif /* _SYS_ZIL_IMPL_H */ 114