Print this page
ZoL PR 9145
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/fs/zfs/sys/dnode.h
+++ new/usr/src/uts/common/fs/zfs/sys/dnode.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 * Copyright (c) 2012, 2018 by Delphix. All rights reserved.
24 24 * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
25 25 */
26 26
27 27 #ifndef _SYS_DNODE_H
28 28 #define _SYS_DNODE_H
29 29
30 30 #include <sys/zfs_context.h>
31 31 #include <sys/avl.h>
32 32 #include <sys/spa.h>
33 33 #include <sys/txg.h>
34 34 #include <sys/zio.h>
35 35 #include <sys/refcount.h>
36 36 #include <sys/dmu_zfetch.h>
37 37 #include <sys/zrlock.h>
38 38 #include <sys/multilist.h>
|
↓ open down ↓ |
38 lines elided |
↑ open up ↑ |
39 39
40 40 #ifdef __cplusplus
41 41 extern "C" {
42 42 #endif
43 43
44 44 /*
45 45 * dnode_hold() flags.
46 46 */
47 47 #define DNODE_MUST_BE_ALLOCATED 1
48 48 #define DNODE_MUST_BE_FREE 2
49 +#define DNODE_DRY_RUN 4
49 50
50 51 /*
51 52 * dnode_next_offset() flags.
52 53 */
53 54 #define DNODE_FIND_HOLE 1
54 55 #define DNODE_FIND_BACKWARDS 2
55 56 #define DNODE_FIND_HAVELOCK 4
56 57
57 58 /*
58 59 * Fixed constants.
59 60 */
60 61 #define DNODE_SHIFT 9 /* 512 bytes */
61 62 #define DN_MIN_INDBLKSHIFT 12 /* 4k */
62 63 /*
63 64 * If we ever increase this value beyond 20, we need to revisit all logic that
64 65 * does x << level * ebps to handle overflow. With a 1M indirect block size,
65 66 * 4 levels of indirect blocks would not be able to guarantee addressing an
66 67 * entire object, so 5 levels will be used, but 5 * (20 - 7) = 65.
67 68 */
68 69 #define DN_MAX_INDBLKSHIFT 17 /* 128k */
69 70 #define DNODE_BLOCK_SHIFT 14 /* 16k */
70 71 #define DNODE_CORE_SIZE 64 /* 64 bytes for dnode sans blkptrs */
71 72 #define DN_MAX_OBJECT_SHIFT 48 /* 256 trillion (zfs_fid_t limit) */
72 73 #define DN_MAX_OFFSET_SHIFT 64 /* 2^64 bytes in a dnode */
73 74
74 75 /*
75 76 * dnode id flags
76 77 *
77 78 * Note: a file will never ever have its ids moved from bonus->spill
78 79 */
79 80 #define DN_ID_CHKED_BONUS 0x1
80 81 #define DN_ID_CHKED_SPILL 0x2
81 82 #define DN_ID_OLD_EXIST 0x4
82 83 #define DN_ID_NEW_EXIST 0x8
83 84
84 85 /*
85 86 * Derived constants.
86 87 */
87 88 #define DNODE_MIN_SIZE (1 << DNODE_SHIFT)
88 89 #define DNODE_MAX_SIZE (1 << DNODE_BLOCK_SHIFT)
89 90 #define DNODE_BLOCK_SIZE (1 << DNODE_BLOCK_SHIFT)
90 91 #define DNODE_MIN_SLOTS (DNODE_MIN_SIZE >> DNODE_SHIFT)
91 92 #define DNODE_MAX_SLOTS (DNODE_MAX_SIZE >> DNODE_SHIFT)
92 93 #define DN_BONUS_SIZE(dnsize) ((dnsize) - DNODE_CORE_SIZE - \
93 94 (1 << SPA_BLKPTRSHIFT))
94 95 #define DN_SLOTS_TO_BONUSLEN(slots) DN_BONUS_SIZE((slots) << DNODE_SHIFT)
95 96 #define DN_OLD_MAX_BONUSLEN (DN_BONUS_SIZE(DNODE_MIN_SIZE))
96 97 #define DN_MAX_NBLKPTR ((DNODE_MIN_SIZE - DNODE_CORE_SIZE) >> SPA_BLKPTRSHIFT)
97 98 #define DN_MAX_OBJECT (1ULL << DN_MAX_OBJECT_SHIFT)
98 99 #define DN_ZERO_BONUSLEN (DN_BONUS_SIZE(DNODE_MAX_SIZE) + 1)
99 100 #define DN_KILL_SPILLBLK (1)
100 101
101 102 #define DN_SLOT_UNINIT ((void *)NULL) /* Uninitialized */
102 103 #define DN_SLOT_FREE ((void *)1UL) /* Free slot */
103 104 #define DN_SLOT_ALLOCATED ((void *)2UL) /* Allocated slot */
104 105 #define DN_SLOT_INTERIOR ((void *)3UL) /* Interior allocated slot */
105 106 #define DN_SLOT_IS_PTR(dn) ((void *)dn > DN_SLOT_INTERIOR)
106 107 #define DN_SLOT_IS_VALID(dn) ((void *)dn != NULL)
107 108
108 109 #define DNODES_PER_BLOCK_SHIFT (DNODE_BLOCK_SHIFT - DNODE_SHIFT)
109 110 #define DNODES_PER_BLOCK (1ULL << DNODES_PER_BLOCK_SHIFT)
110 111
111 112 /*
112 113 * This is inaccurate if the indblkshift of the particular object is not the
113 114 * max. But it's only used by userland to calculate the zvol reservation.
114 115 */
115 116 #define DNODES_PER_LEVEL_SHIFT (DN_MAX_INDBLKSHIFT - SPA_BLKPTRSHIFT)
116 117 #define DNODES_PER_LEVEL (1ULL << DNODES_PER_LEVEL_SHIFT)
117 118
118 119 /* The +2 here is a cheesy way to round up */
119 120 #define DN_MAX_LEVELS (2 + ((DN_MAX_OFFSET_SHIFT - SPA_MINBLOCKSHIFT) / \
120 121 (DN_MIN_INDBLKSHIFT - SPA_BLKPTRSHIFT)))
121 122
122 123 #define DN_BONUS(dnp) ((void*)((dnp)->dn_bonus + \
123 124 (((dnp)->dn_nblkptr - 1) * sizeof (blkptr_t))))
124 125 #define DN_MAX_BONUS_LEN(dnp) \
125 126 ((dnp->dn_flags & DNODE_FLAG_SPILL_BLKPTR) ? \
126 127 (uint8_t *)DN_SPILL_BLKPTR(dnp) - (uint8_t *)DN_BONUS(dnp) : \
127 128 (uint8_t *)(dnp + (dnp->dn_extra_slots + 1)) - (uint8_t *)DN_BONUS(dnp))
128 129
129 130 #define DN_USED_BYTES(dnp) (((dnp)->dn_flags & DNODE_FLAG_USED_BYTES) ? \
130 131 (dnp)->dn_used : (dnp)->dn_used << SPA_MINBLOCKSHIFT)
131 132
132 133 #define EPB(blkshift, typeshift) (1 << (blkshift - typeshift))
133 134
134 135 struct dmu_buf_impl;
135 136 struct objset;
136 137 struct zio;
137 138
138 139 enum dnode_dirtycontext {
139 140 DN_UNDIRTIED,
140 141 DN_DIRTY_OPEN,
141 142 DN_DIRTY_SYNC
142 143 };
143 144
144 145 /* Is dn_used in bytes? if not, it's in multiples of SPA_MINBLOCKSIZE */
145 146 #define DNODE_FLAG_USED_BYTES (1 << 0)
146 147 #define DNODE_FLAG_USERUSED_ACCOUNTED (1 << 1)
147 148
148 149 /* Does dnode have a SA spill blkptr in bonus? */
149 150 #define DNODE_FLAG_SPILL_BLKPTR (1 << 2)
150 151
151 152 /* User/Group/Project dnode accounting */
152 153 #define DNODE_FLAG_USEROBJUSED_ACCOUNTED (1 << 3)
153 154
154 155 /*
155 156 * VARIABLE-LENGTH (LARGE) DNODES
156 157 *
157 158 * The motivation for variable-length dnodes is to eliminate the overhead
158 159 * associated with using spill blocks. Spill blocks are used to store
159 160 * system attribute data (i.e. file metadata) that does not fit in the
160 161 * dnode's bonus buffer. By allowing a larger bonus buffer area the use of
161 162 * a spill block can be avoided. Spill blocks potentially incur an
162 163 * additional read I/O for every dnode in a dnode block. As a worst case
163 164 * example, reading 32 dnodes from a 16k dnode block and all of the spill
164 165 * blocks could issue 33 separate reads. Now suppose those dnodes have size
165 166 * 1024 and therefore don't need spill blocks. Then the worst case number
166 167 * of blocks read is reduced to from 33 to two--one per dnode block.
167 168 *
168 169 * ZFS-on-Linux systems that make heavy use of extended attributes benefit
169 170 * from this feature. In particular, ZFS-on-Linux supports the xattr=sa
170 171 * dataset property which allows file extended attribute data to be stored
171 172 * in the dnode bonus buffer as an alternative to the traditional
172 173 * directory-based format. Workloads such as SELinux and the Lustre
173 174 * distributed filesystem often store enough xattr data to force spill
174 175 * blocks when xattr=sa is in effect. Large dnodes may therefore provide a
175 176 * performance benefit to such systems. Other use cases that benefit from
176 177 * this feature include files with large ACLs and symbolic links with long
177 178 * target names.
178 179 *
179 180 * The size of a dnode may be a multiple of 512 bytes up to the size of a
180 181 * dnode block (currently 16384 bytes). The dn_extra_slots field of the
181 182 * on-disk dnode_phys_t structure describes the size of the physical dnode
182 183 * on disk. The field represents how many "extra" dnode_phys_t slots a
183 184 * dnode consumes in its dnode block. This convention results in a value of
184 185 * 0 for 512 byte dnodes which preserves on-disk format compatibility with
185 186 * older software which doesn't support large dnodes.
186 187 *
187 188 * Similarly, the in-memory dnode_t structure has a dn_num_slots field
188 189 * to represent the total number of dnode_phys_t slots consumed on disk.
189 190 * Thus dn->dn_num_slots is 1 greater than the corresponding
190 191 * dnp->dn_extra_slots. This difference in convention was adopted
191 192 * because, unlike on-disk structures, backward compatibility is not a
192 193 * concern for in-memory objects, so we used a more natural way to
193 194 * represent size for a dnode_t.
194 195 *
195 196 * The default size for newly created dnodes is determined by the value of
196 197 * the "dnodesize" dataset property. By default the property is set to
197 198 * "legacy" which is compatible with older software. Setting the property
198 199 * to "auto" will allow the filesystem to choose the most suitable dnode
199 200 * size. Currently this just sets the default dnode size to 1k, but future
200 201 * code improvements could dynamically choose a size based on observed
201 202 * workload patterns. Dnodes of varying sizes can coexist within the same
202 203 * dataset and even within the same dnode block.
203 204 */
204 205
205 206 #define DNODE_CRYPT_PORTABLE_FLAGS_MASK (DNODE_FLAG_SPILL_BLKPTR)
206 207
207 208 typedef struct dnode_phys {
208 209 uint8_t dn_type; /* dmu_object_type_t */
209 210 uint8_t dn_indblkshift; /* ln2(indirect block size) */
210 211 uint8_t dn_nlevels; /* 1=dn_blkptr->data blocks */
211 212 uint8_t dn_nblkptr; /* length of dn_blkptr */
212 213 uint8_t dn_bonustype; /* type of data in bonus buffer */
213 214 uint8_t dn_checksum; /* ZIO_CHECKSUM type */
214 215 uint8_t dn_compress; /* ZIO_COMPRESS type */
215 216 uint8_t dn_flags; /* DNODE_FLAG_* */
216 217 uint16_t dn_datablkszsec; /* data block size in 512b sectors */
217 218 uint16_t dn_bonuslen; /* length of dn_bonus */
218 219 uint8_t dn_extra_slots; /* # of subsequent slots consumed */
219 220 uint8_t dn_pad2[3];
220 221
221 222 /* accounting is protected by dn_dirty_mtx */
222 223 uint64_t dn_maxblkid; /* largest allocated block ID */
223 224 uint64_t dn_used; /* bytes (or sectors) of disk space */
224 225
225 226 /*
226 227 * Both dn_pad2 and dn_pad3 are protected by the block's MAC. This
227 228 * allows us to protect any fields that might be added here in the
228 229 * future. In either case, developers will want to check
229 230 * zio_crypt_init_uios_dnode() to ensure the new field is being
230 231 * protected properly.
231 232 */
232 233 uint64_t dn_pad3[4];
233 234 union {
234 235 blkptr_t dn_blkptr[1+DN_OLD_MAX_BONUSLEN/sizeof (blkptr_t)];
235 236 struct {
236 237 blkptr_t __dn_ignore1;
237 238 uint8_t dn_bonus[DN_OLD_MAX_BONUSLEN];
238 239 };
239 240 struct {
240 241 blkptr_t __dn_ignore2;
241 242 uint8_t __dn_ignore3[DN_OLD_MAX_BONUSLEN -
242 243 sizeof (blkptr_t)];
243 244 blkptr_t dn_spill;
244 245 };
245 246 };
246 247 } dnode_phys_t;
247 248
248 249 #define DN_SPILL_BLKPTR(dnp) ((blkptr_t *)((char *)(dnp) + \
249 250 (((dnp)->dn_extra_slots + 1) << DNODE_SHIFT) - (1 << SPA_BLKPTRSHIFT)))
250 251
251 252 struct dnode {
252 253 /*
253 254 * Protects the structure of the dnode, including the number of levels
254 255 * of indirection (dn_nlevels), dn_maxblkid, and dn_next_*
255 256 */
256 257 krwlock_t dn_struct_rwlock;
257 258
258 259 /* Our link on dn_objset->os_dnodes list; protected by os_lock. */
259 260 list_node_t dn_link;
260 261
261 262 /* immutable: */
262 263 struct objset *dn_objset;
263 264 uint64_t dn_object;
264 265 struct dmu_buf_impl *dn_dbuf;
265 266 struct dnode_handle *dn_handle;
266 267 dnode_phys_t *dn_phys; /* pointer into dn->dn_dbuf->db.db_data */
267 268
268 269 /*
269 270 * Copies of stuff in dn_phys. They're valid in the open
270 271 * context (eg. even before the dnode is first synced).
271 272 * Where necessary, these are protected by dn_struct_rwlock.
272 273 */
273 274 dmu_object_type_t dn_type; /* object type */
274 275 uint16_t dn_bonuslen; /* bonus length */
275 276 uint8_t dn_bonustype; /* bonus type */
276 277 uint8_t dn_nblkptr; /* number of blkptrs (immutable) */
277 278 uint8_t dn_checksum; /* ZIO_CHECKSUM type */
278 279 uint8_t dn_compress; /* ZIO_COMPRESS type */
279 280 uint8_t dn_nlevels;
280 281 uint8_t dn_indblkshift;
281 282 uint8_t dn_datablkshift; /* zero if blksz not power of 2! */
282 283 uint8_t dn_moved; /* Has this dnode been moved? */
283 284 uint16_t dn_datablkszsec; /* in 512b sectors */
284 285 uint32_t dn_datablksz; /* in bytes */
285 286 uint64_t dn_maxblkid;
286 287 uint8_t dn_next_type[TXG_SIZE];
287 288 uint8_t dn_num_slots; /* metadnode slots consumed on disk */
288 289 uint8_t dn_next_nblkptr[TXG_SIZE];
289 290 uint8_t dn_next_nlevels[TXG_SIZE];
290 291 uint8_t dn_next_indblkshift[TXG_SIZE];
291 292 uint8_t dn_next_bonustype[TXG_SIZE];
292 293 uint8_t dn_rm_spillblk[TXG_SIZE]; /* for removing spill blk */
293 294 uint16_t dn_next_bonuslen[TXG_SIZE];
294 295 uint32_t dn_next_blksz[TXG_SIZE]; /* next block size in bytes */
295 296 uint64_t dn_next_maxblkid[TXG_SIZE]; /* next maxblkid in bytes */
296 297
297 298 /* protected by dn_dbufs_mtx; declared here to fill 32-bit hole */
298 299 uint32_t dn_dbufs_count; /* count of dn_dbufs */
299 300
300 301 /* protected by os_lock: */
301 302 multilist_node_t dn_dirty_link[TXG_SIZE]; /* next on dataset's dirty */
302 303
303 304 /* protected by dn_mtx: */
304 305 kmutex_t dn_mtx;
305 306 list_t dn_dirty_records[TXG_SIZE];
306 307 struct range_tree *dn_free_ranges[TXG_SIZE];
307 308 uint64_t dn_allocated_txg;
308 309 uint64_t dn_free_txg;
309 310 uint64_t dn_assigned_txg;
310 311 uint64_t dn_dirty_txg; /* txg dnode was last dirtied */
311 312 kcondvar_t dn_notxholds;
312 313 enum dnode_dirtycontext dn_dirtyctx;
313 314 uint8_t *dn_dirtyctx_firstset; /* dbg: contents meaningless */
314 315
315 316 /* protected by own devices */
316 317 zfs_refcount_t dn_tx_holds;
317 318 zfs_refcount_t dn_holds;
318 319
319 320 kmutex_t dn_dbufs_mtx;
320 321 /*
321 322 * Descendent dbufs, ordered by dbuf_compare. Note that dn_dbufs
322 323 * can contain multiple dbufs of the same (level, blkid) when a
323 324 * dbuf is marked DB_EVICTING without being removed from
324 325 * dn_dbufs. To maintain the avl invariant that there cannot be
325 326 * duplicate entries, we order the dbufs by an arbitrary value -
326 327 * their address in memory. This means that dn_dbufs cannot be used to
327 328 * directly look up a dbuf. Instead, callers must use avl_walk, have
328 329 * a reference to the dbuf, or look up a non-existant node with
329 330 * db_state = DB_SEARCH (see dbuf_free_range for an example).
330 331 */
331 332 avl_tree_t dn_dbufs;
332 333
333 334 /* protected by dn_struct_rwlock */
334 335 struct dmu_buf_impl *dn_bonus; /* bonus buffer dbuf */
335 336
336 337 boolean_t dn_have_spill; /* have spill or are spilling */
337 338
338 339 /* parent IO for current sync write */
339 340 zio_t *dn_zio;
340 341
341 342 /* used in syncing context */
342 343 uint64_t dn_oldused; /* old phys used bytes */
343 344 uint64_t dn_oldflags; /* old phys dn_flags */
344 345 uint64_t dn_olduid, dn_oldgid, dn_oldprojid;
345 346 uint64_t dn_newuid, dn_newgid, dn_newprojid;
346 347 int dn_id_flags;
347 348
348 349 /* holds prefetch structure */
349 350 struct zfetch dn_zfetch;
350 351 };
351 352
352 353 /*
353 354 * We use this (otherwise unused) bit to indicate if the value of
354 355 * dn_next_maxblkid[txgoff] is valid to use in dnode_sync().
355 356 */
356 357 #define DMU_NEXT_MAXBLKID_SET (1ULL << 63)
357 358
358 359 /*
359 360 * Adds a level of indirection between the dbuf and the dnode to avoid
360 361 * iterating descendent dbufs in dnode_move(). Handles are not allocated
361 362 * individually, but as an array of child dnodes in dnode_hold_impl().
362 363 */
363 364 typedef struct dnode_handle {
364 365 /* Protects dnh_dnode from modification by dnode_move(). */
365 366 zrlock_t dnh_zrlock;
366 367 dnode_t *dnh_dnode;
367 368 } dnode_handle_t;
368 369
369 370 typedef struct dnode_children {
370 371 dmu_buf_user_t dnc_dbu; /* User evict data */
371 372 size_t dnc_count; /* number of children */
372 373 dnode_handle_t dnc_children[]; /* sized dynamically */
373 374 } dnode_children_t;
374 375
375 376 typedef struct free_range {
376 377 avl_node_t fr_node;
377 378 uint64_t fr_blkid;
378 379 uint64_t fr_nblks;
379 380 } free_range_t;
380 381
381 382 void dnode_special_open(struct objset *dd, dnode_phys_t *dnp,
382 383 uint64_t object, dnode_handle_t *dnh);
383 384 void dnode_special_close(dnode_handle_t *dnh);
384 385
385 386 void dnode_setbonuslen(dnode_t *dn, int newsize, dmu_tx_t *tx);
|
↓ open down ↓ |
327 lines elided |
↑ open up ↑ |
386 387 void dnode_setbonus_type(dnode_t *dn, dmu_object_type_t, dmu_tx_t *tx);
387 388 void dnode_rm_spill(dnode_t *dn, dmu_tx_t *tx);
388 389
389 390 int dnode_hold(struct objset *dd, uint64_t object,
390 391 void *ref, dnode_t **dnp);
391 392 int dnode_hold_impl(struct objset *dd, uint64_t object, int flag, int dn_slots,
392 393 void *ref, dnode_t **dnp);
393 394 boolean_t dnode_add_ref(dnode_t *dn, void *ref);
394 395 void dnode_rele(dnode_t *dn, void *ref);
395 396 void dnode_rele_and_unlock(dnode_t *dn, void *tag, boolean_t evicting);
397 +int dnode_try_claim(objset_t *os, uint64_t object, int slots);
396 398 void dnode_setdirty(dnode_t *dn, dmu_tx_t *tx);
397 399 void dnode_sync(dnode_t *dn, dmu_tx_t *tx);
398 400 void dnode_allocate(dnode_t *dn, dmu_object_type_t ot, int blocksize, int ibs,
399 401 dmu_object_type_t bonustype, int bonuslen, int dn_slots, dmu_tx_t *tx);
400 402 void dnode_reallocate(dnode_t *dn, dmu_object_type_t ot, int blocksize,
401 403 dmu_object_type_t bonustype, int bonuslen, int dn_slots,
402 404 boolean_t keep_spill, dmu_tx_t *tx);
403 405 void dnode_free(dnode_t *dn, dmu_tx_t *tx);
404 406 void dnode_byteswap(dnode_phys_t *dnp);
405 407 void dnode_buf_byteswap(void *buf, size_t size);
406 408 void dnode_verify(dnode_t *dn);
407 409 int dnode_set_nlevels(dnode_t *dn, int nlevels, dmu_tx_t *tx);
408 410 int dnode_set_blksz(dnode_t *dn, uint64_t size, int ibs, dmu_tx_t *tx);
409 411 void dnode_free_range(dnode_t *dn, uint64_t off, uint64_t len, dmu_tx_t *tx);
410 412 void dnode_diduse_space(dnode_t *dn, int64_t space);
411 413 void dnode_new_blkid(dnode_t *dn, uint64_t blkid, dmu_tx_t *tx,
412 414 boolean_t have_read, boolean_t force);
413 415 uint64_t dnode_block_freed(dnode_t *dn, uint64_t blkid);
414 416 void dnode_init(void);
415 417 void dnode_fini(void);
416 418 int dnode_next_offset(dnode_t *dn, int flags, uint64_t *off,
417 419 int minlvl, uint64_t blkfill, uint64_t txg);
418 420 void dnode_evict_dbufs(dnode_t *dn);
419 421 void dnode_evict_bonus(dnode_t *dn);
420 422 void dnode_free_interior_slots(dnode_t *dn);
421 423 boolean_t dnode_needs_remap(const dnode_t *dn);
422 424
423 425 #define DNODE_IS_DIRTY(_dn) \
424 426 ((_dn)->dn_dirty_txg >= spa_syncing_txg((_dn)->dn_objset->os_spa))
425 427
426 428 #define DNODE_IS_CACHEABLE(_dn) \
427 429 ((_dn)->dn_objset->os_primary_cache == ZFS_CACHE_ALL || \
428 430 (DMU_OT_IS_METADATA((_dn)->dn_type) && \
429 431 (_dn)->dn_objset->os_primary_cache == ZFS_CACHE_METADATA))
430 432
431 433 #define DNODE_META_IS_CACHEABLE(_dn) \
432 434 ((_dn)->dn_objset->os_primary_cache == ZFS_CACHE_ALL || \
433 435 (_dn)->dn_objset->os_primary_cache == ZFS_CACHE_METADATA)
434 436
435 437 /*
436 438 * Used for dnodestats kstat.
437 439 */
438 440 typedef struct dnode_stats {
439 441 /*
440 442 * Number of failed attempts to hold a meta dnode dbuf.
441 443 */
442 444 kstat_named_t dnode_hold_dbuf_hold;
443 445 /*
444 446 * Number of failed attempts to read a meta dnode dbuf.
445 447 */
446 448 kstat_named_t dnode_hold_dbuf_read;
447 449 /*
448 450 * Number of times dnode_hold(..., DNODE_MUST_BE_ALLOCATED) was able
449 451 * to hold the requested object number which was allocated. This is
450 452 * the common case when looking up any allocated object number.
451 453 */
452 454 kstat_named_t dnode_hold_alloc_hits;
453 455 /*
454 456 * Number of times dnode_hold(..., DNODE_MUST_BE_ALLOCATED) was not
455 457 * able to hold the request object number because it was not allocated.
456 458 */
457 459 kstat_named_t dnode_hold_alloc_misses;
458 460 /*
459 461 * Number of times dnode_hold(..., DNODE_MUST_BE_ALLOCATED) was not
460 462 * able to hold the request object number because the object number
461 463 * refers to an interior large dnode slot.
462 464 */
463 465 kstat_named_t dnode_hold_alloc_interior;
464 466 /*
465 467 * Number of times dnode_hold(..., DNODE_MUST_BE_ALLOCATED) needed
466 468 * to retry acquiring slot zrl locks due to contention.
467 469 */
468 470 kstat_named_t dnode_hold_alloc_lock_retry;
469 471 /*
470 472 * Number of times dnode_hold(..., DNODE_MUST_BE_ALLOCATED) did not
471 473 * need to create the dnode because another thread did so after
472 474 * dropping the read lock but before acquiring the write lock.
473 475 */
474 476 kstat_named_t dnode_hold_alloc_lock_misses;
475 477 /*
476 478 * Number of times dnode_hold(..., DNODE_MUST_BE_ALLOCATED) found
477 479 * a free dnode instantiated by dnode_create() but not yet allocated
478 480 * by dnode_allocate().
479 481 */
480 482 kstat_named_t dnode_hold_alloc_type_none;
481 483 /*
482 484 * Number of times dnode_hold(..., DNODE_MUST_BE_FREE) was able
483 485 * to hold the requested range of free dnode slots.
484 486 */
485 487 kstat_named_t dnode_hold_free_hits;
486 488 /*
487 489 * Number of times dnode_hold(..., DNODE_MUST_BE_FREE) was not
488 490 * able to hold the requested range of free dnode slots because
489 491 * at least one slot was allocated.
490 492 */
491 493 kstat_named_t dnode_hold_free_misses;
492 494 /*
493 495 * Number of times dnode_hold(..., DNODE_MUST_BE_FREE) was not
494 496 * able to hold the requested range of free dnode slots because
495 497 * after acquiring the zrl lock at least one slot was allocated.
496 498 */
497 499 kstat_named_t dnode_hold_free_lock_misses;
498 500 /*
499 501 * Number of times dnode_hold(..., DNODE_MUST_BE_FREE) needed
500 502 * to retry acquiring slot zrl locks due to contention.
501 503 */
502 504 kstat_named_t dnode_hold_free_lock_retry;
503 505 /*
|
↓ open down ↓ |
98 lines elided |
↑ open up ↑ |
504 506 * Number of times dnode_hold(..., DNODE_MUST_BE_FREE) requested
505 507 * a range of dnode slots which were held by another thread.
506 508 */
507 509 kstat_named_t dnode_hold_free_refcount;
508 510 /*
509 511 * Number of times dnode_hold(..., DNODE_MUST_BE_FREE) requested
510 512 * a range of dnode slots which would overflow the dnode_phys_t.
511 513 */
512 514 kstat_named_t dnode_hold_free_overflow;
513 515 /*
514 - * Number of times a dnode_hold(...) was attempted on a dnode
515 - * which had already been unlinked in an earlier txg.
516 - */
517 - kstat_named_t dnode_hold_free_txg;
518 - /*
519 516 * Number of times dnode_free_interior_slots() needed to retry
520 517 * acquiring a slot zrl lock due to contention.
521 518 */
522 519 kstat_named_t dnode_free_interior_lock_retry;
523 520 /*
524 521 * Number of new dnodes allocated by dnode_allocate().
525 522 */
526 523 kstat_named_t dnode_allocate;
527 524 /*
528 525 * Number of dnodes re-allocated by dnode_reallocate().
529 526 */
530 527 kstat_named_t dnode_reallocate;
531 528 /*
532 529 * Number of meta dnode dbufs evicted.
533 530 */
534 531 kstat_named_t dnode_buf_evict;
535 532 /*
536 533 * Number of times dmu_object_alloc*() reached the end of the existing
537 534 * object ID chunk and advanced to a new one.
538 535 */
539 536 kstat_named_t dnode_alloc_next_chunk;
540 537 /*
541 538 * Number of times multiple threads attempted to allocate a dnode
542 539 * from the same block of free dnodes.
543 540 */
544 541 kstat_named_t dnode_alloc_race;
545 542 /*
546 543 * Number of times dmu_object_alloc*() was forced to advance to the
547 544 * next meta dnode dbuf due to an error from dmu_object_next().
548 545 */
549 546 kstat_named_t dnode_alloc_next_block;
550 547 /*
551 548 * Statistics for tracking dnodes which have been moved.
552 549 */
553 550 kstat_named_t dnode_move_invalid;
554 551 kstat_named_t dnode_move_recheck1;
555 552 kstat_named_t dnode_move_recheck2;
556 553 kstat_named_t dnode_move_special;
557 554 kstat_named_t dnode_move_handle;
558 555 kstat_named_t dnode_move_rwlock;
559 556 kstat_named_t dnode_move_active;
560 557 } dnode_stats_t;
561 558
562 559 extern dnode_stats_t dnode_stats;
563 560
564 561 #define DNODE_STAT_INCR(stat, val) \
565 562 atomic_add_64(&dnode_stats.stat.value.ui64, (val));
566 563 #define DNODE_STAT_BUMP(stat) \
567 564 DNODE_STAT_INCR(stat, 1);
568 565
569 566 #ifdef ZFS_DEBUG
570 567
571 568 /*
572 569 * There should be a ## between the string literal and fmt, to make it
573 570 * clear that we're joining two strings together, but that piece of shit
574 571 * gcc doesn't support that preprocessor token.
575 572 */
576 573 #define dprintf_dnode(dn, fmt, ...) do { \
577 574 if (zfs_flags & ZFS_DEBUG_DPRINTF) { \
578 575 char __db_buf[32]; \
579 576 uint64_t __db_obj = (dn)->dn_object; \
580 577 if (__db_obj == DMU_META_DNODE_OBJECT) \
581 578 (void) strcpy(__db_buf, "mdn"); \
582 579 else \
583 580 (void) snprintf(__db_buf, sizeof (__db_buf), "%lld", \
584 581 (u_longlong_t)__db_obj);\
585 582 dprintf_ds((dn)->dn_objset->os_dsl_dataset, "obj=%s " fmt, \
586 583 __db_buf, __VA_ARGS__); \
587 584 } \
588 585 _NOTE(CONSTCOND) } while (0)
589 586
590 587 #define DNODE_VERIFY(dn) dnode_verify(dn)
591 588 #define FREE_VERIFY(db, start, end, tx) free_verify(db, start, end, tx)
592 589
593 590 #else
594 591
595 592 #define dprintf_dnode(db, fmt, ...)
596 593 #define DNODE_VERIFY(dn)
597 594 #define FREE_VERIFY(db, start, end, tx)
598 595
599 596 #endif
600 597
601 598 #ifdef __cplusplus
602 599 }
603 600 #endif
604 601
605 602 #endif /* _SYS_DNODE_H */
|
↓ open down ↓ |
77 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX