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

sys/arc.h File Reference

#include <sys/zfs_context.h>
#include <sys/zio.h>
#include <sys/dmu.h>
#include <sys/spa.h>
Include dependency graph for arc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  arc_buf

Defines

#define ARC_WAIT   (1 << 1)
 perform I/O synchronously
#define ARC_NOWAIT   (1 << 2)
 perform I/O asynchronously
#define ARC_PREFETCH   (1 << 3)
 I/O is a prefetch.
#define ARC_CACHED   (1 << 4)
 I/O was already in cache.
#define ARC_L2CACHE   (1 << 5)
 cache in L2ARC

Typedefs

typedef struct arc_buf_hdr arc_buf_hdr_t
typedef struct arc_buf arc_buf_t
typedef void arc_done_func_t (zio_t *zio, arc_buf_t *buf, void *priv)
typedef int arc_evict_func_t (void *priv)
typedef enum arc_buf_contents arc_buf_contents_t
typedef enum arc_space_type arc_space_type_t
 The following breakdows of arc_size exist for kstat only.

Enumerations

enum  arc_buf_contents { ARC_BUFC_DATA, ARC_BUFC_METADATA, ARC_BUFC_NUMTYPES }
enum  arc_space_type {
  ARC_SPACE_DATA, ARC_SPACE_HDRS, ARC_SPACE_L2HDRS, ARC_SPACE_OTHER,
  ARC_SPACE_NUMTYPES
}
 

The following breakdows of arc_size exist for kstat only.

More...

Functions

void arc_space_consume (uint64_t space, arc_space_type_t type)
void arc_space_return (uint64_t space, arc_space_type_t type)
void * arc_data_buf_alloc (uint64_t space)
void arc_data_buf_free (void *buf, uint64_t space)
arc_buf_tarc_buf_alloc (spa_t *spa, int size, void *tag, arc_buf_contents_t type)
arc_buf_tarc_loan_buf (spa_t *spa, int size)
 Loan out an anonymous arc buffer.
void arc_return_buf (arc_buf_t *buf, void *tag)
 Return a loaned arc buffer to the arc.
void arc_loan_inuse_buf (arc_buf_t *buf, void *tag)
 Detach an arc_buf from a dbuf (tag)
void arc_buf_add_ref (arc_buf_t *buf, void *tag)
int arc_buf_remove_ref (arc_buf_t *buf, void *tag)
int arc_buf_size (arc_buf_t *buf)
void arc_release (arc_buf_t *buf, void *tag)
 Release this buffer from the cache.
int arc_release_bp (arc_buf_t *buf, void *tag, blkptr_t *bp, spa_t *spa, zbookmark_t *zb)
 Release this buffer.
int arc_released (arc_buf_t *buf)
int arc_has_callback (arc_buf_t *buf)
void arc_buf_freeze (arc_buf_t *buf)
void arc_buf_thaw (arc_buf_t *buf)
boolean_t arc_buf_eviction_needed (arc_buf_t *buf)
 Called from the DMU to determine if the current buffer should be evicted.
int arc_read (zio_t *pio, spa_t *spa, const blkptr_t *bp, arc_buf_t *pbuf, arc_done_func_t *done, void *priv, int priority, int zio_flags, uint32_t *arc_flags, const zbookmark_t *zb)
 "Read" the block block at the specified DVA (in bp) via the cache.
int arc_read_nolock (zio_t *pio, spa_t *spa, const blkptr_t *bp, arc_done_func_t *done, void *priv, int priority, int flags, uint32_t *arc_flags, const zbookmark_t *zb)
zio_tarc_write (zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp, arc_buf_t *buf, boolean_t l2arc, const zio_prop_t *zp, arc_done_func_t *ready, arc_done_func_t *done, void *priv, int priority, int zio_flags, const zbookmark_t *zb)
void arc_set_callback (arc_buf_t *buf, arc_evict_func_t *func, void *priv)
int arc_buf_evict (arc_buf_t *buf)
 This is used by the DMU to let the ARC know that a buffer is being evicted, so the ARC should clean up.
void arc_flush (spa_t *spa)
 Flush all *evictable* data from the cache for the given spa.
void arc_tempreserve_clear (uint64_t reserve)
int arc_tempreserve_space (uint64_t reserve, uint64_t txg)
void arc_init (void)
void arc_fini (void)
void l2arc_add_vdev (spa_t *spa, vdev_t *vd)
 Add a vdev for use by the L2ARC.
void l2arc_remove_vdev (vdev_t *vd)
 Remove a vdev from the L2ARC.
boolean_t l2arc_vdev_present (vdev_t *vd)
void l2arc_init (void)
void l2arc_fini (void)
void l2arc_start (void)
void l2arc_stop (void)

Variables

arc_done_func_t arc_bcopy_func
arc_done_func_t arc_getbuf_func

Define Documentation

#define ARC_CACHED   (1 << 4)

I/O was already in cache.

Definition at line 69 of file arc.h.

#define ARC_L2CACHE   (1 << 5)

cache in L2ARC

Definition at line 70 of file arc.h.

#define ARC_NOWAIT   (1 << 2)

perform I/O asynchronously

Definition at line 67 of file arc.h.

#define ARC_PREFETCH   (1 << 3)

I/O is a prefetch.

Definition at line 68 of file arc.h.

#define ARC_WAIT   (1 << 1)

perform I/O synchronously

Definition at line 66 of file arc.h.


Typedef Documentation

typedef struct arc_buf_hdr arc_buf_hdr_t

Definition at line 39 of file arc.h.

typedef struct arc_buf arc_buf_t

Definition at line 40 of file arc.h.

typedef void arc_done_func_t(zio_t *zio, arc_buf_t *buf, void *priv)

Definition at line 41 of file arc.h.

typedef int arc_evict_func_t(void *priv)

Definition at line 42 of file arc.h.

The following breakdows of arc_size exist for kstat only.


Enumeration Type Documentation

Enumerator:
ARC_BUFC_DATA 

buffer contains data

ARC_BUFC_METADATA 

buffer contains metadata

ARC_BUFC_NUMTYPES 

Definition at line 58 of file arc.h.

The following breakdows of arc_size exist for kstat only.

Enumerator:
ARC_SPACE_DATA 
ARC_SPACE_HDRS 
ARC_SPACE_L2HDRS 
ARC_SPACE_OTHER 
ARC_SPACE_NUMTYPES 

Definition at line 75 of file arc.h.


Function Documentation

void arc_buf_add_ref ( arc_buf_t buf,
void *  tag 
)

Definition at line 1561 of file arc.c.

arc_buf_t* arc_buf_alloc ( spa_t spa,
int  size,
void *  tag,
arc_buf_contents_t  type 
)

Definition at line 1446 of file arc.c.

int arc_buf_evict ( arc_buf_t buf)

This is used by the DMU to let the ARC know that a buffer is being evicted, so the ARC should clean up.

If this arc buf is not yet in the evicted state, it will be put there.

Definition at line 3385 of file arc.c.

boolean_t arc_buf_eviction_needed ( arc_buf_t buf)

Called from the DMU to determine if the current buffer should be evicted.

In order to ensure proper locking, the eviction must be initiated from the DMU. Return true if the buffer is associated with user data and duplicate buffers still exist.

Definition at line 1856 of file arc.c.

void arc_buf_freeze ( arc_buf_t buf)

Definition at line 1186 of file arc.c.

int arc_buf_remove_ref ( arc_buf_t buf,
void *  tag 
)

Definition at line 1810 of file arc.c.

int arc_buf_size ( arc_buf_t buf)

Definition at line 1844 of file arc.c.

void arc_buf_thaw ( arc_buf_t buf)

Definition at line 1156 of file arc.c.

void* arc_data_buf_alloc ( uint64_t  space)

Definition at line 1429 of file arc.c.

void arc_data_buf_free ( void *  buf,
uint64_t  space 
)

Definition at line 1438 of file arc.c.

void arc_fini ( void  )

Definition at line 4105 of file arc.c.

void arc_flush ( spa_t spa)

Flush all *evictable* data from the cache for the given spa.

Note:
This will not touch "active" (i.e. referenced) data.

Definition at line 2309 of file arc.c.

int arc_has_callback ( arc_buf_t buf)

Definition at line 3623 of file arc.c.

void arc_init ( void  )

Definition at line 3924 of file arc.c.

arc_buf_t* arc_loan_buf ( spa_t spa,
int  size 
)

Loan out an anonymous arc buffer.

Loaned buffers are not counted as in flight data by arc_tempreserve_space() until they are "returned". Loaned buffers must be returned to the arc before they can be used by the DMU or freed.

Definition at line 1484 of file arc.c.

void arc_loan_inuse_buf ( arc_buf_t buf,
void *  tag 
)

Detach an arc_buf from a dbuf (tag)

Definition at line 1513 of file arc.c.

int arc_read ( zio_t pio,
spa_t spa,
const blkptr_t bp,
arc_buf_t pbuf,
arc_done_func_t done,
void *  private,
int  priority,
int  zio_flags,
uint32_t *  arc_flags,
const zbookmark_t zb 
)

"Read" the block block at the specified DVA (in bp) via the cache.

If the block is found in the cache, invoke the provided callback immediately and return. Note that the `zio' parameter in the callback will be NULL in this case, since no IO was required. If the block is not in the cache pass the read request on to the spa with a substitute callback function, so that the requested block will be added to the cache.

If a read request arrives for a block that has a read in-progress, either wait for the in-progress read to complete (and return the results); or, if this is a read with a "done" func, add a record to the read to invoke the "done" func when the read completes, and return; or just return.

arc_read_done() will invoke all the requested "done" functions for readers of this block.

Normal callers should use arc_read and pass the arc buffer and offset for the bp. But if you know you don't need locking, you can use arc_read_nolock.

Definition at line 3076 of file arc.c.

int arc_read_nolock ( zio_t pio,
spa_t spa,
const blkptr_t bp,
arc_done_func_t done,
void *  priv,
int  priority,
int  flags,
uint32_t *  arc_flags,
const zbookmark_t zb 
)

Definition at line 3103 of file arc.c.

void arc_release ( arc_buf_t buf,
void *  tag 
)

Release this buffer from the cache.

This must be done after a read and prior to modifying the buffer contents. If the buffer has more than one reference, we must make a new hdr for the buffer.

Definition at line 3474 of file arc.c.

int arc_release_bp ( arc_buf_t buf,
void *  tag,
blkptr_t bp,
spa_t spa,
zbookmark_t zb 
)

Release this buffer.

If it does not match the provided BP, fill it with that block's contents.

Definition at line 3604 of file arc.c.

int arc_released ( arc_buf_t buf)

Definition at line 3612 of file arc.c.

void arc_return_buf ( arc_buf_t buf,
void *  tag 
)

Return a loaned arc buffer to the arc.

Definition at line 1498 of file arc.c.

void arc_set_callback ( arc_buf_t buf,
arc_evict_func_t func,
void *  priv 
)

Definition at line 3367 of file arc.c.

void arc_space_consume ( uint64_t  space,
arc_space_type_t  type 
)

Definition at line 1377 of file arc.c.

void arc_space_return ( uint64_t  space,
arc_space_type_t  type 
)

Definition at line 1401 of file arc.c.

void arc_tempreserve_clear ( uint64_t  reserve)

Definition at line 3832 of file arc.c.

int arc_tempreserve_space ( uint64_t  reserve,
uint64_t  txg 
)

Definition at line 3839 of file arc.c.

zio_t* arc_write ( zio_t pio,
spa_t spa,
uint64_t  txg,
blkptr_t bp,
arc_buf_t buf,
boolean_t  l2arc,
const zio_prop_t zp,
arc_done_func_t ready,
arc_done_func_t done,
void *  priv,
int  priority,
int  zio_flags,
const zbookmark_t zb 
)

Definition at line 3746 of file arc.c.

void l2arc_add_vdev ( spa_t spa,
vdev_t vd 
)

Add a vdev for use by the L2ARC.

By this point the spa has already validated the vdev and opened it.

Definition at line 5078 of file arc.c.

void l2arc_fini ( void  )

Definition at line 5180 of file arc.c.

void l2arc_init ( void  )

Definition at line 5158 of file arc.c.

void l2arc_remove_vdev ( vdev_t vd)

Remove a vdev from the L2ARC.

Definition at line 5123 of file arc.c.

void l2arc_start ( void  )

Definition at line 5201 of file arc.c.

void l2arc_stop ( void  )

Definition at line 5211 of file arc.c.

boolean_t l2arc_vdev_present ( vdev_t vd)

Definition at line 5058 of file arc.c.


Variable Documentation

arc_done_func_t arc_bcopy_func

Definition at line 45 of file arc.h.

arc_done_func_t arc_getbuf_func

Definition at line 46 of file arc.h.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines