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