FreeBSD ZFS
The Zettabyte File System
Defines | Functions | Variables

dnode.c File Reference

#include <sys/zfs_context.h>
#include <sys/dbuf.h>
#include <sys/dnode.h>
#include <sys/dmu.h>
#include <sys/dmu_impl.h>
#include <sys/dmu_tx.h>
#include <sys/dmu_objset.h>
#include <sys/dsl_dir.h>
#include <sys/dsl_dataset.h>
#include <sys/spa.h>
#include <sys/zio.h>
#include <sys/dmu_zfetch.h>
Include dependency graph for dnode.c:

Go to the source code of this file.

Defines

#define DNODE_STAT_ADD(stat)
 Define DNODE_STATS to turn on statistic gathering.

Functions

static int free_range_compar (const void *node1, const void *node2)
static int dnode_cons (void *arg, void *unused, int kmflag)
static void dnode_dest (void *arg, void *unused)
void dnode_init (void)
void dnode_fini (void)
void dnode_byteswap (dnode_phys_t *dnp)
void dnode_buf_byteswap (void *vbuf, size_t size)
void dnode_setbonuslen (dnode_t *dn, int newsize, dmu_tx_t *tx)
void dnode_setbonus_type (dnode_t *dn, dmu_object_type_t newtype, dmu_tx_t *tx)
void dnode_rm_spill (dnode_t *dn, dmu_tx_t *tx)
static void dnode_setdblksz (dnode_t *dn, int size)
static dnode_tdnode_create (objset_t *os, dnode_phys_t *dnp, dmu_buf_impl_t *db, uint64_t object, dnode_handle_t *dnh)
static void dnode_destroy (dnode_t *dn)
 Caller must be holding the dnode handle, which is released upon return.
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)
static void dnode_move_impl (dnode_t *odn, dnode_t *ndn)
void dnode_special_close (dnode_handle_t *dnh)
dnode_tdnode_special_open (objset_t *os, dnode_phys_t *dnp, uint64_t object, dnode_handle_t *dnh)
static void dnode_buf_pageout (dmu_buf_t *db, void *arg)
int dnode_hold_impl (objset_t *os, uint64_t object, int flag, void *tag, dnode_t **dnp)
 Succeeds even for free dnodes.
int dnode_hold (objset_t *os, uint64_t object, void *tag, dnode_t **dnp)
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.
void dnode_rele (dnode_t *dn, void *tag)
void dnode_setdirty (dnode_t *dn, dmu_tx_t *tx)
void dnode_free (dnode_t *dn, dmu_tx_t *tx)
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_new_blkid (dnode_t *dn, uint64_t blkid, dmu_tx_t *tx, boolean_t have_read)
 read-holding callers must not rely on the lock being continuously held
void dnode_clear_range (dnode_t *dn, uint64_t blkid, uint64_t nblks, dmu_tx_t *tx)
void dnode_free_range (dnode_t *dn, uint64_t off, uint64_t len, dmu_tx_t *tx)
static boolean_t dnode_spill_freed (dnode_t *dn)
uint64_t dnode_block_freed (dnode_t *dn, uint64_t blkid)
void dnode_diduse_space (dnode_t *dn, int64_t delta)
 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.
static int dnode_next_offset_level (dnode_t *dn, int flags, uint64_t *offset, int lvl, uint64_t blkfill, uint64_t txg)
 Scans a block at the indicated "level" looking for a hole or data (depending on 'flags').
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.

Variables

static kmem_cache_t * dnode_cache
static dnode_phys_t dnode_phys_zero
int zfs_default_bs = SPA_MINBLOCKSHIFT
int zfs_default_ibs = DN_MAX_INDBLKSHIFT

Define Documentation

#define DNODE_STAT_ADD (   stat)

Define DNODE_STATS to turn on statistic gathering.

By default, it is only turned on when DEBUG is also defined.

Definition at line 53 of file dnode.c.


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 *  vbuf,
size_t  size 
)

Definition at line 298 of file dnode.c.

static void dnode_buf_pageout ( dmu_buf_t db,
void *  arg 
) [static]

Definition at line 961 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.

static int dnode_cons ( void *  arg,
void *  unused,
int  kmflag 
) [static]

Definition at line 67 of file dnode.c.

static dnode_t* dnode_create ( objset_t os,
dnode_phys_t dnp,
dmu_buf_impl_t db,
uint64_t  object,
dnode_handle_t dnh 
) [static]

Definition at line 378 of file dnode.c.

static void dnode_dest ( void *  arg,
void *  unused 
) [static]

Definition at line 126 of file dnode.c.

static void dnode_destroy ( dnode_t dn) [static]

Caller must be holding the dnode handle, which is released upon return.

Definition at line 436 of file dnode.c.

void dnode_diduse_space ( dnode_t dn,
int64_t  delta 
)

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

Definition at line 1767 of file dnode.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.

static void dnode_move_impl ( dnode_t odn,
dnode_t ndn 
) [static]

Definition at line 648 of file dnode.c.

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

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.

static int dnode_next_offset_level ( dnode_t dn,
int  flags,
uint64_t *  offset,
int  lvl,
uint64_t  blkfill,
uint64_t  txg 
) [static]

Scans a block at the indicated "level" looking for a hole or data (depending on 'flags').

If level > 0, then we are scanning an indirect block looking at its pointers. If level == 0, then we are looking at a block of dnodes. If we don't find what we are looking for in the block, we return ESRCH. Otherwise, return with *offset pointing to the beginning (if searching forwards) or end (if searching backwards) of the range covered by the block pointer we matched on (or dnode).

The basic search algorithm used below by dnode_next_offset() is to use this function to search up the block tree (widen the search) until we find something (i.e., we don't return ESRCH) and then search back down the tree (narrow the search) until we reach our original search level.

Definition at line 1832 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 *  tag 
)

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  newtype,
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.

static void dnode_setdblksz ( dnode_t dn,
int  size 
) [static]

Definition at line 365 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 ( objset_t os,
dnode_phys_t dnp,
uint64_t  object,
dnode_handle_t dnh 
)

Definition at line 950 of file dnode.c.

static boolean_t dnode_spill_freed ( dnode_t dn) [static]

Definition at line 1703 of file dnode.c.

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.

static int free_range_compar ( const void *  node1,
const void *  node2 
) [static]

Definition at line 314 of file dnode.c.


Variable Documentation

kmem_cache_t* dnode_cache [static]

Definition at line 41 of file dnode.c.

Definition at line 56 of file dnode.c.

int zfs_default_bs = SPA_MINBLOCKSHIFT

Definition at line 58 of file dnode.c.

int zfs_default_ibs = DN_MAX_INDBLKSHIFT

Definition at line 59 of file dnode.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines