FreeBSD ZFS
The Zettabyte File System
Defines | Functions | Variables

zfs_znode.c File Reference

#include <sys/types.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/systm.h>
#include <sys/sysmacros.h>
#include <sys/resource.h>
#include <sys/mntent.h>
#include <sys/u8_textprep.h>
#include <sys/dsl_dataset.h>
#include <sys/vfs.h>
#include <sys/vnode.h>
#include <sys/file.h>
#include <sys/kmem.h>
#include <sys/errno.h>
#include <sys/unistd.h>
#include <sys/atomic.h>
#include <sys/zfs_dir.h>
#include <sys/zfs_acl.h>
#include <sys/zfs_ioctl.h>
#include <sys/zfs_rlock.h>
#include <sys/zfs_fuid.h>
#include <sys/dnode.h>
#include <sys/fs/zfs.h>
#include <sys/kidmap.h>
#include <sys/dmu.h>
#include <sys/refcount.h>
#include <sys/stat.h>
#include <sys/zap.h>
#include <sys/zfs_znode.h>
#include <sys/sa.h>
#include <sys/zfs_sa.h>
#include <sys/zfs_stat.h>
#include "zfs_prop.h"
#include "zfs_comutil.h"
Include dependency graph for zfs_znode.c:

Go to the source code of this file.

Defines

#define ZNODE_STAT_ADD(stat)
 Define ZNODE_STATS to turn on statistic gathering.
#define NBITSMINOR64   32
#define MAXMAJ64   0xffffffffUL
#define MAXMIN64   0xffffffffUL

Functions

 SYSCTL_INT (_debug_sizeof, OID_AUTO, znode, CTLFLAG_RD, 0, sizeof(znode_t),"sizeof(znode_t)")
static void znode_evict_error (dmu_buf_t *dbuf, void *user_ptr)
static int zfs_znode_cache_constructor (void *buf, void *arg, int kmflags)
static void zfs_znode_cache_destructor (void *buf, void *arg)
void zfs_znode_init (void)
void zfs_znode_fini (void)
int zfs_create_share_dir (zfsvfs_t *zfsvfs, dmu_tx_t *tx)
static uint64_t zfs_expldev (dev_t dev)
 Create special expldev for ZFS private use.
dev_t zfs_cmpldev (uint64_t dev)
 Special cmpldev for ZFS private use.
static void zfs_znode_sa_init (zfsvfs_t *zfsvfs, znode_t *zp, dmu_buf_t *db, dmu_object_type_t obj_type, sa_handle_t *sa_hdl)
void zfs_znode_dmu_fini (znode_t *zp)
static void zfs_vnode_forget (vnode_t *vp)
static znode_tzfs_znode_alloc (zfsvfs_t *zfsvfs, dmu_buf_t *db, int blksz, dmu_object_type_t obj_type, sa_handle_t *hdl)
 Construct a new znode/vnode and intialize.
void zfs_mknode (znode_t *dzp, vattr_t *vap, dmu_tx_t *tx, cred_t *cr, uint_t flag, znode_t **zpp, zfs_acl_ids_t *acl_ids)
 Create a new DMU object to hold a zfs znode.
void zfs_xvattr_set (znode_t *zp, xvattr_t *xvap, dmu_tx_t *tx)
 Update in-core attributes.
int zfs_zget (zfsvfs_t *zfsvfs, uint64_t obj_num, znode_t **zpp)
int zfs_rezget (znode_t *zp)
void zfs_znode_delete (znode_t *zp, dmu_tx_t *tx)
void zfs_zinactive (znode_t *zp)
void zfs_znode_free (znode_t *zp)
void zfs_tstamp_update_setup (znode_t *zp, uint_t flag, uint64_t mtime[2], uint64_t ctime[2], boolean_t have_tx)
void zfs_grow_blocksize (znode_t *zp, uint64_t size, dmu_tx_t *tx)
 Grow the block size for a file.
static int zfs_extend (znode_t *zp, uint64_t end)
 Increase the file length.
static int zfs_free_range (znode_t *zp, uint64_t off, uint64_t len)
 Free space in a file.
static int zfs_trunc (znode_t *zp, uint64_t end)
 Truncate a file.
int zfs_freesp (znode_t *zp, uint64_t off, uint64_t len, int flag, boolean_t log)
 Free space in a file.
void zfs_create_fs (objset_t *os, cred_t *cr, nvlist_t *zplprops, dmu_tx_t *tx)
static int zfs_sa_setup (objset_t *osp, sa_attr_type_t **sa_table)
static int zfs_grab_sa_handle (objset_t *osp, uint64_t obj, sa_handle_t **hdlp, dmu_buf_t **db, void *tag)
void zfs_release_sa_handle (sa_handle_t *hdl, dmu_buf_t *db, void *tag)
static int zfs_obj_to_pobj (objset_t *osp, sa_handle_t *hdl, sa_attr_type_t *sa_table, uint64_t *pobjp, int *is_xattrdir)
 Given an object number, return its parent object number and whether or not the object is an extended attribute directory.
static int zfs_obj_to_stats_impl (sa_handle_t *hdl, sa_attr_type_t *sa_table, zfs_stat_t *sb)
 Given an object number, return some zpl level statistics.
static int zfs_obj_to_path_impl (objset_t *osp, uint64_t obj, sa_handle_t *hdl, sa_attr_type_t *sa_table, char *buf, int len)
int zfs_obj_to_path (objset_t *osp, uint64_t obj, char *buf, int len)
int zfs_obj_to_stats (objset_t *osp, uint64_t obj, zfs_stat_t *sb, char *buf, int len)

Variables

krwlock_t zfsvfs_lock
 Needed to close a small window in zfs_znode_move() that allows the zfsvfs to be freed before it can be safely accessed.
static kmem_cache_t * znode_cache = NULL
struct vop_vector zfs_vnodeops
struct vop_vector zfs_fifoops
struct vop_vector zfs_shareops
static uint64_t empty_xattr
static uint64_t pad [4]
static zfs_acl_phys_t acl_phys

Define Documentation

#define MAXMAJ64   0xffffffffUL

Definition at line 558 of file zfs_znode.c.

#define MAXMIN64   0xffffffffUL

Definition at line 561 of file zfs_znode.c.

#define NBITSMINOR64   32

Definition at line 555 of file zfs_znode.c.

#define ZNODE_STAT_ADD (   stat)

Define ZNODE_STATS to turn on statistic gathering.

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

Definition at line 84 of file zfs_znode.c.


Function Documentation

SYSCTL_INT ( _debug_sizeof  ,
OID_AUTO  ,
znode  ,
CTLFLAG_RD  ,
,
sizeof(znode_t ,
"sizeof(znode_t)"   
)
dev_t zfs_cmpldev ( uint64_t  dev)

Special cmpldev for ZFS private use.

Can't use standard cmpldev since it takes a long dev_t and compresses it to dev32_t in LP64. We need to do a compaction of a long dev_t to a dev32_t in ILP32.

Definition at line 586 of file zfs_znode.c.

void zfs_create_fs ( objset_t os,
cred_t *  cr,
nvlist_t *  zplprops,
dmu_tx_t tx 
)

Definition at line 1841 of file zfs_znode.c.

int zfs_create_share_dir ( zfsvfs_t zfsvfs,
dmu_tx_t tx 
)

Definition at line 499 of file zfs_znode.c.

static uint64_t zfs_expldev ( dev_t  dev) [static]

Create special expldev for ZFS private use.

Can't use standard expldev since it doesn't do what we want. The standard expldev() takes a dev32_t in LP64 and expands it to a long dev_t. We need an interface that takes a dev32_t in ILP32 and expands it to a long dev_t.

Definition at line 573 of file zfs_znode.c.

static int zfs_extend ( znode_t zp,
uint64_t  end 
) [static]

Increase the file length.

Parameters:
[in]zpznode of file to free data in.
[in]endnew end-of-file
Returns:
0 on success, error code on failure

Definition at line 1560 of file zfs_znode.c.

static int zfs_free_range ( znode_t zp,
uint64_t  off,
uint64_t  len 
) [static]

Free space in a file.

Parameters:
[in]zpznode of file to free data in.
[in]offstart of section to free.
[in]lenlength of section to free.
Returns:
0 on success, error code on failure

Definition at line 1639 of file zfs_znode.c.

int zfs_freesp ( znode_t zp,
uint64_t  off,
uint64_t  len,
int  flag,
boolean_t  log 
)

Free space in a file.

Parameters:
[in]zpznode of file to free data in.
[in]offstart of range
[in]lenend of range (0 => EOF)
[in]flagcurrent file open mode flags.
[in]logTRUE if this action should be logged
Returns:
0 on success, error code on failure

Definition at line 1768 of file zfs_znode.c.

static int zfs_grab_sa_handle ( objset_t osp,
uint64_t  obj,
sa_handle_t **  hdlp,
dmu_buf_t **  db,
void *  tag 
) [static]

Definition at line 2010 of file zfs_znode.c.

void zfs_grow_blocksize ( znode_t zp,
uint64_t  size,
dmu_tx_t tx 
)

Grow the block size for a file.

Parameters:
[in]zpznode of file to free data in.
[in]sizerequested block size
[in]txopen transaction.
Note:
This function assumes that the znode is write locked.

Definition at line 1509 of file zfs_znode.c.

void zfs_mknode ( znode_t dzp,
vattr_t *  vap,
dmu_tx_t tx,
cred_t *  cr,
uint_t  flag,
znode_t **  zpp,
zfs_acl_ids_t acl_ids 
)

Create a new DMU object to hold a zfs znode.

Parameters:
[in]dzpparent directory for new znode
[in]vapfile attributes for new znode
[in]txdmu transaction id for zap operations
[in]crcredentials of caller
[in]flagflags:

  • IS_ROOT_NODE - new object will be root
  • IS_XATTR - new object is an attribute
[out]zppallocated znode

Definition at line 786 of file zfs_znode.c.

int zfs_obj_to_path ( objset_t osp,
uint64_t  obj,
char *  buf,
int  len 
)

Definition at line 2196 of file zfs_znode.c.

static int zfs_obj_to_path_impl ( objset_t osp,
uint64_t  obj,
sa_handle_t hdl,
sa_attr_type_t sa_table,
char *  buf,
int  len 
) [static]

Definition at line 2124 of file zfs_znode.c.

static int zfs_obj_to_pobj ( objset_t osp,
sa_handle_t hdl,
sa_attr_type_t sa_table,
uint64_t *  pobjp,
int *  is_xattrdir 
) [static]

Given an object number, return its parent object number and whether or not the object is an extended attribute directory.

Definition at line 2049 of file zfs_znode.c.

int zfs_obj_to_stats ( objset_t osp,
uint64_t  obj,
zfs_stat_t sb,
char *  buf,
int  len 
)

Definition at line 2218 of file zfs_znode.c.

static int zfs_obj_to_stats_impl ( sa_handle_t hdl,
sa_attr_type_t sa_table,
zfs_stat_t sb 
) [static]

Given an object number, return some zpl level statistics.

Definition at line 2105 of file zfs_znode.c.

void zfs_release_sa_handle ( sa_handle_t hdl,
dmu_buf_t db,
void *  tag 
)

Definition at line 2038 of file zfs_znode.c.

int zfs_rezget ( znode_t zp)

Definition at line 1276 of file zfs_znode.c.

static int zfs_sa_setup ( objset_t osp,
sa_attr_type_t **  sa_table 
) [static]

Definition at line 1996 of file zfs_znode.c.

static int zfs_trunc ( znode_t zp,
uint64_t  end 
) [static]

Truncate a file.

Parameters:
[in]zpznode of file to free data in.
[in]endnew end-of-file.
Returns:
0 on success, error code on failure

Definition at line 1686 of file zfs_znode.c.

void zfs_tstamp_update_setup ( znode_t zp,
uint_t  flag,
uint64_t  mtime[2],
uint64_t  ctime[2],
boolean_t  have_tx 
)

Definition at line 1466 of file zfs_znode.c.

static void zfs_vnode_forget ( vnode_t *  vp) [static]

Definition at line 634 of file zfs_znode.c.

void zfs_xvattr_set ( znode_t zp,
xvattr_t *  xvap,
dmu_tx_t tx 
)

Update in-core attributes.

It is assumed the caller will be doing an sa_bulk_update to push the changes out

Definition at line 1051 of file zfs_znode.c.

int zfs_zget ( zfsvfs_t zfsvfs,
uint64_t  obj_num,
znode_t **  zpp 
)

Definition at line 1142 of file zfs_znode.c.

void zfs_zinactive ( znode_t zp)

Definition at line 1398 of file zfs_znode.c.

static znode_t* zfs_znode_alloc ( zfsvfs_t zfsvfs,
dmu_buf_t db,
int  blksz,
dmu_object_type_t  obj_type,
sa_handle_t hdl 
) [static]

Construct a new znode/vnode and intialize.

This does not do a call to dmu_set_user() that is up to the caller to do, in case you don't want to return the znode

Definition at line 652 of file zfs_znode.c.

static int zfs_znode_cache_constructor ( void *  buf,
void *  arg,
int  kmflags 
) [static]

Definition at line 124 of file zfs_znode.c.

static void zfs_znode_cache_destructor ( void *  buf,
void *  arg 
) [static]

Definition at line 167 of file zfs_znode.c.

void zfs_znode_delete ( znode_t zp,
dmu_tx_t tx 
)

Definition at line 1379 of file zfs_znode.c.

void zfs_znode_dmu_fini ( znode_t zp)

Definition at line 623 of file zfs_znode.c.

void zfs_znode_fini ( void  )

Definition at line 386 of file zfs_znode.c.

void zfs_znode_free ( znode_t zp)

Definition at line 1444 of file zfs_znode.c.

void zfs_znode_init ( void  )

Definition at line 372 of file zfs_znode.c.

static void zfs_znode_sa_init ( zfsvfs_t zfsvfs,
znode_t zp,
dmu_buf_t db,
dmu_object_type_t  obj_type,
sa_handle_t sa_hdl 
) [static]

Definition at line 592 of file zfs_znode.c.

static void znode_evict_error ( dmu_buf_t dbuf,
void *  user_ptr 
) [static]

Definition at line 103 of file zfs_znode.c.


Variable Documentation

Definition at line 772 of file zfs_znode.c.

uint64_t empty_xattr [static]

Definition at line 770 of file zfs_znode.c.

uint64_t pad[4] [static]

Definition at line 771 of file zfs_znode.c.

struct vop_vector zfs_fifoops

Definition at line 6693 of file zfs_vnops.c.

struct vop_vector zfs_shareops

Definition at line 6694 of file zfs_vnops.c.

struct vop_vector zfs_vnodeops

Definition at line 6692 of file zfs_vnops.c.

krwlock_t zfsvfs_lock

Needed to close a small window in zfs_znode_move() that allows the zfsvfs to be freed before it can be safely accessed.

Definition at line 97 of file zfs_znode.c.

kmem_cache_t* znode_cache = NULL [static]

Definition at line 99 of file zfs_znode.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines