]>
Commit | Line | Data |
---|---|---|
34dc7c2f BB |
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 | /* | |
428870ff | 22 | * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
64fc7762 | 23 | * Copyright (c) 2012, 2017 by Delphix. All rights reserved. |
0c66c32d | 24 | * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. |
34dc7c2f BB |
25 | */ |
26 | ||
27 | #ifndef _SYS_DNODE_H | |
28 | #define _SYS_DNODE_H | |
29 | ||
34dc7c2f BB |
30 | #include <sys/zfs_context.h> |
31 | #include <sys/avl.h> | |
32 | #include <sys/spa.h> | |
33 | #include <sys/txg.h> | |
34 | #include <sys/zio.h> | |
35 | #include <sys/refcount.h> | |
36 | #include <sys/dmu_zfetch.h> | |
572e2857 | 37 | #include <sys/zrlock.h> |
64fc7762 | 38 | #include <sys/multilist.h> |
34dc7c2f BB |
39 | |
40 | #ifdef __cplusplus | |
41 | extern "C" { | |
42 | #endif | |
43 | ||
44 | /* | |
b128c09f | 45 | * dnode_hold() flags. |
34dc7c2f BB |
46 | */ |
47 | #define DNODE_MUST_BE_ALLOCATED 1 | |
48 | #define DNODE_MUST_BE_FREE 2 | |
49 | ||
b128c09f BB |
50 | /* |
51 | * dnode_next_offset() flags. | |
52 | */ | |
53 | #define DNODE_FIND_HOLE 1 | |
54 | #define DNODE_FIND_BACKWARDS 2 | |
55 | #define DNODE_FIND_HAVELOCK 4 | |
56 | ||
34dc7c2f BB |
57 | /* |
58 | * Fixed constants. | |
59 | */ | |
60 | #define DNODE_SHIFT 9 /* 512 bytes */ | |
d25b4497 | 61 | #define DN_MIN_INDBLKSHIFT 12 /* 4k */ |
32d41fb7 PD |
62 | /* |
63 | * If we ever increase this value beyond 20, we need to revisit all logic that | |
64 | * does x << level * ebps to handle overflow. With a 1M indirect block size, | |
65 | * 4 levels of indirect blocks would not be able to guarantee addressing an | |
66 | * entire object, so 5 levels will be used, but 5 * (20 - 7) = 65. | |
67 | */ | |
d7958b4c | 68 | #define DN_MAX_INDBLKSHIFT 17 /* 128k */ |
34dc7c2f BB |
69 | #define DNODE_BLOCK_SHIFT 14 /* 16k */ |
70 | #define DNODE_CORE_SIZE 64 /* 64 bytes for dnode sans blkptrs */ | |
71 | #define DN_MAX_OBJECT_SHIFT 48 /* 256 trillion (zfs_fid_t limit) */ | |
72 | #define DN_MAX_OFFSET_SHIFT 64 /* 2^64 bytes in a dnode */ | |
73 | ||
428870ff BB |
74 | /* |
75 | * dnode id flags | |
76 | * | |
b5256303 | 77 | * Note: a file will never ever have its ids moved from bonus->spill |
428870ff BB |
78 | */ |
79 | #define DN_ID_CHKED_BONUS 0x1 | |
80 | #define DN_ID_CHKED_SPILL 0x2 | |
81 | #define DN_ID_OLD_EXIST 0x4 | |
82 | #define DN_ID_NEW_EXIST 0x8 | |
83 | ||
34dc7c2f BB |
84 | /* |
85 | * Derived constants. | |
86 | */ | |
50c957f7 NB |
87 | #define DNODE_MIN_SIZE (1 << DNODE_SHIFT) |
88 | #define DNODE_MAX_SIZE (1 << DNODE_BLOCK_SHIFT) | |
89 | #define DNODE_BLOCK_SIZE (1 << DNODE_BLOCK_SHIFT) | |
90 | #define DNODE_MIN_SLOTS (DNODE_MIN_SIZE >> DNODE_SHIFT) | |
91 | #define DNODE_MAX_SLOTS (DNODE_MAX_SIZE >> DNODE_SHIFT) | |
92 | #define DN_BONUS_SIZE(dnsize) ((dnsize) - DNODE_CORE_SIZE - \ | |
93 | (1 << SPA_BLKPTRSHIFT)) | |
94 | #define DN_SLOTS_TO_BONUSLEN(slots) DN_BONUS_SIZE((slots) << DNODE_SHIFT) | |
95 | #define DN_OLD_MAX_BONUSLEN (DN_BONUS_SIZE(DNODE_MIN_SIZE)) | |
96 | #define DN_MAX_NBLKPTR ((DNODE_MIN_SIZE - DNODE_CORE_SIZE) >> SPA_BLKPTRSHIFT) | |
34dc7c2f | 97 | #define DN_MAX_OBJECT (1ULL << DN_MAX_OBJECT_SHIFT) |
50c957f7 | 98 | #define DN_ZERO_BONUSLEN (DN_BONUS_SIZE(DNODE_MAX_SIZE) + 1) |
428870ff | 99 | #define DN_KILL_SPILLBLK (1) |
34dc7c2f BB |
100 | |
101 | #define DNODES_PER_BLOCK_SHIFT (DNODE_BLOCK_SHIFT - DNODE_SHIFT) | |
102 | #define DNODES_PER_BLOCK (1ULL << DNODES_PER_BLOCK_SHIFT) | |
d7958b4c MA |
103 | |
104 | /* | |
105 | * This is inaccurate if the indblkshift of the particular object is not the | |
106 | * max. But it's only used by userland to calculate the zvol reservation. | |
107 | */ | |
34dc7c2f | 108 | #define DNODES_PER_LEVEL_SHIFT (DN_MAX_INDBLKSHIFT - SPA_BLKPTRSHIFT) |
428870ff | 109 | #define DNODES_PER_LEVEL (1ULL << DNODES_PER_LEVEL_SHIFT) |
34dc7c2f | 110 | |
031d7c2f GN |
111 | #define DN_MAX_LEVELS (DIV_ROUND_UP(DN_MAX_OFFSET_SHIFT - SPA_MINBLOCKSHIFT, \ |
112 | DN_MIN_INDBLKSHIFT - SPA_BLKPTRSHIFT) + 1) | |
34dc7c2f BB |
113 | |
114 | #define DN_BONUS(dnp) ((void*)((dnp)->dn_bonus + \ | |
115 | (((dnp)->dn_nblkptr - 1) * sizeof (blkptr_t)))) | |
b5256303 TC |
116 | #define DN_MAX_BONUS_LEN(dnp) \ |
117 | ((dnp->dn_flags & DNODE_FLAG_SPILL_BLKPTR) ? \ | |
118 | (uint8_t *)DN_SPILL_BLKPTR(dnp) - (uint8_t *)DN_BONUS(dnp) : \ | |
119 | (uint8_t *)(dnp + (dnp->dn_extra_slots + 1)) - (uint8_t *)DN_BONUS(dnp)) | |
34dc7c2f BB |
120 | |
121 | #define DN_USED_BYTES(dnp) (((dnp)->dn_flags & DNODE_FLAG_USED_BYTES) ? \ | |
122 | (dnp)->dn_used : (dnp)->dn_used << SPA_MINBLOCKSHIFT) | |
123 | ||
124 | #define EPB(blkshift, typeshift) (1 << (blkshift - typeshift)) | |
125 | ||
126 | struct dmu_buf_impl; | |
428870ff | 127 | struct objset; |
34dc7c2f BB |
128 | struct zio; |
129 | ||
130 | enum dnode_dirtycontext { | |
131 | DN_UNDIRTIED, | |
132 | DN_DIRTY_OPEN, | |
133 | DN_DIRTY_SYNC | |
134 | }; | |
135 | ||
136 | /* Is dn_used in bytes? if not, it's in multiples of SPA_MINBLOCKSIZE */ | |
1de321e6 JX |
137 | #define DNODE_FLAG_USED_BYTES (1 << 0) |
138 | #define DNODE_FLAG_USERUSED_ACCOUNTED (1 << 1) | |
34dc7c2f | 139 | |
428870ff | 140 | /* Does dnode have a SA spill blkptr in bonus? */ |
1de321e6 JX |
141 | #define DNODE_FLAG_SPILL_BLKPTR (1 << 2) |
142 | ||
143 | /* User/Group dnode accounting */ | |
144 | #define DNODE_FLAG_USEROBJUSED_ACCOUNTED (1 << 3) | |
428870ff | 145 | |
b5256303 TC |
146 | #define DNODE_CRYPT_PORTABLE_FLAGS_MASK (DNODE_FLAG_SPILL_BLKPTR) |
147 | ||
1e0457e7 MA |
148 | /* |
149 | * VARIABLE-LENGTH (LARGE) DNODES | |
150 | * | |
151 | * The motivation for variable-length dnodes is to eliminate the overhead | |
152 | * associated with using spill blocks. Spill blocks are used to store | |
153 | * system attribute data (i.e. file metadata) that does not fit in the | |
154 | * dnode's bonus buffer. By allowing a larger bonus buffer area the use of | |
155 | * a spill block can be avoided. Spill blocks potentially incur an | |
156 | * additional read I/O for every dnode in a dnode block. As a worst case | |
157 | * example, reading 32 dnodes from a 16k dnode block and all of the spill | |
158 | * blocks could issue 33 separate reads. Now suppose those dnodes have size | |
159 | * 1024 and therefore don't need spill blocks. Then the worst case number | |
160 | * of blocks read is reduced to from 33 to two--one per dnode block. | |
161 | * | |
162 | * ZFS-on-Linux systems that make heavy use of extended attributes benefit | |
163 | * from this feature. In particular, ZFS-on-Linux supports the xattr=sa | |
164 | * dataset property which allows file extended attribute data to be stored | |
165 | * in the dnode bonus buffer as an alternative to the traditional | |
166 | * directory-based format. Workloads such as SELinux and the Lustre | |
167 | * distributed filesystem often store enough xattr data to force spill | |
168 | * blocks when xattr=sa is in effect. Large dnodes may therefore provide a | |
169 | * performance benefit to such systems. Other use cases that benefit from | |
170 | * this feature include files with large ACLs and symbolic links with long | |
171 | * target names. | |
172 | * | |
173 | * The size of a dnode may be a multiple of 512 bytes up to the size of a | |
174 | * dnode block (currently 16384 bytes). The dn_extra_slots field of the | |
175 | * on-disk dnode_phys_t structure describes the size of the physical dnode | |
176 | * on disk. The field represents how many "extra" dnode_phys_t slots a | |
177 | * dnode consumes in its dnode block. This convention results in a value of | |
178 | * 0 for 512 byte dnodes which preserves on-disk format compatibility with | |
179 | * older software which doesn't support large dnodes. | |
180 | * | |
181 | * Similarly, the in-memory dnode_t structure has a dn_num_slots field | |
182 | * to represent the total number of dnode_phys_t slots consumed on disk. | |
183 | * Thus dn->dn_num_slots is 1 greater than the corresponding | |
184 | * dnp->dn_extra_slots. This difference in convention was adopted | |
185 | * because, unlike on-disk structures, backward compatibility is not a | |
186 | * concern for in-memory objects, so we used a more natural way to | |
187 | * represent size for a dnode_t. | |
188 | * | |
189 | * The default size for newly created dnodes is determined by the value of | |
190 | * the "dnodesize" dataset property. By default the property is set to | |
191 | * "legacy" which is compatible with older software. Setting the property | |
192 | * to "auto" will allow the filesystem to choose the most suitable dnode | |
193 | * size. Currently this just sets the default dnode size to 1k, but future | |
194 | * code improvements could dynamically choose a size based on observed | |
195 | * workload patterns. Dnodes of varying sizes can coexist within the same | |
196 | * dataset and even within the same dnode block. | |
197 | */ | |
198 | ||
34dc7c2f BB |
199 | typedef struct dnode_phys { |
200 | uint8_t dn_type; /* dmu_object_type_t */ | |
201 | uint8_t dn_indblkshift; /* ln2(indirect block size) */ | |
202 | uint8_t dn_nlevels; /* 1=dn_blkptr->data blocks */ | |
203 | uint8_t dn_nblkptr; /* length of dn_blkptr */ | |
204 | uint8_t dn_bonustype; /* type of data in bonus buffer */ | |
205 | uint8_t dn_checksum; /* ZIO_CHECKSUM type */ | |
206 | uint8_t dn_compress; /* ZIO_COMPRESS type */ | |
207 | uint8_t dn_flags; /* DNODE_FLAG_* */ | |
208 | uint16_t dn_datablkszsec; /* data block size in 512b sectors */ | |
209 | uint16_t dn_bonuslen; /* length of dn_bonus */ | |
50c957f7 NB |
210 | uint8_t dn_extra_slots; /* # of subsequent slots consumed */ |
211 | uint8_t dn_pad2[3]; | |
34dc7c2f BB |
212 | |
213 | /* accounting is protected by dn_dirty_mtx */ | |
214 | uint64_t dn_maxblkid; /* largest allocated block ID */ | |
215 | uint64_t dn_used; /* bytes (or sectors) of disk space */ | |
216 | ||
217 | uint64_t dn_pad3[4]; | |
218 | ||
aca19e06 | 219 | /* |
50c957f7 NB |
220 | * The tail region is 448 bytes for a 512 byte dnode, and |
221 | * correspondingly larger for larger dnode sizes. The spill | |
222 | * block pointer, when present, is always at the end of the tail | |
223 | * region. There are three ways this space may be used, using | |
224 | * a 512 byte dnode for this diagram: | |
aca19e06 JE |
225 | * |
226 | * 0 64 128 192 256 320 384 448 (offset) | |
227 | * +---------------+---------------+---------------+-------+ | |
228 | * | dn_blkptr[0] | dn_blkptr[1] | dn_blkptr[2] | / | | |
229 | * +---------------+---------------+---------------+-------+ | |
230 | * | dn_blkptr[0] | dn_bonus[0..319] | | |
231 | * +---------------+-----------------------+---------------+ | |
50c957f7 | 232 | * | dn_blkptr[0] | dn_bonus[0..191] | dn_spill | |
aca19e06 JE |
233 | * +---------------+-----------------------+---------------+ |
234 | */ | |
235 | union { | |
50c957f7 | 236 | blkptr_t dn_blkptr[1+DN_OLD_MAX_BONUSLEN/sizeof (blkptr_t)]; |
aca19e06 JE |
237 | struct { |
238 | blkptr_t __dn_ignore1; | |
50c957f7 | 239 | uint8_t dn_bonus[DN_OLD_MAX_BONUSLEN]; |
aca19e06 JE |
240 | }; |
241 | struct { | |
242 | blkptr_t __dn_ignore2; | |
50c957f7 NB |
243 | uint8_t __dn_ignore3[DN_OLD_MAX_BONUSLEN - |
244 | sizeof (blkptr_t)]; | |
aca19e06 JE |
245 | blkptr_t dn_spill; |
246 | }; | |
247 | }; | |
34dc7c2f BB |
248 | } dnode_phys_t; |
249 | ||
50c957f7 NB |
250 | #define DN_SPILL_BLKPTR(dnp) (blkptr_t *)((char *)(dnp) + \ |
251 | (((dnp)->dn_extra_slots + 1) << DNODE_SHIFT) - (1 << SPA_BLKPTRSHIFT)) | |
252 | ||
2bce8049 | 253 | struct dnode { |
34dc7c2f | 254 | /* |
d3cc8b15 WA |
255 | * Protects the structure of the dnode, including the number of levels |
256 | * of indirection (dn_nlevels), dn_maxblkid, and dn_next_* | |
34dc7c2f BB |
257 | */ |
258 | krwlock_t dn_struct_rwlock; | |
259 | ||
9babb374 | 260 | /* Our link on dn_objset->os_dnodes list; protected by os_lock. */ |
34dc7c2f BB |
261 | list_node_t dn_link; |
262 | ||
263 | /* immutable: */ | |
428870ff | 264 | struct objset *dn_objset; |
34dc7c2f BB |
265 | uint64_t dn_object; |
266 | struct dmu_buf_impl *dn_dbuf; | |
572e2857 | 267 | struct dnode_handle *dn_handle; |
34dc7c2f BB |
268 | dnode_phys_t *dn_phys; /* pointer into dn->dn_dbuf->db.db_data */ |
269 | ||
270 | /* | |
271 | * Copies of stuff in dn_phys. They're valid in the open | |
272 | * context (eg. even before the dnode is first synced). | |
273 | * Where necessary, these are protected by dn_struct_rwlock. | |
274 | */ | |
275 | dmu_object_type_t dn_type; /* object type */ | |
276 | uint16_t dn_bonuslen; /* bonus length */ | |
277 | uint8_t dn_bonustype; /* bonus type */ | |
278 | uint8_t dn_nblkptr; /* number of blkptrs (immutable) */ | |
279 | uint8_t dn_checksum; /* ZIO_CHECKSUM type */ | |
280 | uint8_t dn_compress; /* ZIO_COMPRESS type */ | |
281 | uint8_t dn_nlevels; | |
282 | uint8_t dn_indblkshift; | |
283 | uint8_t dn_datablkshift; /* zero if blksz not power of 2! */ | |
572e2857 | 284 | uint8_t dn_moved; /* Has this dnode been moved? */ |
34dc7c2f BB |
285 | uint16_t dn_datablkszsec; /* in 512b sectors */ |
286 | uint32_t dn_datablksz; /* in bytes */ | |
287 | uint64_t dn_maxblkid; | |
fa86b5db | 288 | uint8_t dn_next_type[TXG_SIZE]; |
50c957f7 | 289 | uint8_t dn_num_slots; /* metadnode slots consumed on disk */ |
d164b209 | 290 | uint8_t dn_next_nblkptr[TXG_SIZE]; |
34dc7c2f BB |
291 | uint8_t dn_next_nlevels[TXG_SIZE]; |
292 | uint8_t dn_next_indblkshift[TXG_SIZE]; | |
428870ff BB |
293 | uint8_t dn_next_bonustype[TXG_SIZE]; |
294 | uint8_t dn_rm_spillblk[TXG_SIZE]; /* for removing spill blk */ | |
34dc7c2f BB |
295 | uint16_t dn_next_bonuslen[TXG_SIZE]; |
296 | uint32_t dn_next_blksz[TXG_SIZE]; /* next block size in bytes */ | |
297 | ||
572e2857 BB |
298 | /* protected by dn_dbufs_mtx; declared here to fill 32-bit hole */ |
299 | uint32_t dn_dbufs_count; /* count of dn_dbufs */ | |
300 | ||
34dc7c2f | 301 | /* protected by os_lock: */ |
64fc7762 | 302 | multilist_node_t dn_dirty_link[TXG_SIZE]; /* next on dataset's dirty */ |
34dc7c2f BB |
303 | |
304 | /* protected by dn_mtx: */ | |
305 | kmutex_t dn_mtx; | |
306 | list_t dn_dirty_records[TXG_SIZE]; | |
9bd274dd | 307 | struct range_tree *dn_free_ranges[TXG_SIZE]; |
34dc7c2f BB |
308 | uint64_t dn_allocated_txg; |
309 | uint64_t dn_free_txg; | |
310 | uint64_t dn_assigned_txg; | |
311 | kcondvar_t dn_notxholds; | |
312 | enum dnode_dirtycontext dn_dirtyctx; | |
313 | uint8_t *dn_dirtyctx_firstset; /* dbg: contents meaningless */ | |
314 | ||
315 | /* protected by own devices */ | |
316 | refcount_t dn_tx_holds; | |
317 | refcount_t dn_holds; | |
318 | ||
319 | kmutex_t dn_dbufs_mtx; | |
9925c28c AR |
320 | /* |
321 | * Descendent dbufs, ordered by dbuf_compare. Note that dn_dbufs | |
322 | * can contain multiple dbufs of the same (level, blkid) when a | |
323 | * dbuf is marked DB_EVICTING without being removed from | |
324 | * dn_dbufs. To maintain the avl invariant that there cannot be | |
325 | * duplicate entries, we order the dbufs by an arbitrary value - | |
326 | * their address in memory. This means that dn_dbufs cannot be used to | |
327 | * directly look up a dbuf. Instead, callers must use avl_walk, have | |
4e33ba4c | 328 | * a reference to the dbuf, or look up a non-existent node with |
9925c28c AR |
329 | * db_state = DB_SEARCH (see dbuf_free_range for an example). |
330 | */ | |
331 | avl_tree_t dn_dbufs; | |
572e2857 BB |
332 | |
333 | /* protected by dn_struct_rwlock */ | |
34dc7c2f | 334 | struct dmu_buf_impl *dn_bonus; /* bonus buffer dbuf */ |
572e2857 | 335 | |
428870ff | 336 | boolean_t dn_have_spill; /* have spill or are spilling */ |
34dc7c2f BB |
337 | |
338 | /* parent IO for current sync write */ | |
339 | zio_t *dn_zio; | |
340 | ||
9babb374 | 341 | /* used in syncing context */ |
428870ff BB |
342 | uint64_t dn_oldused; /* old phys used bytes */ |
343 | uint64_t dn_oldflags; /* old phys dn_flags */ | |
344 | uint64_t dn_olduid, dn_oldgid; | |
345 | uint64_t dn_newuid, dn_newgid; | |
346 | int dn_id_flags; | |
9babb374 | 347 | |
34dc7c2f BB |
348 | /* holds prefetch structure */ |
349 | struct zfetch dn_zfetch; | |
2bce8049 | 350 | }; |
34dc7c2f | 351 | |
572e2857 BB |
352 | /* |
353 | * Adds a level of indirection between the dbuf and the dnode to avoid | |
354 | * iterating descendent dbufs in dnode_move(). Handles are not allocated | |
355 | * individually, but as an array of child dnodes in dnode_hold_impl(). | |
356 | */ | |
357 | typedef struct dnode_handle { | |
358 | /* Protects dnh_dnode from modification by dnode_move(). */ | |
359 | zrlock_t dnh_zrlock; | |
360 | dnode_t *dnh_dnode; | |
361 | } dnode_handle_t; | |
362 | ||
363 | typedef struct dnode_children { | |
0c66c32d | 364 | dmu_buf_user_t dnc_dbu; /* User evict data */ |
572e2857 | 365 | size_t dnc_count; /* number of children */ |
5aea3644 | 366 | dnode_handle_t dnc_children[]; /* sized dynamically */ |
572e2857 BB |
367 | } dnode_children_t; |
368 | ||
34dc7c2f BB |
369 | typedef struct free_range { |
370 | avl_node_t fr_node; | |
371 | uint64_t fr_blkid; | |
372 | uint64_t fr_nblks; | |
373 | } free_range_t; | |
374 | ||
0c66c32d | 375 | void dnode_special_open(struct objset *dd, dnode_phys_t *dnp, |
572e2857 BB |
376 | uint64_t object, dnode_handle_t *dnh); |
377 | void dnode_special_close(dnode_handle_t *dnh); | |
34dc7c2f BB |
378 | |
379 | void dnode_setbonuslen(dnode_t *dn, int newsize, dmu_tx_t *tx); | |
428870ff BB |
380 | void dnode_setbonus_type(dnode_t *dn, dmu_object_type_t, dmu_tx_t *tx); |
381 | void dnode_rm_spill(dnode_t *dn, dmu_tx_t *tx); | |
382 | ||
383 | int dnode_hold(struct objset *dd, uint64_t object, | |
34dc7c2f | 384 | void *ref, dnode_t **dnp); |
50c957f7 | 385 | int dnode_hold_impl(struct objset *dd, uint64_t object, int flag, int dn_slots, |
34dc7c2f BB |
386 | void *ref, dnode_t **dnp); |
387 | boolean_t dnode_add_ref(dnode_t *dn, void *ref); | |
388 | void dnode_rele(dnode_t *dn, void *ref); | |
4c7b7eed | 389 | void dnode_rele_and_unlock(dnode_t *dn, void *tag); |
34dc7c2f BB |
390 | void dnode_setdirty(dnode_t *dn, dmu_tx_t *tx); |
391 | void dnode_sync(dnode_t *dn, dmu_tx_t *tx); | |
392 | void dnode_allocate(dnode_t *dn, dmu_object_type_t ot, int blocksize, int ibs, | |
50c957f7 | 393 | dmu_object_type_t bonustype, int bonuslen, int dn_slots, dmu_tx_t *tx); |
34dc7c2f | 394 | void dnode_reallocate(dnode_t *dn, dmu_object_type_t ot, int blocksize, |
50c957f7 | 395 | dmu_object_type_t bonustype, int bonuslen, int dn_slots, dmu_tx_t *tx); |
34dc7c2f BB |
396 | void dnode_free(dnode_t *dn, dmu_tx_t *tx); |
397 | void dnode_byteswap(dnode_phys_t *dnp); | |
398 | void dnode_buf_byteswap(void *buf, size_t size); | |
399 | void dnode_verify(dnode_t *dn); | |
b5256303 | 400 | int dnode_set_nlevels(dnode_t *dn, int nlevels, dmu_tx_t *tx); |
34dc7c2f | 401 | int dnode_set_blksz(dnode_t *dn, uint64_t size, int ibs, dmu_tx_t *tx); |
34dc7c2f | 402 | void dnode_free_range(dnode_t *dn, uint64_t off, uint64_t len, dmu_tx_t *tx); |
34dc7c2f | 403 | void dnode_diduse_space(dnode_t *dn, int64_t space); |
b128c09f | 404 | void dnode_new_blkid(dnode_t *dn, uint64_t blkid, dmu_tx_t *tx, boolean_t); |
34dc7c2f BB |
405 | uint64_t dnode_block_freed(dnode_t *dn, uint64_t blkid); |
406 | void dnode_init(void); | |
407 | void dnode_fini(void); | |
b128c09f BB |
408 | int dnode_next_offset(dnode_t *dn, int flags, uint64_t *off, |
409 | int minlvl, uint64_t blkfill, uint64_t txg); | |
34dc7c2f | 410 | void dnode_evict_dbufs(dnode_t *dn); |
4c7b7eed | 411 | void dnode_evict_bonus(dnode_t *dn); |
34dc7c2f | 412 | |
755065f3 AM |
413 | #define DNODE_IS_CACHEABLE(_dn) \ |
414 | ((_dn)->dn_objset->os_primary_cache == ZFS_CACHE_ALL || \ | |
415 | (DMU_OT_IS_METADATA((_dn)->dn_type) && \ | |
416 | (_dn)->dn_objset->os_primary_cache == ZFS_CACHE_METADATA)) | |
417 | ||
418 | #define DNODE_META_IS_CACHEABLE(_dn) \ | |
419 | ((_dn)->dn_objset->os_primary_cache == ZFS_CACHE_ALL || \ | |
420 | (_dn)->dn_objset->os_primary_cache == ZFS_CACHE_METADATA) | |
421 | ||
34dc7c2f BB |
422 | #ifdef ZFS_DEBUG |
423 | ||
424 | /* | |
425 | * There should be a ## between the string literal and fmt, to make it | |
426 | * clear that we're joining two strings together, but that piece of shit | |
427 | * gcc doesn't support that preprocessor token. | |
428 | */ | |
429 | #define dprintf_dnode(dn, fmt, ...) do { \ | |
430 | if (zfs_flags & ZFS_DEBUG_DPRINTF) { \ | |
431 | char __db_buf[32]; \ | |
432 | uint64_t __db_obj = (dn)->dn_object; \ | |
433 | if (__db_obj == DMU_META_DNODE_OBJECT) \ | |
434 | (void) strcpy(__db_buf, "mdn"); \ | |
435 | else \ | |
436 | (void) snprintf(__db_buf, sizeof (__db_buf), "%lld", \ | |
437 | (u_longlong_t)__db_obj);\ | |
438 | dprintf_ds((dn)->dn_objset->os_dsl_dataset, "obj=%s " fmt, \ | |
439 | __db_buf, __VA_ARGS__); \ | |
440 | } \ | |
441 | _NOTE(CONSTCOND) } while (0) | |
442 | ||
443 | #define DNODE_VERIFY(dn) dnode_verify(dn) | |
444 | #define FREE_VERIFY(db, start, end, tx) free_verify(db, start, end, tx) | |
445 | ||
446 | #else | |
447 | ||
448 | #define dprintf_dnode(db, fmt, ...) | |
449 | #define DNODE_VERIFY(dn) | |
450 | #define FREE_VERIFY(db, start, end, tx) | |
451 | ||
452 | #endif | |
453 | ||
454 | #ifdef __cplusplus | |
455 | } | |
456 | #endif | |
457 | ||
458 | #endif /* _SYS_DNODE_H */ |