FreeBSD ZFS
The Zettabyte File System
Functions | Variables

zap.c File Reference

This file contains the top half of the zfs directory structure implementation. More...

#include <sys/spa.h>
#include <sys/dmu.h>
#include <sys/zfs_context.h>
#include <sys/zfs_znode.h>
#include <sys/fs/zfs.h>
#include <sys/zap.h>
#include <sys/refcount.h>
#include <sys/zap_impl.h>
#include <sys/zap_leaf.h>
Include dependency graph for zap.c:

Go to the source code of this file.

Functions

static void zap_leaf_pageout (dmu_buf_t *db, void *vl)
static uint64_t zap_allocate_blocks (zap_t *zap, int nblocks)
void fzap_byteswap (void *vbuf, size_t size)
void fzap_upgrade (zap_t *zap, dmu_tx_t *tx, zap_flags_t flags)
static int zap_tryupgradedir (zap_t *zap, dmu_tx_t *tx)
static int zap_table_grow (zap_t *zap, zap_table_phys_t *tbl, void(*transfer_func)(const uint64_t *src, uint64_t *dst, int n), dmu_tx_t *tx)
 Generic routines for dealing with the pointer & cookie tables.
static int zap_table_store (zap_t *zap, zap_table_phys_t *tbl, uint64_t idx, uint64_t val, dmu_tx_t *tx)
static int zap_table_load (zap_t *zap, zap_table_phys_t *tbl, uint64_t idx, uint64_t *valp)
static void zap_ptrtbl_transfer (const uint64_t *src, uint64_t *dst, int n)
 Routines for growing the ptrtbl.
static int zap_grow_ptrtbl (zap_t *zap, dmu_tx_t *tx)
static void zap_increment_num_entries (zap_t *zap, int delta, dmu_tx_t *tx)
static zap_leaf_tzap_create_leaf (zap_t *zap, dmu_tx_t *tx)
int fzap_count (zap_t *zap, uint64_t *count)
void zap_put_leaf (zap_leaf_t *l)
static zap_leaf_tzap_open_leaf (uint64_t blkid, dmu_buf_t *db)
static int zap_get_leaf_byblk (zap_t *zap, uint64_t blkid, dmu_tx_t *tx, krw_t lt, zap_leaf_t **lp)
static int zap_idx_to_blk (zap_t *zap, uint64_t idx, uint64_t *valp)
static int zap_set_idx_to_blk (zap_t *zap, uint64_t idx, uint64_t blk, dmu_tx_t *tx)
static int zap_deref_leaf (zap_t *zap, uint64_t h, dmu_tx_t *tx, krw_t lt, zap_leaf_t **lp)
static int zap_expand_leaf (zap_name_t *zn, zap_leaf_t *l, dmu_tx_t *tx, zap_leaf_t **lp)
static void zap_put_leaf_maybe_grow_ptrtbl (zap_name_t *zn, zap_leaf_t *l, dmu_tx_t *tx)
static int fzap_checkname (zap_name_t *zn)
static int fzap_checksize (uint64_t integer_size, uint64_t num_integers)
static int fzap_check (zap_name_t *zn, uint64_t integer_size, uint64_t num_integers)
int fzap_lookup (zap_name_t *zn, uint64_t integer_size, uint64_t num_integers, void *buf, char *realname, int rn_len, boolean_t *ncp)
 Routines for manipulating attributes.
int fzap_add_cd (zap_name_t *zn, uint64_t integer_size, uint64_t num_integers, const void *val, uint32_t cd, dmu_tx_t *tx)
int fzap_add (zap_name_t *zn, uint64_t integer_size, uint64_t num_integers, const void *val, dmu_tx_t *tx)
int fzap_update (zap_name_t *zn, int integer_size, uint64_t num_integers, const void *val, dmu_tx_t *tx)
int fzap_length (zap_name_t *zn, uint64_t *integer_size, uint64_t *num_integers)
int fzap_remove (zap_name_t *zn, dmu_tx_t *tx)
void fzap_prefetch (zap_name_t *zn)
uint64_t zap_create_link (objset_t *os, dmu_object_type_t ot, uint64_t parent_obj, const char *name, dmu_tx_t *tx)
int zap_value_search (objset_t *os, uint64_t zapobj, uint64_t value, uint64_t mask, char *name)
 Search for an entry by za_first_integer.
int zap_join (objset_t *os, uint64_t fromobj, uint64_t intoobj, dmu_tx_t *tx)
 Transfer all the entries from fromobj into intoobj.
int zap_join_key (objset_t *os, uint64_t fromobj, uint64_t intoobj, uint64_t value, dmu_tx_t *tx)
 Same as zap_join, but add together any duplicated entries.
int zap_join_increment (objset_t *os, uint64_t fromobj, uint64_t intoobj, dmu_tx_t *tx)
 Same as zap_join, but set the values to 'value'.
int zap_add_int (objset_t *os, uint64_t obj, uint64_t value, dmu_tx_t *tx)
 Manipulate entries where the name + value are the "same" (the name is a stringified version of the value).
int zap_remove_int (objset_t *os, uint64_t obj, uint64_t value, dmu_tx_t *tx)
int zap_lookup_int (objset_t *os, uint64_t obj, uint64_t value)
int zap_add_int_key (objset_t *os, uint64_t obj, uint64_t key, uint64_t value, dmu_tx_t *tx)
 Here the key is an int and the value is a different int.
int zap_update_int_key (objset_t *os, uint64_t obj, uint64_t key, uint64_t value, dmu_tx_t *tx)
int zap_lookup_int_key (objset_t *os, uint64_t obj, uint64_t key, uint64_t *valuep)
int zap_increment (objset_t *os, uint64_t obj, const char *name, int64_t delta, dmu_tx_t *tx)
int zap_increment_int (objset_t *os, uint64_t obj, uint64_t key, int64_t delta, dmu_tx_t *tx)
int fzap_cursor_retrieve (zap_t *zap, zap_cursor_t *zc, zap_attribute_t *za)
static void zap_stats_ptrtbl (zap_t *zap, uint64_t *tbl, int len, zap_stats_t *zs)
int fzap_cursor_move_to_key (zap_cursor_t *zc, zap_name_t *zn)
void fzap_get_stats (zap_t *zap, zap_stats_t *zs)
int fzap_count_write (zap_name_t *zn, int add, uint64_t *towrite, uint64_t *tooverwrite)

Variables

int fzap_default_block_shift = 14

Detailed Description

This file contains the top half of the zfs directory structure implementation.

The bottom half is in zap_leaf.c.

The zdir is an extendable hash data structure. There is a table of pointers to buckets (zap_t->zd_data->zd_leafs). The buckets are each a constant size and hold a variable number of directory entries. The buckets (aka "leaf nodes") are implemented in zap_leaf.c.

The pointer table holds a power of 2 number of pointers. (1<<zap_t->zd_data->zd_phys->zd_prefix_len). The bucket pointed to by the pointer at index i in the table holds entries whose hash value has a zd_prefix_len - bit prefix

Definition in file zap.c.


Function Documentation

int fzap_add ( zap_name_t zn,
uint64_t  integer_size,
uint64_t  num_integers,
const void *  val,
dmu_tx_t tx 
)

Definition at line 835 of file zap.c.

int fzap_add_cd ( zap_name_t zn,
uint64_t  integer_size,
uint64_t  num_integers,
const void *  val,
uint32_t  cd,
dmu_tx_t tx 
)

Definition at line 791 of file zap.c.

void fzap_byteswap ( void *  vbuf,
size_t  size 
)

Definition at line 60 of file zap.c.

static int fzap_check ( zap_name_t zn,
uint64_t  integer_size,
uint64_t  num_integers 
) [static]

Definition at line 744 of file zap.c.

static int fzap_checkname ( zap_name_t zn) [static]

Definition at line 716 of file zap.c.

static int fzap_checksize ( uint64_t  integer_size,
uint64_t  num_integers 
) [static]

Definition at line 724 of file zap.c.

int fzap_count ( zap_t zap,
uint64_t *  count 
)

Definition at line 421 of file zap.c.

int fzap_count_write ( zap_name_t zn,
int  add,
uint64_t *  towrite,
uint64_t *  tooverwrite 
)

Definition at line 1328 of file zap.c.

int fzap_cursor_move_to_key ( zap_cursor_t zc,
zap_name_t zn 
)

Definition at line 1248 of file zap.c.

int fzap_cursor_retrieve ( zap_t zap,
zap_cursor_t zc,
zap_attribute_t za 
)

Definition at line 1153 of file zap.c.

void fzap_get_stats ( zap_t zap,
zap_stats_t zs 
)

Definition at line 1273 of file zap.c.

int fzap_length ( zap_name_t zn,
uint64_t *  integer_size,
uint64_t *  num_integers 
)

Definition at line 891 of file zap.c.

int fzap_lookup ( zap_name_t zn,
uint64_t  integer_size,
uint64_t  num_integers,
void *  buf,
char *  realname,
int  rn_len,
boolean_t *  ncp 
)

Routines for manipulating attributes.

Definition at line 757 of file zap.c.

void fzap_prefetch ( zap_name_t zn)

Definition at line 934 of file zap.c.

int fzap_remove ( zap_name_t zn,
dmu_tx_t tx 
)

Definition at line 915 of file zap.c.

int fzap_update ( zap_name_t zn,
int  integer_size,
uint64_t  num_integers,
const void *  val,
dmu_tx_t tx 
)

Definition at line 848 of file zap.c.

void fzap_upgrade ( zap_t zap,
dmu_tx_t tx,
zap_flags_t  flags 
)

Definition at line 75 of file zap.c.

int zap_add_int ( objset_t os,
uint64_t  obj,
uint64_t  value,
dmu_tx_t tx 
)

Manipulate entries where the name + value are the "same" (the name is a stringified version of the value).

Definition at line 1062 of file zap.c.

int zap_add_int_key ( objset_t os,
uint64_t  obj,
uint64_t  key,
uint64_t  value,
dmu_tx_t tx 
)

Here the key is an int and the value is a different int.

Definition at line 1089 of file zap.c.

static uint64_t zap_allocate_blocks ( zap_t zap,
int  nblocks 
) [static]

Definition at line 383 of file zap.c.

static zap_leaf_t* zap_create_leaf ( zap_t zap,
dmu_tx_t tx 
) [static]

Definition at line 393 of file zap.c.

uint64_t zap_create_link ( objset_t os,
dmu_object_type_t  ot,
uint64_t  parent_obj,
const char *  name,
dmu_tx_t tx 
)

Definition at line 953 of file zap.c.

static int zap_deref_leaf ( zap_t zap,
uint64_t  h,
dmu_tx_t tx,
krw_t  lt,
zap_leaf_t **  lp 
) [static]

Definition at line 574 of file zap.c.

static int zap_expand_leaf ( zap_name_t zn,
zap_leaf_t l,
dmu_tx_t tx,
zap_leaf_t **  lp 
) [static]

Definition at line 594 of file zap.c.

static int zap_get_leaf_byblk ( zap_t zap,
uint64_t  blkid,
dmu_tx_t tx,
krw_t  lt,
zap_leaf_t **  lp 
) [static]

Definition at line 500 of file zap.c.

static int zap_grow_ptrtbl ( zap_t zap,
dmu_tx_t tx 
) [static]

Definition at line 321 of file zap.c.

static int zap_idx_to_blk ( zap_t zap,
uint64_t  idx,
uint64_t *  valp 
) [static]

Definition at line 543 of file zap.c.

int zap_increment ( objset_t os,
uint64_t  obj,
const char *  name,
int64_t  delta,
dmu_tx_t tx 
)

Definition at line 1118 of file zap.c.

int zap_increment_int ( objset_t os,
uint64_t  obj,
uint64_t  key,
int64_t  delta,
dmu_tx_t tx 
)

Definition at line 1139 of file zap.c.

static void zap_increment_num_entries ( zap_t zap,
int  delta,
dmu_tx_t tx 
) [static]

Definition at line 373 of file zap.c.

int zap_join ( objset_t os,
uint64_t  fromobj,
uint64_t  intoobj,
dmu_tx_t tx 
)

Transfer all the entries from fromobj into intoobj.

Only works on int_size=8 num_integers=1 values. Fails if there are any duplicated entries.

Definition at line 991 of file zap.c.

int zap_join_increment ( objset_t os,
uint64_t  fromobj,
uint64_t  intoobj,
dmu_tx_t tx 
)

Same as zap_join, but set the values to 'value'.

Definition at line 1034 of file zap.c.

int zap_join_key ( objset_t os,
uint64_t  fromobj,
uint64_t  intoobj,
uint64_t  value,
dmu_tx_t tx 
)

Same as zap_join, but add together any duplicated entries.

Definition at line 1012 of file zap.c.

static void zap_leaf_pageout ( dmu_buf_t db,
void *  vl 
) [static]

Definition at line 443 of file zap.c.

int zap_lookup_int ( objset_t os,
uint64_t  obj,
uint64_t  value 
)

Definition at line 1080 of file zap.c.

int zap_lookup_int_key ( objset_t os,
uint64_t  obj,
uint64_t  key,
uint64_t *  valuep 
)

Definition at line 1109 of file zap.c.

static zap_leaf_t* zap_open_leaf ( uint64_t  blkid,
dmu_buf_t db 
) [static]

Definition at line 452 of file zap.c.

static void zap_ptrtbl_transfer ( const uint64_t *  src,
uint64_t *  dst,
int  n 
) [static]

Routines for growing the ptrtbl.

Definition at line 310 of file zap.c.

void zap_put_leaf ( zap_leaf_t l)

Definition at line 435 of file zap.c.

static void zap_put_leaf_maybe_grow_ptrtbl ( zap_name_t zn,
zap_leaf_t l,
dmu_tx_t tx 
) [static]

Definition at line 681 of file zap.c.

int zap_remove_int ( objset_t os,
uint64_t  obj,
uint64_t  value,
dmu_tx_t tx 
)

Definition at line 1071 of file zap.c.

static int zap_set_idx_to_blk ( zap_t zap,
uint64_t  idx,
uint64_t  blk,
dmu_tx_t tx 
) [static]

Definition at line 559 of file zap.c.

static void zap_stats_ptrtbl ( zap_t zap,
uint64_t *  tbl,
int  len,
zap_stats_t zs 
) [static]

Definition at line 1222 of file zap.c.

static int zap_table_grow ( zap_t zap,
zap_table_phys_t tbl,
void(*)(const uint64_t *src, uint64_t *dst, int n)  transfer_func,
dmu_tx_t tx 
) [static]

Generic routines for dealing with the pointer & cookie tables.

Definition at line 147 of file zap.c.

static int zap_table_load ( zap_t zap,
zap_table_phys_t tbl,
uint64_t  idx,
uint64_t *  valp 
) [static]

Definition at line 270 of file zap.c.

static int zap_table_store ( zap_t zap,
zap_table_phys_t tbl,
uint64_t  idx,
uint64_t  val,
dmu_tx_t tx 
) [static]

Definition at line 222 of file zap.c.

static int zap_tryupgradedir ( zap_t zap,
dmu_tx_t tx 
) [static]

Definition at line 131 of file zap.c.

int zap_update_int_key ( objset_t os,
uint64_t  obj,
uint64_t  key,
uint64_t  value,
dmu_tx_t tx 
)

Definition at line 1099 of file zap.c.

int zap_value_search ( objset_t os,
uint64_t  zapobj,
uint64_t  value,
uint64_t  mask,
char *  name 
)

Search for an entry by za_first_integer.

Parameters:
[in]maskIf mask==0, the match must be exact (ie, same as mask=-1ULL)
[out]nameThe name of the entry whose (za_first_integer & mask) == (value & mask). The string pointed to by name must be at least 256 bytes long.
Return values:
ENOENTNo entry was found for the given value and mask

Definition at line 966 of file zap.c.


Variable Documentation

Definition at line 53 of file zap.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines