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, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _SYS_DMU_IMPL_H 28 #define _SYS_DMU_IMPL_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #include <sys/txg_impl.h> 33 #include <sys/zio.h> 34 #include <sys/dnode.h> 35 #include <sys/zfs_context.h> 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 /* 42 * This is the locking strategy for the DMU. Numbers in parenthesis are 43 * cases that use that lock order, referenced below: 44 * 45 * ARC is self-contained 46 * bplist is self-contained 47 * refcount is self-contained 48 * txg is self-contained (hopefully!) 49 * zst_lock 50 * zf_rwlock 51 * 52 * XXX try to improve evicting path? 53 * 54 * dp_config_rwlock > os_obj_lock > dn_struct_rwlock > 55 * dn_dbufs_mtx > hash_mutexes > db_mtx > leafs 56 * 57 * dp_config_rwlock 58 * must be held before: everything 59 * protects dd namespace changes 60 * protects property changes globally 61 * held from: 62 * dsl_dir_open/r: 63 * dsl_dir_create_sync/w: 64 * dsl_dir_sync_destroy/w: 65 * dsl_dir_rename_sync/w: 66 * dsl_prop_changed_notify/r: 67 * 68 * os_obj_lock 69 * must be held before: 70 * everything except dp_config_rwlock 71 * protects os_obj_next 72 * held from: 73 * dmu_object_alloc: dn_dbufs_mtx, db_mtx, hash_mutexes, dn_struct_rwlock 74 * 75 * dn_struct_rwlock 76 * must be held before: 77 * everything except dp_config_rwlock and os_obj_lock 78 * protects structure of dnode (eg. nlevels) 79 * db_blkptr can change when syncing out change to nlevels 80 * dn_maxblkid 81 * dn_nlevels 82 * dn_*blksz* 83 * phys nlevels, maxblkid, physical blkptr_t's (?) 84 * held from: 85 * callers of dbuf_read_impl, dbuf_hold[_impl], dbuf_prefetch 86 * dmu_object_info_from_dnode: dn_dirty_mtx (dn_datablksz) 87 * dmu_tx_count_free: 88 * dbuf_read_impl: db_mtx, dmu_zfetch() 89 * dmu_zfetch: zf_rwlock/r, zst_lock, dbuf_prefetch() 90 * dbuf_new_size: db_mtx 91 * dbuf_dirty: db_mtx 92 * dbuf_findbp: (callers, phys? - the real need) 93 * dbuf_create: dn_dbufs_mtx, hash_mutexes, db_mtx (phys?) 94 * dbuf_prefetch: dn_dirty_mtx, hash_mutexes, db_mtx, dn_dbufs_mtx 95 * dbuf_hold_impl: hash_mutexes, db_mtx, dn_dbufs_mtx, dbuf_findbp() 96 * dnode_sync/w (increase_indirection): db_mtx (phys) 97 * dnode_set_blksz/w: dn_dbufs_mtx (dn_*blksz*) 98 * dnode_new_blkid/w: (dn_maxblkid) 99 * dnode_free_range/w: dn_dirty_mtx (dn_maxblkid) 100 * dnode_next_offset: (phys) 101 * 102 * dn_dbufs_mtx 103 * must be held before: 104 * db_mtx, hash_mutexes 105 * protects: 106 * dn_dbufs 107 * dn_evicted 108 * held from: 109 * dmu_evict_user: db_mtx (dn_dbufs) 110 * dbuf_free_range: db_mtx (dn_dbufs) 111 * dbuf_remove_ref: db_mtx, callees: 112 * dbuf_hash_remove: hash_mutexes, db_mtx 113 * dbuf_create: hash_mutexes, db_mtx (dn_dbufs) 114 * dnode_set_blksz: (dn_dbufs) 115 * 116 * hash_mutexes (global) 117 * must be held before: 118 * db_mtx 119 * protects dbuf_hash_table (global) and db_hash_next 120 * held from: 121 * dbuf_find: db_mtx 122 * dbuf_hash_insert: db_mtx 123 * dbuf_hash_remove: db_mtx 124 * 125 * db_mtx (meta-leaf) 126 * must be held before: 127 * dn_mtx, dn_dirty_mtx, dd_lock (leaf mutexes) 128 * protects: 129 * db_state 130 * db_holds 131 * db_buf 132 * db_changed 133 * db_data_pending 134 * db_dirtied 135 * db_link 136 * db_dirty_node (??) 137 * db_dirtycnt 138 * db_d.* 139 * db.* 140 * held from: 141 * dbuf_dirty: dn_mtx, dn_dirty_mtx 142 * dbuf_dirty->dsl_dir_willuse_space: dd_lock 143 * dbuf_dirty->dbuf_new_block->dsl_dataset_block_freeable: dd_lock 144 * dbuf_undirty: dn_dirty_mtx (db_d) 145 * dbuf_write_done: dn_dirty_mtx (db_state) 146 * dbuf_* 147 * dmu_buf_update_user: none (db_d) 148 * dmu_evict_user: none (db_d) (maybe can eliminate) 149 * dbuf_find: none (db_holds) 150 * dbuf_hash_insert: none (db_holds) 151 * dmu_buf_read_array_impl: none (db_state, db_changed) 152 * dmu_sync: none (db_dirty_node, db_d) 153 * dnode_reallocate: none (db) 154 * 155 * dn_mtx (leaf) 156 * protects: 157 * dn_dirty_dbufs 158 * dn_ranges 159 * phys accounting 160 * dn_allocated_txg 161 * dn_free_txg 162 * dn_assigned_txg 163 * dd_assigned_tx 164 * dn_notxholds 165 * dn_dirtyctx 166 * dn_dirtyctx_firstset 167 * (dn_phys copy fields?) 168 * (dn_phys contents?) 169 * held from: 170 * dnode_* 171 * dbuf_dirty: none 172 * dbuf_sync: none (phys accounting) 173 * dbuf_undirty: none (dn_ranges, dn_dirty_dbufs) 174 * dbuf_write_done: none (phys accounting) 175 * dmu_object_info_from_dnode: none (accounting) 176 * dmu_tx_commit: none 177 * dmu_tx_hold_object_impl: none 178 * dmu_tx_try_assign: dn_notxholds(cv) 179 * dmu_tx_unassign: none 180 * 181 * dd_lock (leaf) 182 * protects: 183 * dd_prop_cbs 184 * dd_sync_* 185 * dd_used_bytes 186 * dd_tempreserved 187 * dd_space_towrite 188 * dd_myname 189 * dd_phys accounting? 190 * held from: 191 * dsl_dir_* 192 * dsl_prop_changed_notify: none (dd_prop_cbs) 193 * dsl_prop_register: none (dd_prop_cbs) 194 * dsl_prop_unregister: none (dd_prop_cbs) 195 * dsl_dataset_block_freeable: none (dd_sync_*) 196 * 197 * os_lock (leaf) 198 * protects: 199 * os_dirty_dnodes 200 * os_free_dnodes 201 * os_dnodes 202 * os_downgraded_dbufs 203 * dn_dirtyblksz 204 * dn_dirty_link 205 * held from: 206 * dnode_create: none (os_dnodes) 207 * dnode_destroy: none (os_dnodes) 208 * dnode_setdirty: none (dn_dirtyblksz, os_*_dnodes) 209 * dnode_free: none (dn_dirtyblksz, os_*_dnodes) 210 * 211 * ds_lock (leaf) 212 * protects: 213 * ds_user_ptr 214 * ds_user_evice_func 215 * ds_open_refcount 216 * ds_snapname 217 * ds_phys accounting 218 * held from: 219 * dsl_dataset_* 220 * 221 */ 222 223 struct objset; 224 struct dmu_pool; 225 226 #ifdef __cplusplus 227 } 228 #endif 229 230 #endif /* _SYS_DMU_IMPL_H */ 231