FreeBSD ZFS
The Zettabyte File System
Data Structures | Defines | Typedefs | Enumerations | Functions

sys/dnode.h File Reference

#include <sys/zfs_context.h>
#include <sys/avl.h>
#include <sys/spa.h>
#include <sys/txg.h>
#include <sys/zio.h>
#include <sys/refcount.h>
#include <sys/dmu_zfetch.h>
#include <sys/zrlock.h>
#include <sys/dmu_zfetch.h>
#include <sys/zrlock.h>
Include dependency graph for dnode.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  dnode_phys
struct  dnode
struct  dnode_handle
 Adds a level of indirection between the dbuf and the dnode to avoid iterating descendent dbufs in dnode_move(). More...
struct  dnode_children
struct  free_range

Defines

#define DN_MAX_LEVELS
#define DN_BONUS(dnp)
#define DN_USED_BYTES(dnp)
#define EPB(blkshift, typeshift)   (1 << (blkshift - typeshift))
#define DNODE_FLAG_USED_BYTES   (1<<0)
 Is dn_used in bytes? if not, it's in multiples of SPA_MINBLOCKSIZE.
#define DNODE_FLAG_USERUSED_ACCOUNTED   (1<<1)
#define DNODE_FLAG_SPILL_BLKPTR   (1<<2)
 Does dnode have a SA spill blkptr in bonus?
#define dprintf_dnode(db, fmt,...)
#define DNODE_VERIFY(dn)
#define FREE_VERIFY(db, start, end, tx)
dnode_hold() flags
#define DNODE_MUST_BE_ALLOCATED   1
#define DNODE_MUST_BE_FREE   2
dnode_next_offset() flags
#define DNODE_FIND_HOLE   1
#define DNODE_FIND_BACKWARDS   2
#define DNODE_FIND_HAVELOCK   4
Fixed constants
#define DNODE_SHIFT   9
 512 bytes
#define DN_MIN_INDBLKSHIFT   10
 1k
#define DN_MAX_INDBLKSHIFT   14
 16k
#define DNODE_BLOCK_SHIFT   14
 16k
#define DNODE_CORE_SIZE   64
 64 bytes for dnode sans blkptrs
#define DN_MAX_OBJECT_SHIFT   48
 256 trillion (zfs_fid_t limit)
#define DN_MAX_OFFSET_SHIFT   64
 2^64 bytes in a dnode
dnode id flags
Note:
a file will never ever have its ids moved from bonus->spill and only in a crypto environment would it be on spill
#define DN_ID_CHKED_BONUS   0x1
#define DN_ID_CHKED_SPILL   0x2
#define DN_ID_OLD_EXIST   0x4
#define DN_ID_NEW_EXIST   0x8
Derived constants
#define DNODE_SIZE   (1 << DNODE_SHIFT)
#define DN_MAX_NBLKPTR   ((DNODE_SIZE - DNODE_CORE_SIZE) >> SPA_BLKPTRSHIFT)
#define DN_MAX_BONUSLEN   (DNODE_SIZE - DNODE_CORE_SIZE - (1 << SPA_BLKPTRSHIFT))
#define DN_MAX_OBJECT   (1ULL << DN_MAX_OBJECT_SHIFT)
#define DN_ZERO_BONUSLEN   (DN_MAX_BONUSLEN + 1)
#define DN_KILL_SPILLBLK   (1)
#define DNODES_PER_BLOCK_SHIFT   (DNODE_BLOCK_SHIFT - DNODE_SHIFT)
#define DNODES_PER_BLOCK   (1ULL << DNODES_PER_BLOCK_SHIFT)
#define DNODES_PER_LEVEL_SHIFT   (DN_MAX_INDBLKSHIFT - SPA_BLKPTRSHIFT)
#define DNODES_PER_LEVEL   (1ULL << DNODES_PER_LEVEL_SHIFT)

Typedefs

typedef struct dnode_phys dnode_phys_t
typedef struct dnode dnode_t
typedef struct dnode_handle dnode_handle_t
 Adds a level of indirection between the dbuf and the dnode to avoid iterating descendent dbufs in dnode_move().
typedef struct dnode_children dnode_children_t
typedef struct free_range free_range_t

Enumerations

enum  dnode_dirtycontext { DN_UNDIRTIED, DN_DIRTY_OPEN, DN_DIRTY_SYNC }

Functions

dnode_tdnode_special_open (struct objset *dd, dnode_phys_t *dnp, uint64_t object, dnode_handle_t *dnh)
void dnode_special_close (dnode_handle_t *dnh)
void dnode_setbonuslen (dnode_t *dn, int newsize, dmu_tx_t *tx)
void dnode_setbonus_type (dnode_t *dn, dmu_object_type_t, dmu_tx_t *tx)
void dnode_rm_spill (dnode_t *dn, dmu_tx_t *tx)
int dnode_hold (struct objset *dd, uint64_t object, void *ref, dnode_t **dnp)
int dnode_hold_impl (struct objset *dd, uint64_t object, int flag, void *ref, dnode_t **dnp)
 Succeeds even for free dnodes.
boolean_t dnode_add_ref (dnode_t *dn, void *ref)
 Can only add a reference if there is already at least one reference on the dnode.
void dnode_rele (dnode_t *dn, void *ref)
void dnode_setdirty (dnode_t *dn, dmu_tx_t *tx)
void dnode_sync (dnode_t *dn, dmu_tx_t *tx)
 Writes out the dnode's dirty buffers.
void dnode_allocate (dnode_t *dn, dmu_object_type_t ot, int blocksize, int ibs, dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx)
void dnode_reallocate (dnode_t *dn, dmu_object_type_t ot, int blocksize, dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx)
void dnode_free (dnode_t *dn, dmu_tx_t *tx)
void dnode_byteswap (dnode_phys_t *dnp)
void dnode_buf_byteswap (void *buf, size_t size)
void dnode_verify (dnode_t *dn)
int dnode_set_blksz (dnode_t *dn, uint64_t size, int ibs, dmu_tx_t *tx)
 Try to change the block size for the indicated dnode.
void dnode_free_range (dnode_t *dn, uint64_t off, uint64_t len, dmu_tx_t *tx)
void dnode_clear_range (dnode_t *dn, uint64_t blkid, uint64_t nblks, dmu_tx_t *tx)
void dnode_diduse_space (dnode_t *dn, int64_t space)
 call from syncing context when we actually write/free space for this dnode
void dnode_willuse_space (dnode_t *dn, int64_t space, dmu_tx_t *tx)
 Call when we think we're going to write/free space in open context.
void dnode_new_blkid (dnode_t *dn, uint64_t blkid, dmu_tx_t *tx, boolean_t)
 read-holding callers must not rely on the lock being continuously held
uint64_t dnode_block_freed (dnode_t *dn, uint64_t blkid)
void dnode_init (void)
void dnode_fini (void)
int dnode_next_offset (dnode_t *dn, int flags, uint64_t *off, int minlvl, uint64_t blkfill, uint64_t txg)
 Find the next hole, data, or sparse region at or after *offset.
void dnode_evict_dbufs (dnode_t *dn)
 Tries to kick all the dnode's dbufs out of the cache...

Define Documentation

#define DN_BONUS (   dnp)
Value:
((void*)((dnp)->dn_bonus + \
        (((dnp)->dn_nblkptr - 1) * sizeof (blkptr_t))))

Definition at line 107 of file dnode.h.

#define DN_ID_CHKED_BONUS   0x1

Definition at line 80 of file dnode.h.

#define DN_ID_CHKED_SPILL   0x2

Definition at line 81 of file dnode.h.

#define DN_ID_NEW_EXIST   0x8

Definition at line 83 of file dnode.h.

#define DN_ID_OLD_EXIST   0x4

Definition at line 82 of file dnode.h.

#define DN_KILL_SPILLBLK   (1)

Definition at line 95 of file dnode.h.

#define DN_MAX_BONUSLEN   (DNODE_SIZE - DNODE_CORE_SIZE - (1 << SPA_BLKPTRSHIFT))

Definition at line 92 of file dnode.h.

#define DN_MAX_INDBLKSHIFT   14

16k

Definition at line 65 of file dnode.h.

#define DN_MAX_LEVELS
Value:

Definition at line 104 of file dnode.h.

#define DN_MAX_NBLKPTR   ((DNODE_SIZE - DNODE_CORE_SIZE) >> SPA_BLKPTRSHIFT)

Definition at line 91 of file dnode.h.

#define DN_MAX_OBJECT   (1ULL << DN_MAX_OBJECT_SHIFT)

Definition at line 93 of file dnode.h.

#define DN_MAX_OBJECT_SHIFT   48

256 trillion (zfs_fid_t limit)

Definition at line 68 of file dnode.h.

#define DN_MAX_OFFSET_SHIFT   64

2^64 bytes in a dnode

Definition at line 69 of file dnode.h.

#define DN_MIN_INDBLKSHIFT   10

1k

Definition at line 64 of file dnode.h.

#define DN_USED_BYTES (   dnp)
Value:
(((dnp)->dn_flags & DNODE_FLAG_USED_BYTES) ? \
        (dnp)->dn_used : (dnp)->dn_used << SPA_MINBLOCKSHIFT)

