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>
48 * This is the locking strategy for the DMU. Numbers in parenthesis are
49 * cases that use that lock order, referenced below:
51 * ARC is self-contained
52 * bplist is self-contained
53 * refcount is self-contained
54 * txg is self-contained (hopefully!)
58 * XXX try to improve evicting path?
60 * dp_config_rwlock > os_obj_lock > dn_struct_rwlock >
61 * dn_dbufs_mtx > hash_mutexes > db_mtx > dd_lock > leafs
64 * must be held before: everything
65 * protects dd namespace changes
66 * protects property changes globally
69 * dsl_dir_create_sync/w:
70 * dsl_dir_sync_destroy/w:
71 * dsl_dir_rename_sync/w:
72 * dsl_prop_changed_notify/r:
75 * must be held before:
76 * everything except dp_config_rwlock
77 * protects os_obj_next
79 * dmu_object_alloc: dn_dbufs_mtx, db_mtx, hash_mutexes, dn_struct_rwlock
82 * must be held before:
83 * everything except dp_config_rwlock and os_obj_lock
84 * protects structure of dnode (eg. nlevels)
85 * db_blkptr can change when syncing out change to nlevels
89 * phys nlevels, maxblkid, physical blkptr_t's (?)
91 * callers of dbuf_read_impl, dbuf_hold[_impl], dbuf_prefetch
92 * dmu_object_info_from_dnode: dn_dirty_mtx (dn_datablksz)
93 * dbuf_read_impl: db_mtx, dmu_zfetch()
94 * dmu_zfetch: zf_rwlock/r, zst_lock, dbuf_prefetch()
95 * dbuf_new_size: db_mtx
97 * dbuf_findbp: (callers, phys? - the real need)
98 * dbuf_create: dn_dbufs_mtx, hash_mutexes, db_mtx (phys?)
99 * dbuf_prefetch: dn_dirty_mtx, hash_mutexes, db_mtx, dn_dbufs_mtx
100 * dbuf_hold_impl: hash_mutexes, db_mtx, dn_dbufs_mtx, dbuf_findbp()
101 * dnode_sync/w (increase_indirection): db_mtx (phys)
102 * dnode_set_blksz/w: dn_dbufs_mtx (dn_*blksz*)
103 * dnode_new_blkid/w: (dn_maxblkid)
104 * dnode_free_range/w: dn_dirty_mtx (dn_maxblkid)
105 * dnode_next_offset: (phys)
108 * must be held before:
109 * db_mtx, hash_mutexes
114 * dmu_evict_user: db_mtx (dn_dbufs)
115 * dbuf_free_range: db_mtx (dn_dbufs)
116 * dbuf_remove_ref: db_mtx, callees:
117 * dbuf_hash_remove: hash_mutexes, db_mtx
118 * dbuf_create: hash_mutexes, db_mtx (dn_dbufs)
119 * dnode_set_blksz: (dn_dbufs)
121 * hash_mutexes (global)
122 * must be held before:
124 * protects dbuf_hash_table (global) and db_hash_next
127 * dbuf_hash_insert: db_mtx
128 * dbuf_hash_remove: db_mtx
131 * must be held before:
132 * dn_mtx, dn_dirty_mtx, dd_lock (leaf mutexes)
146 * dbuf_dirty: dn_mtx, dn_dirty_mtx
147 * dbuf_dirty->dsl_dir_willuse_space: dd_lock
148 * dbuf_dirty->dbuf_new_block->dsl_dataset_block_freeable: dd_lock
149 * dbuf_undirty: dn_dirty_mtx (db_d)
150 * dbuf_write_done: dn_dirty_mtx (db_state)
152 * dmu_buf_update_user: none (db_d)
153 * dmu_evict_user: none (db_d) (maybe can eliminate)
154 * dbuf_find: none (db_holds)
155 * dbuf_hash_insert: none (db_holds)
156 * dmu_buf_read_array_impl: none (db_state, db_changed)
157 * dmu_sync: none (db_dirty_records, db_d)
158 * dnode_reallocate: none (db)
159 * dmu_write_direct: none (db_dirty_records, db_d)
160 * dmu_write_direct_done: none (db_dirty_records, db_d)
175 * dn_dirtyctx_firstset
176 * (dn_phys copy fields?)
177 * (dn_phys contents?)
181 * dbuf_sync: none (phys accounting)
182 * dbuf_undirty: none (dn_ranges, dn_dirty_dbufs)
183 * dbuf_write_done: none (phys accounting)
184 * dmu_object_info_from_dnode: none (accounting)
185 * dmu_tx_commit: none
186 * dmu_tx_hold_object_impl: none
187 * dmu_tx_try_assign: dn_notxholds(cv)
188 * dmu_tx_unassign: none
191 * must be held before:
201 * dd_phys accounting?
204 * dsl_prop_changed_notify: none (dd_prop_cbs)
205 * dsl_prop_register: none (dd_prop_cbs)
206 * dsl_prop_unregister: none (dd_prop_cbs)
213 * os_downgraded_dbufs
217 * dnode_create: none (os_dnodes)
218 * dnode_destroy: none (os_dnodes)
219 * dnode_setdirty: none (dn_dirtyblksz, os_*_dnodes)
220 * dnode_free: none (dn_dirtyblksz, os_*_dnodes)
228 * ds_phys userrefs zapobj
247 typedef struct dmu_sendstatus
{
248 list_node_t dss_link
;
252 uint64_t dss_blocks
; /* blocks visited during the sending process */
256 * dmu_sync_{ready/done} args
259 dbuf_dirty_record_t
*dsa_dr
;
260 void (*dsa_done
)(struct zgd
*, int);
265 void dmu_sync_done(zio_t
*, arc_buf_t
*buf
, void *varg
);
266 void dmu_sync_ready(zio_t
*, arc_buf_t
*buf
, void *varg
);
268 void dmu_object_zapify(objset_t
*, uint64_t, dmu_object_type_t
, dmu_tx_t
*);
269 void dmu_object_free_zapified(objset_t
*, uint64_t, dmu_tx_t
*);
271 int dmu_write_direct(zio_t
*, dmu_buf_impl_t
*, abd_t
*, dmu_tx_t
*);
272 int dmu_read_abd(dnode_t
*, uint64_t, uint64_t, abd_t
*, uint32_t flags
);
273 int dmu_write_abd(dnode_t
*, uint64_t, uint64_t, abd_t
*, uint32_t, dmu_tx_t
*);
275 int dmu_read_uio_direct(dnode_t
*, zfs_uio_t
*, uint64_t);
276 int dmu_write_uio_direct(dnode_t
*, zfs_uio_t
*, uint64_t, dmu_tx_t
*);
283 #endif /* _SYS_DMU_IMPL_H */