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.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or https://opensource.org/licenses/CDDL-1.0.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
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]
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 * Copyright (c) 2012, Joyent, Inc. All rights reserved.
27 * Copyright (c) 2013, 2018 by Delphix. All rights reserved.
30 #ifndef _SYS_DMU_IMPL_H
31 #define _SYS_DMU_IMPL_H
33 #include <sys/txg_impl.h>
35 #include <sys/dnode.h>
36 #include <sys/zfs_context.h>
37 #include <sys/zfs_ioctl.h>
44 * This is the locking strategy for the DMU. Numbers in parenthesis are
45 * cases that use that lock order, referenced below:
47 * ARC is self-contained
48 * bplist is self-contained
49 * refcount is self-contained
50 * txg is self-contained (hopefully!)
54 * XXX try to improve evicting path?
56 * dp_config_rwlock > os_obj_lock > dn_struct_rwlock >
57 * dn_dbufs_mtx > hash_mutexes > db_mtx > dd_lock > leafs
60 * must be held before: everything
61 * protects dd namespace changes
62 * protects property changes globally
65 * dsl_dir_create_sync/w:
66 * dsl_dir_sync_destroy/w:
67 * dsl_dir_rename_sync/w:
68 * dsl_prop_changed_notify/r:
71 * must be held before:
72 * everything except dp_config_rwlock
73 * protects os_obj_next
75 * dmu_object_alloc: dn_dbufs_mtx, db_mtx, hash_mutexes, dn_struct_rwlock
78 * must be held before:
79 * everything except dp_config_rwlock and os_obj_lock
80 * protects structure of dnode (eg. nlevels)
81 * db_blkptr can change when syncing out change to nlevels
85 * phys nlevels, maxblkid, physical blkptr_t's (?)
87 * callers of dbuf_read_impl, dbuf_hold[_impl], dbuf_prefetch
88 * dmu_object_info_from_dnode: dn_dirty_mtx (dn_datablksz)
89 * dbuf_read_impl: db_mtx, dmu_zfetch()
90 * dmu_zfetch: zf_rwlock/r, zst_lock, dbuf_prefetch()
91 * dbuf_new_size: db_mtx
93 * dbuf_findbp: (callers, phys? - the real need)
94 * dbuf_create: dn_dbufs_mtx, hash_mutexes, db_mtx (phys?)
95 * dbuf_prefetch: dn_dirty_mtx, hash_mutexes, db_mtx, dn_dbufs_mtx
96 * dbuf_hold_impl: hash_mutexes, db_mtx, dn_dbufs_mtx, dbuf_findbp()
97 * dnode_sync/w (increase_indirection): db_mtx (phys)
98 * dnode_set_blksz/w: dn_dbufs_mtx (dn_*blksz*)
99 * dnode_new_blkid/w: (dn_maxblkid)
100 * dnode_free_range/w: dn_dirty_mtx (dn_maxblkid)
101 * dnode_next_offset: (phys)
104 * must be held before:
105 * db_mtx, hash_mutexes
110 * dmu_evict_user: db_mtx (dn_dbufs)
111 * dbuf_free_range: db_mtx (dn_dbufs)
112 * dbuf_remove_ref: db_mtx, callees:
113 * dbuf_hash_remove: hash_mutexes, db_mtx
114 * dbuf_create: hash_mutexes, db_mtx (dn_dbufs)
115 * dnode_set_blksz: (dn_dbufs)
117 * hash_mutexes (global)
118 * must be held before:
120 * protects dbuf_hash_table (global) and db_hash_next
123 * dbuf_hash_insert: db_mtx
124 * dbuf_hash_remove: db_mtx
127 * must be held before:
128 * dn_mtx, dn_dirty_mtx, dd_lock (leaf mutexes)
142 * dbuf_dirty: dn_mtx, dn_dirty_mtx
143 * dbuf_dirty->dsl_dir_willuse_space: dd_lock
144 * dbuf_dirty->dbuf_new_block->dsl_dataset_block_freeable: dd_lock
145 * dbuf_undirty: dn_dirty_mtx (db_d)
146 * dbuf_write_done: dn_dirty_mtx (db_state)
148 * dmu_buf_update_user: none (db_d)
149 * dmu_evict_user: none (db_d) (maybe can eliminate)
150 * dbuf_find: none (db_holds)
151 * dbuf_hash_insert: none (db_holds)
152 * dmu_buf_read_array_impl: none (db_state, db_changed)
153 * dmu_sync: none (db_dirty_node, db_d)
154 * dnode_reallocate: none (db)
169 * dn_dirtyctx_firstset
170 * (dn_phys copy fields?)
171 * (dn_phys contents?)
175 * dbuf_sync: none (phys accounting)
176 * dbuf_undirty: none (dn_ranges, dn_dirty_dbufs)
177 * dbuf_write_done: none (phys accounting)
178 * dmu_object_info_from_dnode: none (accounting)
179 * dmu_tx_commit: none
180 * dmu_tx_hold_object_impl: none
181 * dmu_tx_try_assign: dn_notxholds(cv)
182 * dmu_tx_unassign: none
185 * must be held before:
195 * dd_phys accounting?
198 * dsl_prop_changed_notify: none (dd_prop_cbs)
199 * dsl_prop_register: none (dd_prop_cbs)
200 * dsl_prop_unregister: none (dd_prop_cbs)
207 * os_downgraded_dbufs
211 * dnode_create: none (os_dnodes)
212 * dnode_destroy: none (os_dnodes)
213 * dnode_setdirty: none (dn_dirtyblksz, os_*_dnodes)
214 * dnode_free: none (dn_dirtyblksz, os_*_dnodes)
222 * ds_phys userrefs zapobj
240 typedef struct dmu_sendstatus
{
241 list_node_t dss_link
;
245 uint64_t dss_blocks
; /* blocks visited during the sending process */
248 void dmu_object_zapify(objset_t
*, uint64_t, dmu_object_type_t
, dmu_tx_t
*);
249 void dmu_object_free_zapified(objset_t
*, uint64_t, dmu_tx_t
*);
255 #endif /* _SYS_DMU_IMPL_H */