]>
Commit | Line | Data |
---|---|---|
34dc7c2f BB |
1 | /* |
2 | * CDDL HEADER START | |
3 | * | |
4 | * The contents of this file are subject to the terms of the | |
5 | * Common Development and Distribution License (the "License"). | |
6 | * You may not use this file except in compliance with the License. | |
7 | * | |
8 | * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE | |
9 | * or http://www.opensolaris.org/os/licensing. | |
10 | * See the License for the specific language governing permissions | |
11 | * and limitations under the License. | |
12 | * | |
13 | * When distributing Covered Code, include this CDDL HEADER in each | |
14 | * file and include the License file at usr/src/OPENSOLARIS.LICENSE. | |
15 | * If applicable, add the following below this CDDL HEADER, with the | |
16 | * fields enclosed by brackets "[]" replaced with your own identifying | |
17 | * information: Portions Copyright [yyyy] [name of copyright owner] | |
18 | * | |
19 | * CDDL HEADER END | |
20 | */ | |
21 | /* | |
428870ff | 22 | * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
34dc7c2f BB |
23 | */ |
24 | ||
428870ff BB |
25 | /* Portions Copyright 2010 Robert Milkowski */ |
26 | ||
34dc7c2f BB |
27 | #ifndef _SYS_ZIL_IMPL_H |
28 | #define _SYS_ZIL_IMPL_H | |
29 | ||
34dc7c2f BB |
30 | #include <sys/zil.h> |
31 | #include <sys/dmu_objset.h> | |
32 | ||
33 | #ifdef __cplusplus | |
34 | extern "C" { | |
35 | #endif | |
36 | ||
37 | /* | |
38 | * Log write buffer. | |
39 | */ | |
40 | typedef struct lwb { | |
41 | zilog_t *lwb_zilog; /* back pointer to log struct */ | |
42 | blkptr_t lwb_blk; /* on disk address of this log blk */ | |
43 | int lwb_nused; /* # used bytes in buffer */ | |
44 | int lwb_sz; /* size of block and buffer */ | |
45 | char *lwb_buf; /* log write buffer */ | |
46 | zio_t *lwb_zio; /* zio for this buffer */ | |
428870ff | 47 | dmu_tx_t *lwb_tx; /* tx for log block allocation */ |
34dc7c2f | 48 | uint64_t lwb_max_txg; /* highest txg in this lwb */ |
34dc7c2f BB |
49 | list_node_t lwb_node; /* zilog->zl_lwb_list linkage */ |
50 | } lwb_t; | |
51 | ||
572e2857 BB |
52 | /* |
53 | * Intent log transaction lists | |
54 | */ | |
55 | typedef struct itxs { | |
56 | list_t i_sync_list; /* list of synchronous itxs */ | |
57 | avl_tree_t i_async_tree; /* tree of foids for async itxs */ | |
58 | } itxs_t; | |
59 | ||
60 | typedef struct itxg { | |
61 | kmutex_t itxg_lock; /* lock for this structure */ | |
62 | uint64_t itxg_txg; /* txg for this chain */ | |
63 | uint64_t itxg_sod; /* total size on disk for this txg */ | |
64 | itxs_t *itxg_itxs; /* sync and async itxs */ | |
65 | } itxg_t; | |
66 | ||
67 | /* for async nodes we build up an AVL tree of lists of async itxs per file */ | |
68 | typedef struct itx_async_node { | |
69 | uint64_t ia_foid; /* file object id */ | |
70 | list_t ia_list; /* list of async itxs for this foid */ | |
71 | avl_node_t ia_node; /* AVL tree linkage */ | |
72 | } itx_async_node_t; | |
73 | ||
34dc7c2f BB |
74 | /* |
75 | * Vdev flushing: during a zil_commit(), we build up an AVL tree of the vdevs | |
76 | * we've touched so we know which ones need a write cache flush at the end. | |
77 | */ | |
78 | typedef struct zil_vdev_node { | |
79 | uint64_t zv_vdev; /* vdev to be flushed */ | |
80 | avl_node_t zv_node; /* AVL tree linkage */ | |
81 | } zil_vdev_node_t; | |
82 | ||
428870ff BB |
83 | #define ZIL_PREV_BLKS 16 |
84 | ||
34dc7c2f BB |
85 | /* |
86 | * Stable storage intent log management structure. One per dataset. | |
87 | */ | |
88 | struct zilog { | |
89 | kmutex_t zl_lock; /* protects most zilog_t fields */ | |
90 | struct dsl_pool *zl_dmu_pool; /* DSL pool */ | |
91 | spa_t *zl_spa; /* handle for read/write log */ | |
92 | const zil_header_t *zl_header; /* log header buffer */ | |
93 | objset_t *zl_os; /* object set we're logging */ | |
94 | zil_get_data_t *zl_get_data; /* callback to get object content */ | |
95 | zio_t *zl_root_zio; /* log writer root zio */ | |
428870ff | 96 | uint64_t zl_lr_seq; /* on-disk log record sequence number */ |
428870ff | 97 | uint64_t zl_commit_lr_seq; /* last committed on-disk lr seq */ |
34dc7c2f | 98 | uint64_t zl_destroy_txg; /* txg of last zil_destroy() */ |
fb5f0bc8 BB |
99 | uint64_t zl_replayed_seq[TXG_SIZE]; /* last replayed rec seq */ |
100 | uint64_t zl_replaying_seq; /* current replay seq number */ | |
34dc7c2f BB |
101 | uint32_t zl_suspend; /* log suspend count */ |
102 | kcondvar_t zl_cv_writer; /* log writer thread completion */ | |
103 | kcondvar_t zl_cv_suspend; /* log suspend completion */ | |
104 | uint8_t zl_suspending; /* log is currently suspending */ | |
105 | uint8_t zl_keep_first; /* keep first log block in destroy */ | |
fb5f0bc8 | 106 | uint8_t zl_replay; /* replaying records while set */ |
34dc7c2f BB |
107 | uint8_t zl_stop_sync; /* for debugging */ |
108 | uint8_t zl_writer; /* boolean: write setup in progress */ | |
428870ff BB |
109 | uint8_t zl_logbias; /* latency or throughput */ |
110 | uint8_t zl_sync; /* synchronous or asynchronous */ | |
111 | int zl_parse_error; /* last zil_parse() error */ | |
112 | uint64_t zl_parse_blk_seq; /* highest blk seq on last parse */ | |
113 | uint64_t zl_parse_lr_seq; /* highest lr seq on last parse */ | |
114 | uint64_t zl_parse_blk_count; /* number of blocks parsed */ | |
115 | uint64_t zl_parse_lr_count; /* number of log records parsed */ | |
572e2857 BB |
116 | uint64_t zl_next_batch; /* next batch number */ |
117 | uint64_t zl_com_batch; /* committed batch number */ | |
118 | kcondvar_t zl_cv_batch[2]; /* batch condition variables */ | |
119 | itxg_t zl_itxg[TXG_SIZE]; /* intent log txg chains */ | |
120 | list_t zl_itx_commit_list; /* itx list to be committed */ | |
34dc7c2f BB |
121 | uint64_t zl_itx_list_sz; /* total size of records on list */ |
122 | uint64_t zl_cur_used; /* current commit log size used */ | |
34dc7c2f BB |
123 | list_t zl_lwb_list; /* in-flight log write list */ |
124 | kmutex_t zl_vdev_lock; /* protects zl_vdev_tree */ | |
125 | avl_tree_t zl_vdev_tree; /* vdevs to flush in zil_commit() */ | |
126 | taskq_t *zl_clean_taskq; /* runs lwb and itx clean tasks */ | |
428870ff | 127 | avl_tree_t zl_bp_tree; /* track bps during log parse */ |
34dc7c2f BB |
128 | clock_t zl_replay_time; /* lbolt of when replay started */ |
129 | uint64_t zl_replay_blks; /* number of log blocks replayed */ | |
428870ff BB |
130 | zil_header_t zl_old_header; /* debugging aid */ |
131 | uint_t zl_prev_blks[ZIL_PREV_BLKS]; /* size - sector rounded */ | |
132 | uint_t zl_prev_rotor; /* rotor for zl_prev[] */ | |
34dc7c2f BB |
133 | }; |
134 | ||
428870ff | 135 | typedef struct zil_bp_node { |
34dc7c2f BB |
136 | dva_t zn_dva; |
137 | avl_node_t zn_node; | |
428870ff | 138 | } zil_bp_node_t; |
34dc7c2f | 139 | |
428870ff | 140 | #define ZIL_MAX_LOG_DATA (SPA_MAXBLOCKSIZE - sizeof (zil_chain_t) - \ |
9babb374 BB |
141 | sizeof (lr_write_t)) |
142 | ||
34dc7c2f BB |
143 | #ifdef __cplusplus |
144 | } | |
145 | #endif | |
146 | ||
147 | #endif /* _SYS_ZIL_IMPL_H */ |