Definition at line 110 of file dnode.h.

#define DN_ZERO_BONUSLEN   (DN_MAX_BONUSLEN + 1)

Definition at line 94 of file dnode.h.

#define DNODE_BLOCK_SHIFT   14

16k

Definition at line 66 of file dnode.h.

#define DNODE_CORE_SIZE   64

64 bytes for dnode sans blkptrs

Definition at line 67 of file dnode.h.

#define DNODE_FIND_BACKWARDS   2

Definition at line 55 of file dnode.h.

#define DNODE_FIND_HAVELOCK   4

Definition at line 56 of file dnode.h.

#define DNODE_FIND_HOLE   1

Definition at line 54 of file dnode.h.

#define DNODE_FLAG_SPILL_BLKPTR   (1<<2)

Does dnode have a SA spill blkptr in bonus?

Definition at line 130 of file dnode.h.

#define DNODE_FLAG_USED_BYTES   (1<<0)

Is dn_used in bytes? if not, it's in multiples of SPA_MINBLOCKSIZE.

Definition at line 126 of file dnode.h.

#define DNODE_FLAG_USERUSED_ACCOUNTED   (1<<1)

Definition at line 127 of file dnode.h.

#define DNODE_MUST_BE_ALLOCATED   1

Definition at line 46 of file dnode.h.

#define DNODE_MUST_BE_FREE   2

Definition at line 47 of file dnode.h.

#define DNODE_SHIFT   9

512 bytes

Definition at line 63 of file dnode.h.

#define DNODE_SIZE   (1 << DNODE_SHIFT)

Definition at line 90 of file dnode.h.

#define DNODE_VERIFY (   dn)

Definition at line 357 of file dnode.h.

#define DNODES_PER_BLOCK   (1ULL << DNODES_PER_BLOCK_SHIFT)

Definition at line 98 of file dnode.h.

#define DNODES_PER_BLOCK_SHIFT   (DNODE_BLOCK_SHIFT - DNODE_SHIFT)

Definition at line 97 of file dnode.h.

#define DNODES_PER_LEVEL   (1ULL << DNODES_PER_LEVEL_SHIFT)

Definition at line 100 of file dnode.h.

#define DNODES_PER_LEVEL_SHIFT   (DN_MAX_INDBLKSHIFT - SPA_BLKPTRSHIFT)

Definition at line 99 of file dnode.h.

#define dprintf_dnode (   db,
  fmt,
  ... 
)

Definition at line 356 of file dnode.h.

#define EPB (   blkshift,
  typeshift 
)    (1 << (blkshift - typeshift))

Definition at line 113 of file dnode.h.

#define FREE_VERIFY (   db,
  start,
  end,
  tx 
)

Definition at line 358 of file dnode.h.


Typedef Documentation

typedef struct dnode_handle dnode_handle_t

Adds a level of indirection between the dbuf and the dnode to avoid iterating descendent dbufs in dnode_move().

Handles are not allocated individually, but as an array of child dnodes in dnode_hold_impl().

typedef struct dnode_phys dnode_phys_t
typedef struct dnode dnode_t
typedef struct free_range free_range_t

Enumeration Type Documentation

Enumerator:
DN_UNDIRTIED 
DN_DIRTY_OPEN 
DN_DIRTY_SYNC 

Definition at line 119 of file dnode.h.


Function Documentation

boolean_t dnode_add_ref ( dnode_t dn,
void *  tag 
)

Can only add a reference if there is already at least one reference on the dnode.

Returns:
FALSE if unable to add a new reference, TRUE otherwise

Definition at line 1160 of file dnode.c.

void dnode_allocate ( dnode_t dn,
dmu_object_type_t  ot,
int  blocksize,
int  ibs,
dmu_object_type_t  bonustype,
int  bonuslen,
dmu_tx_t tx 
)

Definition at line 481 of file dnode.c.

uint64_t dnode_block_freed ( dnode_t dn,
uint64_t  blkid 
)
Return values:
TRUEThis blkid was freed in a recent txg
FALSEThis blkid was not freed in a recent txg

Definition at line 1721 of file dnode.c.

void dnode_buf_byteswap ( void *  buf,
size_t  size 
)

Definition at line 298 of file dnode.c.

void dnode_byteswap ( dnode_phys_t dnp)

Definition at line 246 of file dnode.c.

void dnode_clear_range ( dnode_t dn,
uint64_t  blkid,
uint64_t  nblks,
dmu_tx_t tx 
)

Definition at line 1464 of file dnode.c.

void dnode_diduse_space ( dnode_t dn,
int64_t  space 
)

call from syncing context when we actually write/free space for this dnode

Definition at line 1767 of file dnode.c.

void dnode_evict_dbufs ( dnode_t dn)

Tries to kick all the dnode's dbufs out of the cache...

Definition at line 376 of file dnode_sync.c.

void dnode_fini ( void  )

Definition at line 183 of file dnode.c.

void dnode_free ( dnode_t dn,
dmu_tx_t tx 
)

Definition at line 1278 of file dnode.c.

void dnode_free_range ( dnode_t dn,
uint64_t  off,
uint64_t  len,
dmu_tx_t tx 
)

Definition at line 1517 of file dnode.c.

int dnode_hold ( objset_t os,
uint64_t  object,
void *  tag,
dnode_t **  dnp 
)
Returns:
held dnode if the object is allocated, NULL if not.

Definition at line 1148 of file dnode.c.

int dnode_hold_impl ( objset_t os,
uint64_t  object,
int  flag,
void *  tag,
dnode_t **  dnp 
)

Succeeds even for free dnodes.

Return values:
0Success
EINVALinvalid object number
EIOI/O error
otherOther errors

Definition at line 1011 of file dnode.c.

void dnode_init ( void  )

Definition at line 173 of file dnode.c.

void dnode_new_blkid ( dnode_t dn,
uint64_t  blkid,
dmu_tx_t tx,
boolean_t   
)

read-holding callers must not rely on the lock being continuously held

Definition at line 1382 of file dnode.c.

int dnode_next_offset ( dnode_t dn,
int  flags,
uint64_t *  offset,
int  minlvl,
uint64_t  blkfill,
uint64_t  txg 
)

Find the next hole, data, or sparse region at or after *offset.

The value 'blkfill' tells us how many items we expect to find in an L0 data block; this value is 1 for normal objects, DNODES_PER_BLOCK for the meta dnode, and some fraction of DNODES_PER_BLOCK when searching for sparse regions thereof.

Examples:

dnode_next_offset(dn, flags, offset, 1, 1, 0); Finds the next/previous hole/data in a file. Used in dmu_offset_next().

dnode_next_offset(mdn, flags, offset, 0, DNODES_PER_BLOCK, txg); Finds the next free/allocated dnode an objset's meta-dnode. Only finds objects that have new contents since txg (ie. bonus buffer changes and content removal are ignored). Used in dmu_object_next().

dnode_next_offset(mdn, DNODE_FIND_HOLE, offset, 2, DNODES_PER_BLOCK >> 2, 0); Finds the next L2 meta-dnode bp that's at most 1/4 full. Used in dmu_object_alloc().

Definition at line 1963 of file dnode.c.

void dnode_reallocate ( dnode_t dn,
dmu_object_type_t  ot,
int  blocksize,
dmu_object_type_t  bonustype,
int  bonuslen,
dmu_tx_t tx 
)

Definition at line 564 of file dnode.c.

void dnode_rele ( dnode_t dn,
void *  ref 
)

Definition at line 1173 of file dnode.c.

void dnode_rm_spill ( dnode_t dn,
dmu_tx_t tx 
)

Definition at line 355 of file dnode.c.

int dnode_set_blksz ( dnode_t dn,
uint64_t  size,
int  ibs,
dmu_tx_t tx 
)

Try to change the block size for the indicated dnode.

This can only succeed if there are no blocks allocated or dirty beyond first block

Definition at line 1315 of file dnode.c.

void dnode_setbonus_type ( dnode_t dn,
dmu_object_type_t  ,
dmu_tx_t tx 
)

Definition at line 344 of file dnode.c.

void dnode_setbonuslen ( dnode_t dn,
int  newsize,
dmu_tx_t tx 
)

Definition at line 327 of file dnode.c.

void dnode_setdirty ( dnode_t dn,
dmu_tx_t tx 
)

Definition at line 1210 of file dnode.c.

void dnode_special_close ( dnode_handle_t dnh)

Definition at line 931 of file dnode.c.

dnode_t* dnode_special_open ( struct objset dd,
dnode_phys_t dnp,
uint64_t  object,
dnode_handle_t dnh 
)

Definition at line 950 of file dnode.c.

void dnode_sync ( dnode_t dn,
dmu_tx_t tx 
)

Writes out the dnode's dirty buffers.

Definition at line 529 of file dnode_sync.c.

void dnode_verify ( dnode_t dn)
void dnode_willuse_space ( dnode_t dn,
int64_t  space,
dmu_tx_t tx 
)

Call when we think we're going to write/free space in open context.

Be conservative (ie. OK to write less than this or free more than this, but don't write more or free less).

Definition at line 1800 of file dnode.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines