Print this page
3752 want more verifiable dbuf user eviction
Submitted by: Justin Gibbs <justing@spectralogic.com>
Submitted by: Will Andrews <willa@spectralogic.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/fs/zfs/sys/dmu_impl.h
+++ new/usr/src/uts/common/fs/zfs/sys/dmu_impl.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 * Copyright (c) 2012, Joyent, Inc. All rights reserved.
↓ open down ↓ |
24 lines elided |
↑ open up ↑ |
25 25 */
26 26
27 27 #ifndef _SYS_DMU_IMPL_H
28 28 #define _SYS_DMU_IMPL_H
29 29
30 30 #include <sys/txg_impl.h>
31 31 #include <sys/zio.h>
32 32 #include <sys/dnode.h>
33 33 #include <sys/zfs_context.h>
34 34 #include <sys/zfs_ioctl.h>
35 +#include <sys/dmu.h>
35 36
36 37 #ifdef __cplusplus
37 38 extern "C" {
38 39 #endif
39 40
40 41 /*
41 42 * This is the locking strategy for the DMU. Numbers in parenthesis are
42 43 * cases that use that lock order, referenced below:
43 44 *
44 45 * ARC is self-contained
45 46 * bplist is self-contained
46 47 * refcount is self-contained
47 48 * txg is self-contained (hopefully!)
48 49 * zst_lock
49 50 * zf_rwlock
50 51 *
51 52 * XXX try to improve evicting path?
52 53 *
53 54 * dp_config_rwlock > os_obj_lock > dn_struct_rwlock >
54 55 * dn_dbufs_mtx > hash_mutexes > db_mtx > dd_lock > leafs
55 56 *
56 57 * dp_config_rwlock
57 58 * must be held before: everything
58 59 * protects dd namespace changes
59 60 * protects property changes globally
60 61 * held from:
61 62 * dsl_dir_open/r:
62 63 * dsl_dir_create_sync/w:
63 64 * dsl_dir_sync_destroy/w:
64 65 * dsl_dir_rename_sync/w:
65 66 * dsl_prop_changed_notify/r:
66 67 *
67 68 * os_obj_lock
68 69 * must be held before:
69 70 * everything except dp_config_rwlock
70 71 * protects os_obj_next
71 72 * held from:
72 73 * dmu_object_alloc: dn_dbufs_mtx, db_mtx, hash_mutexes, dn_struct_rwlock
73 74 *
74 75 * dn_struct_rwlock
75 76 * must be held before:
76 77 * everything except dp_config_rwlock and os_obj_lock
77 78 * protects structure of dnode (eg. nlevels)
78 79 * db_blkptr can change when syncing out change to nlevels
79 80 * dn_maxblkid
80 81 * dn_nlevels
81 82 * dn_*blksz*
82 83 * phys nlevels, maxblkid, physical blkptr_t's (?)
83 84 * held from:
84 85 * callers of dbuf_read_impl, dbuf_hold[_impl], dbuf_prefetch
85 86 * dmu_object_info_from_dnode: dn_dirty_mtx (dn_datablksz)
86 87 * dmu_tx_count_free:
87 88 * dbuf_read_impl: db_mtx, dmu_zfetch()
88 89 * dmu_zfetch: zf_rwlock/r, zst_lock, dbuf_prefetch()
89 90 * dbuf_new_size: db_mtx
90 91 * dbuf_dirty: db_mtx
91 92 * dbuf_findbp: (callers, phys? - the real need)
92 93 * dbuf_create: dn_dbufs_mtx, hash_mutexes, db_mtx (phys?)
93 94 * dbuf_prefetch: dn_dirty_mtx, hash_mutexes, db_mtx, dn_dbufs_mtx
94 95 * dbuf_hold_impl: hash_mutexes, db_mtx, dn_dbufs_mtx, dbuf_findbp()
95 96 * dnode_sync/w (increase_indirection): db_mtx (phys)
96 97 * dnode_set_blksz/w: dn_dbufs_mtx (dn_*blksz*)
97 98 * dnode_new_blkid/w: (dn_maxblkid)
98 99 * dnode_free_range/w: dn_dirty_mtx (dn_maxblkid)
99 100 * dnode_next_offset: (phys)
100 101 *
101 102 * dn_dbufs_mtx
102 103 * must be held before:
103 104 * db_mtx, hash_mutexes
104 105 * protects:
105 106 * dn_dbufs
106 107 * dn_evicted
107 108 * held from:
108 109 * dmu_evict_user: db_mtx (dn_dbufs)
109 110 * dbuf_free_range: db_mtx (dn_dbufs)
110 111 * dbuf_remove_ref: db_mtx, callees:
111 112 * dbuf_hash_remove: hash_mutexes, db_mtx
112 113 * dbuf_create: hash_mutexes, db_mtx (dn_dbufs)
113 114 * dnode_set_blksz: (dn_dbufs)
114 115 *
115 116 * hash_mutexes (global)
116 117 * must be held before:
117 118 * db_mtx
118 119 * protects dbuf_hash_table (global) and db_hash_next
119 120 * held from:
120 121 * dbuf_find: db_mtx
121 122 * dbuf_hash_insert: db_mtx
122 123 * dbuf_hash_remove: db_mtx
123 124 *
124 125 * db_mtx (meta-leaf)
125 126 * must be held before:
126 127 * dn_mtx, dn_dirty_mtx, dd_lock (leaf mutexes)
127 128 * protects:
128 129 * db_state
129 130 * db_holds
130 131 * db_buf
131 132 * db_changed
132 133 * db_data_pending
133 134 * db_dirtied
134 135 * db_link
135 136 * db_dirty_node (??)
136 137 * db_dirtycnt
137 138 * db_d.*
138 139 * db.*
139 140 * held from:
140 141 * dbuf_dirty: dn_mtx, dn_dirty_mtx
141 142 * dbuf_dirty->dsl_dir_willuse_space: dd_lock
142 143 * dbuf_dirty->dbuf_new_block->dsl_dataset_block_freeable: dd_lock
143 144 * dbuf_undirty: dn_dirty_mtx (db_d)
144 145 * dbuf_write_done: dn_dirty_mtx (db_state)
145 146 * dbuf_*
146 147 * dmu_buf_update_user: none (db_d)
147 148 * dmu_evict_user: none (db_d) (maybe can eliminate)
148 149 * dbuf_find: none (db_holds)
149 150 * dbuf_hash_insert: none (db_holds)
150 151 * dmu_buf_read_array_impl: none (db_state, db_changed)
151 152 * dmu_sync: none (db_dirty_node, db_d)
152 153 * dnode_reallocate: none (db)
153 154 *
154 155 * dn_mtx (leaf)
155 156 * protects:
156 157 * dn_dirty_dbufs
157 158 * dn_ranges
158 159 * phys accounting
159 160 * dn_allocated_txg
160 161 * dn_free_txg
161 162 * dn_assigned_txg
162 163 * dd_assigned_tx
163 164 * dn_notxholds
164 165 * dn_dirtyctx
165 166 * dn_dirtyctx_firstset
166 167 * (dn_phys copy fields?)
167 168 * (dn_phys contents?)
168 169 * held from:
169 170 * dnode_*
170 171 * dbuf_dirty: none
171 172 * dbuf_sync: none (phys accounting)
172 173 * dbuf_undirty: none (dn_ranges, dn_dirty_dbufs)
173 174 * dbuf_write_done: none (phys accounting)
174 175 * dmu_object_info_from_dnode: none (accounting)
175 176 * dmu_tx_commit: none
176 177 * dmu_tx_hold_object_impl: none
177 178 * dmu_tx_try_assign: dn_notxholds(cv)
178 179 * dmu_tx_unassign: none
179 180 *
180 181 * dd_lock
181 182 * must be held before:
182 183 * ds_lock
183 184 * ancestors' dd_lock
184 185 * protects:
185 186 * dd_prop_cbs
186 187 * dd_sync_*
187 188 * dd_used_bytes
188 189 * dd_tempreserved
189 190 * dd_space_towrite
190 191 * dd_myname
191 192 * dd_phys accounting?
192 193 * held from:
193 194 * dsl_dir_*
194 195 * dsl_prop_changed_notify: none (dd_prop_cbs)
195 196 * dsl_prop_register: none (dd_prop_cbs)
196 197 * dsl_prop_unregister: none (dd_prop_cbs)
197 198 * dsl_dataset_block_freeable: none (dd_sync_*)
198 199 *
199 200 * os_lock (leaf)
200 201 * protects:
201 202 * os_dirty_dnodes
202 203 * os_free_dnodes
203 204 * os_dnodes
204 205 * os_downgraded_dbufs
205 206 * dn_dirtyblksz
206 207 * dn_dirty_link
207 208 * held from:
208 209 * dnode_create: none (os_dnodes)
209 210 * dnode_destroy: none (os_dnodes)
210 211 * dnode_setdirty: none (dn_dirtyblksz, os_*_dnodes)
211 212 * dnode_free: none (dn_dirtyblksz, os_*_dnodes)
212 213 *
213 214 * ds_lock
214 215 * protects:
215 216 * ds_objset
216 217 * ds_open_refcount
217 218 * ds_snapname
218 219 * ds_phys accounting
219 220 * ds_phys userrefs zapobj
220 221 * ds_reserved
221 222 * held from:
222 223 * dsl_dataset_*
223 224 *
224 225 * dr_mtx (leaf)
225 226 * protects:
226 227 * dr_children
227 228 * held from:
228 229 * dbuf_dirty
229 230 * dbuf_undirty
230 231 * dbuf_sync_indirect
231 232 * dnode_new_blkid
232 233 */
233 234
234 235 struct objset;
235 236 struct dmu_pool;
236 237
237 238 typedef struct dmu_xuio {
238 239 int next;
239 240 int cnt;
240 241 struct arc_buf **bufs;
241 242 iovec_t *iovp;
242 243 } dmu_xuio_t;
243 244
244 245 typedef struct xuio_stats {
245 246 /* loaned yet not returned arc_buf */
246 247 kstat_named_t xuiostat_onloan_rbuf;
247 248 kstat_named_t xuiostat_onloan_wbuf;
248 249 /* whether a copy is made when loaning out a read buffer */
249 250 kstat_named_t xuiostat_rbuf_copied;
250 251 kstat_named_t xuiostat_rbuf_nocopy;
251 252 /* whether a copy is made when assigning a write buffer */
252 253 kstat_named_t xuiostat_wbuf_copied;
253 254 kstat_named_t xuiostat_wbuf_nocopy;
254 255 } xuio_stats_t;
255 256
256 257 static xuio_stats_t xuio_stats = {
257 258 { "onloan_read_buf", KSTAT_DATA_UINT64 },
258 259 { "onloan_write_buf", KSTAT_DATA_UINT64 },
259 260 { "read_buf_copied", KSTAT_DATA_UINT64 },
260 261 { "read_buf_nocopy", KSTAT_DATA_UINT64 },
261 262 { "write_buf_copied", KSTAT_DATA_UINT64 },
262 263 { "write_buf_nocopy", KSTAT_DATA_UINT64 }
263 264 };
264 265
265 266 #define XUIOSTAT_INCR(stat, val) \
266 267 atomic_add_64(&xuio_stats.stat.value.ui64, (val))
267 268 #define XUIOSTAT_BUMP(stat) XUIOSTAT_INCR(stat, 1)
268 269
269 270 /*
270 271 * The list of data whose inclusion in a send stream can be pending from
271 272 * one call to backup_cb to another. Multiple calls to dump_free() and
272 273 * dump_freeobjects() can be aggregated into a single DRR_FREE or
273 274 * DRR_FREEOBJECTS replay record.
274 275 */
275 276 typedef enum {
276 277 PENDING_NONE,
277 278 PENDING_FREE,
278 279 PENDING_FREEOBJECTS
279 280 } dmu_pendop_t;
280 281
281 282 typedef struct dmu_sendarg {
282 283 list_node_t dsa_link;
283 284 dmu_replay_record_t *dsa_drr;
284 285 vnode_t *dsa_vp;
285 286 int dsa_outfd;
286 287 struct proc *dsa_proc;
287 288 offset_t *dsa_off;
288 289 objset_t *dsa_os;
289 290 zio_cksum_t dsa_zc;
290 291 uint64_t dsa_toguid;
291 292 int dsa_err;
292 293 dmu_pendop_t dsa_pending_op;
293 294 } dmu_sendarg_t;
294 295
295 296
296 297 #ifdef __cplusplus
297 298 }
298 299 #endif
299 300
300 301 #endif /* _SYS_DMU_IMPL_H */
↓ open down ↓ |
256 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX