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

sys/spa.h File Reference

#include <sys/avl.h>
#include <sys/zfs_context.h>
#include <sys/nvpair.h>
#include <sys/sysmacros.h>
#include <sys/types.h>
#include <sys/fs/zfs.h>
#include <sys/dmu.h>
#include <sys/zfs_context.h>
#include <sys/dmu.h>
Include dependency graph for spa.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  dva
 All SPA data is represented by 128-bit data virtual addresses (DVAs). More...
struct  zio_cksum
 Each block has a 256-bit checksum -- strong enough for cryptographic hashes. More...
struct  blkptr
 Each block is described by its DVAs, time of birth, checksum, etc. More...
struct  history_arg

Defines

#define SPA_MINBLOCKSHIFT   9
#define SPA_MAXBLOCKSHIFT   17
#define SPA_MINBLOCKSIZE   (1ULL << SPA_MINBLOCKSHIFT)
#define SPA_MAXBLOCKSIZE   (1ULL << SPA_MAXBLOCKSHIFT)
#define SPA_BLOCKSIZES   (SPA_MAXBLOCKSHIFT - SPA_MINBLOCKSHIFT + 1)
 We currently support nine block sizes, from 512 bytes to 128K.
#define SPA_CONFIG_BLOCKSIZE   (1ULL << 14)
 Size of block to hold the configuration data (a packed nvlist)
#define SPA_LSIZEBITS   16
#define SPA_PSIZEBITS   16
#define SPA_ASIZEBITS   24
 The DVA size encodings for LSIZE and PSIZE support blocks up to 32MB.
#define SPA_BLKPTRSHIFT   7
 blkptr_t is 128 bytes
#define SPA_DVAS_PER_BP   3
 Number of DVAs in a bp.
#define BP_IS_RAIDZ(bp)
 BP_IS_RAIDZ(bp) assumes no block compression.
#define BP_ZERO(bp)
#define ZFS_HOST_BYTEORDER   (0ULL)
#define BP_SHOULD_BYTESWAP(bp)   (BP_GET_BYTEORDER(bp) != ZFS_HOST_BYTEORDER)
#define BP_SPRINTF_LEN   320
#define SPRINTF_BLKPTR(func, ws, buf, bp, type, checksum, compress)
 This macro allows code sharing between zfs, libzpool, and mdb.
#define BP_GET_BUFC_TYPE(bp)
#define SPA_ASYNC_CONFIG_UPDATE   0x01
#define SPA_ASYNC_REMOVE   0x02
#define SPA_ASYNC_PROBE   0x04
#define SPA_ASYNC_RESILVER_DONE   0x08
#define SPA_ASYNC_RESILVER   0x10
#define SPA_ASYNC_AUTOEXPAND   0x20
#define SPA_ASYNC_REMOVE_DONE   0x40
#define SPA_ASYNC_REMOVE_STOP   0x80
#define SYNC_PASS_DEFERRED_FREE   2
 Defer frees after this pass.
#define SYNC_PASS_DONT_COMPRESS   4
 don't compress after this pass
#define SYNC_PASS_REWRITE   1
 rewrite new bps after this pass
#define SPA_CONFIG_UPDATE_POOL   0
#define SPA_CONFIG_UPDATE_VDEVS   1
#define SCL_NONE   0x00
#define SCL_CONFIG   0x01
#define SCL_STATE   0x02
#define SCL_L2ARC   0x04
 hack until L2ARC 2.0
#define SCL_ALLOC   0x08
#define SCL_ZIO   0x10
#define SCL_FREE   0x20
#define SCL_VDEV   0x40
#define SCL_LOCKS   7
#define SCL_ALL   ((1 << SCL_LOCKS) - 1)
#define SCL_STATE_ALL   (SCL_STATE | SCL_L2ARC | SCL_ZIO)
#define strtonum(str, nptr)   zfs_strtonum((str), (nptr))
#define dprintf_bp(bp, fmt,...)
#define spa_dbgmsg(spa,...)
General-purpose 32-bit and 64-bit bitfield encodings.
#define BF32_DECODE(x, low, len)   P2PHASE((x) >> (low), 1U << (len))
#define BF64_DECODE(x, low, len)   P2PHASE((x) >> (low), 1ULL << (len))
#define BF32_ENCODE(x, low, len)   (P2PHASE((x), 1U << (len)) << (low))
#define BF64_ENCODE(x, low, len)   (P2PHASE((x), 1ULL << (len)) << (low))
#define BF32_GET(x, low, len)   BF32_DECODE(x, low, len)
#define BF64_GET(x, low, len)   BF64_DECODE(x, low, len)
#define BF32_SET(x, low, len, val)   ((x) ^= BF32_ENCODE((x >> low) ^ (val), low, len))
#define BF64_SET(x, low, len, val)   ((x) ^= BF64_ENCODE((x >> low) ^ (val), low, len))
#define BF32_GET_SB(x, low, len, shift, bias)   ((BF32_GET(x, low, len) + (bias)) << (shift))
#define BF64_GET_SB(x, low, len, shift, bias)   ((BF64_GET(x, low, len) + (bias)) << (shift))
#define BF32_SET_SB(x, low, len, shift, bias, val)   BF32_SET(x, low, len, ((val) >> (shift)) - (bias))
#define BF64_SET_SB(x, low, len, shift, bias, val)   BF64_SET(x, low, len, ((val) >> (shift)) - (bias))
Macros to get and set fields in a bp or DVA.
#define DVA_GET_ASIZE(dva)   BF64_GET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, 0)
#define DVA_SET_ASIZE(dva, x)   BF64_SET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, 0, x)
#define DVA_GET_GRID(dva)   BF64_GET((dva)->dva_word[0], 24, 8)
#define DVA_SET_GRID(dva, x)   BF64_SET((dva)->dva_word[0], 24, 8, x)
#define DVA_GET_VDEV(dva)   BF64_GET((dva)->dva_word[0], 32, 32)
#define DVA_SET_VDEV(dva, x)   BF64_SET((dva)->dva_word[0], 32, 32, x)
#define DVA_GET_OFFSET(dva)   BF64_GET_SB((dva)->dva_word[1], 0, 63, SPA_MINBLOCKSHIFT, 0)
#define DVA_SET_OFFSET(dva, x)   BF64_SET_SB((dva)->dva_word[1], 0, 63, SPA_MINBLOCKSHIFT, 0, x)
#define DVA_GET_GANG(dva)   BF64_GET((dva)->dva_word[1], 63, 1)
#define DVA_SET_GANG(dva, x)   BF64_SET((dva)->dva_word[1], 63, 1, x)
#define BP_GET_LSIZE(bp)   BF64_GET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1)
#define BP_SET_LSIZE(bp, x)   BF64_SET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1, x)
#define BP_GET_PSIZE(bp)   BF64_GET_SB((bp)->blk_prop, 16, 16, SPA_MINBLOCKSHIFT, 1)
#define BP_SET_PSIZE(bp, x)   BF64_SET_SB((bp)->blk_prop, 16, 16, SPA_MINBLOCKSHIFT, 1, x)
#define BP_GET_COMPRESS(bp)   BF64_GET((bp)->blk_prop, 32, 8)
#define BP_SET_COMPRESS(bp, x)   BF64_SET((bp)->blk_prop, 32, 8, x)
#define BP_GET_CHECKSUM(bp)   BF64_GET((bp)->blk_prop, 40, 8)
#define BP_SET_CHECKSUM(bp, x)   BF64_SET((bp)->blk_prop, 40, 8, x)
#define BP_GET_TYPE(bp)   BF64_GET((bp)->blk_prop, 48, 8)
#define BP_SET_TYPE(bp, x)   BF64_SET((bp)->blk_prop, 48, 8, x)
#define BP_GET_LEVEL(bp)   BF64_GET((bp)->blk_prop, 56, 5)
#define BP_SET_LEVEL(bp, x)   BF64_SET((bp)->blk_prop, 56, 5, x)
#define BP_GET_PROP_BIT_61(bp)   BF64_GET((bp)->blk_prop, 61, 1)
#define BP_SET_PROP_BIT_61(bp, x)   BF64_SET((bp)->blk_prop, 61, 1, x)
#define BP_GET_DEDUP(bp)   BF64_GET((bp)->blk_prop, 62, 1)
#define BP_SET_DEDUP(bp, x)   BF64_SET((bp)->blk_prop, 62, 1, x)
#define BP_GET_BYTEORDER(bp)   (0 - BF64_GET((bp)->blk_prop, 63, 1))
#define BP_SET_BYTEORDER(bp, x)   BF64_SET((bp)->blk_prop, 63, 1, x)
#define BP_PHYSICAL_BIRTH(bp)   ((bp)->blk_phys_birth ? (bp)->blk_phys_birth : (bp)->blk_birth)
#define BP_SET_BIRTH(bp, logical, physical)
#define BP_GET_ASIZE(bp)
#define BP_GET_UCSIZE(bp)
#define BP_GET_NDVAS(bp)
#define BP_COUNT_GANG(bp)
#define DVA_EQUAL(dva1, dva2)
#define BP_EQUAL(bp1, bp2)
#define ZIO_CHECKSUM_EQUAL(zc1, zc2)
#define DVA_IS_VALID(dva)   (DVA_GET_ASIZE(dva) != 0)
#define ZIO_SET_CHECKSUM(zcp, w0, w1, w2, w3)
#define BP_IDENTITY(bp)   (&(bp)->blk_dva[0])
#define BP_IS_GANG(bp)   DVA_GET_GANG(BP_IDENTITY(bp))
#define BP_IS_HOLE(bp)   ((bp)->blk_birth == 0)
Controls the behavior of spa_vdev_remove().
#define SPA_REMOVE_UNSPARE   0x01
#define SPA_REMOVE_DONE   0x02

Typedefs

typedef struct spa spa_t
typedef struct vdev vdev_t
typedef struct metaslab metaslab_t
typedef struct metaslab_group metaslab_group_t
typedef struct metaslab_class metaslab_class_t
typedef struct zio zio_t
typedef struct zilog zilog_t
typedef struct spa_aux_vdev spa_aux_vdev_t
typedef struct ddt ddt_t
typedef struct ddt_entry ddt_entry_t
typedef struct dva dva_t
 All SPA data is represented by 128-bit data virtual addresses (DVAs).
typedef struct zio_cksum zio_cksum_t
 Each block has a 256-bit checksum -- strong enough for cryptographic hashes.
typedef struct blkptr blkptr_t
 Each block is described by its DVAs, time of birth, checksum, etc.
typedef enum spa_import_type spa_import_type_t
typedef enum spa_log_state spa_log_state_t
 Log state.
typedef enum history_log_type history_log_type_t
 History logging.
typedef struct history_arg history_arg_t

Enumerations

enum  spa_import_type { SPA_IMPORT_EXISTING, SPA_IMPORT_ASSEMBLE }
enum  spa_log_state { SPA_LOG_UNKNOWN = 0, SPA_LOG_MISSING, SPA_LOG_CLEAR, SPA_LOG_GOOD }
 

Log state.

More...
enum  history_log_type { LOG_CMD_POOL_CREATE, LOG_CMD_NORMAL, LOG_INTERNAL }
 

History logging.

More...

Functions

int spa_open (const char *pool, spa_t **, void *tag)
int spa_open_rewind (const char *pool, spa_t **, void *tag, nvlist_t *policy, nvlist_t **config)
int spa_get_stats (const char *pool, nvlist_t **config, char *altroot, size_t buflen)
int spa_create (const char *pool, nvlist_t *config, nvlist_t *props, const char *history_str, nvlist_t *zplprops)
 Pool Creation.
int spa_import_rootpool (const char *name)
int spa_import (const char *pool, nvlist_t *config, nvlist_t *props, uint64_t flags)
 Import a non-root pool into the system.
nvlist_t * spa_tryimport (nvlist_t *tryconfig)
int spa_destroy (char *pool)
 Destroy a storage pool.
int spa_export (char *pool, nvlist_t **oldconfig, boolean_t force, boolean_t hardforce)
 Export a storage pool.
int spa_reset (char *pool)
 Reset a storage pool.
void spa_async_request (spa_t *spa, int flag)
void spa_async_unrequest (spa_t *spa, int flag)
void spa_async_suspend (spa_t *spa)
void spa_async_resume (spa_t *spa)
spa_tspa_inject_addref (char *pool)
 Increment a SPA's inject count.
void spa_inject_delref (spa_t *spa)
void spa_scan_stat_init (spa_t *spa)
 Reset pool scan stat per scan pass (or reboot).
int spa_scan_get_stats (spa_t *spa, pool_scan_stat_t *ps)
 Get scan stats for zpool status reports.
int spa_vdev_add (spa_t *spa, nvlist_t *nvroot)
 Add a device to a storage pool.
int spa_vdev_attach (spa_t *spa, uint64_t guid, nvlist_t *nvroot, int replacing)
 Attach a device to a mirror.
int spa_vdev_detach (spa_t *spa, uint64_t guid, uint64_t pguid, int replace_done)
 Detach a device from a mirror or replacing vdev.
int spa_vdev_remove (spa_t *spa, uint64_t guid, boolean_t unspare)
 Remove a device from the pool.
boolean_t spa_vdev_remove_active (spa_t *spa)
int spa_vdev_setpath (spa_t *spa, uint64_t guid, const char *newpath)
int spa_vdev_setfru (spa_t *spa, uint64_t guid, const char *newfru)
int spa_vdev_split_mirror (spa_t *spa, char *newname, nvlist_t *config, nvlist_t *props, boolean_t exp)
 Split a set of devices from their mirrors, and create a new pool from them.
void spa_spare_add (vdev_t *vd)
void spa_spare_remove (vdev_t *vd)
boolean_t spa_spare_exists (uint64_t guid, uint64_t *pool, int *refcnt)
void spa_spare_activate (vdev_t *vd)
void spa_l2cache_add (vdev_t *vd)
void spa_l2cache_remove (vdev_t *vd)
boolean_t spa_l2cache_exists (uint64_t guid, uint64_t *pool)
void spa_l2cache_activate (vdev_t *vd)
void spa_l2cache_drop (spa_t *spa)
 Stop and drop level 2 ARC devices.
int spa_scan (spa_t *spa, pool_scan_func_t func)
int spa_scan_stop (spa_t *spa)
void spa_sync (spa_t *spa, uint64_t txg)
 Sync the specified transaction group.
void spa_sync_allpools (void)
 Sync all pools.
void spa_config_sync (spa_t *, boolean_t, boolean_t)
 Synchronize pool configuration to disk.
void spa_config_load (void)
 Called when the module is first loaded, this routine loads the configuration file into the SPA namespace.
nvlist_t * spa_all_configs (uint64_t *)
 Sigh.
void spa_config_set (spa_t *spa, nvlist_t *config)
nvlist_t * spa_config_generate (spa_t *spa, vdev_t *vd, uint64_t txg, int getstats)
 Generate the pool's configuration based on the current in-core state.
void spa_config_update (spa_t *spa, int what)
 Update all disk labels, generate a fresh config based on the current in-core state, and sync the global config cache (do not sync the config cache if this is a booting rootpool).
spa_tspa_lookup (const char *name)
 Lookup the named spa_t in the AVL tree.
spa_tspa_add (const char *name, nvlist_t *config, const char *altroot)
 Create an uninitialized spa_t with the given name.
void spa_remove (spa_t *spa)
 Removes a spa_t from the namespace, freeing up any memory used.
spa_tspa_next (spa_t *prev)
 Find the next pool.
void spa_open_ref (spa_t *spa, void *tag)
 Add a reference to the given spa_t.
void spa_close (spa_t *spa, void *tag)
 Remove a reference to the given spa_t.
boolean_t spa_refcount_zero (spa_t *spa)
 Check to see if the spa refcount is zero.
int spa_config_tryenter (spa_t *spa, int locks, void *tag, krw_t rw)
void spa_config_enter (spa_t *spa, int locks, void *tag, krw_t rw)
void spa_config_exit (spa_t *spa, int locks, void *tag)
int spa_config_held (spa_t *spa, int locks, krw_t rw)
uint64_t spa_vdev_enter (spa_t *spa)
 Lock the given spa_t for the purpose of adding or removing a vdev.
uint64_t spa_vdev_config_enter (spa_t *spa)
 Internal implementation for spa_vdev_enter().
void spa_vdev_config_exit (spa_t *spa, vdev_t *vd, uint64_t txg, int error, char *tag)
 Used in combination with spa_vdev_config_enter() to allow the syncing of multiple transactions without releasing the spa_namespace_lock.
int spa_vdev_exit (spa_t *spa, vdev_t *vd, uint64_t txg, int error)
 Unlock the spa_t after adding or removing a vdev.
void spa_vdev_state_enter (spa_t *spa, int oplock)
 Lock the given spa_t for the purpose of changing vdev state.
int spa_vdev_state_exit (spa_t *spa, vdev_t *vd, int error)
spa_log_state_t spa_get_log_state (spa_t *spa)
void spa_set_log_state (spa_t *spa, spa_log_state_t state)
int spa_offline_log (spa_t *spa)
void spa_claim_notify (zio_t *zio)
 Log claim callback.
boolean_t spa_shutting_down (spa_t *spa)
struct dsl_poolspa_get_dsl (spa_t *spa)
boolean_t spa_is_initializing (spa_t *spa)
blkptr_tspa_get_rootblkptr (spa_t *spa)
void spa_set_rootblkptr (spa_t *spa, const blkptr_t *bp)
void spa_altroot (spa_t *, char *, size_t)
int spa_sync_pass (spa_t *spa)
char * spa_name (spa_t *spa)
uint64_t spa_guid (spa_t *spa)
uint64_t spa_load_guid (spa_t *spa)
uint64_t spa_last_synced_txg (spa_t *spa)
uint64_t spa_first_txg (spa_t *spa)
uint64_t spa_syncing_txg (spa_t *spa)
uint64_t spa_version (spa_t *spa)
pool_state_t spa_state (spa_t *spa)
spa_load_state_t spa_load_state (spa_t *spa)
uint64_t spa_freeze_txg (spa_t *spa)
uint64_t spa_get_asize (spa_t *spa, uint64_t lsize)
uint64_t spa_get_dspace (spa_t *spa)
void spa_update_dspace (spa_t *spa)
boolean_t spa_deflate (spa_t *spa)
metaslab_class_tspa_normal_class (spa_t *spa)
metaslab_class_tspa_log_class (spa_t *spa)
int spa_max_replication (spa_t *spa)
int spa_prev_software_version (spa_t *spa)
int spa_busy (void)
uint8_t spa_get_failmode (spa_t *spa)
 Return the failure mode that has been set to this pool.
boolean_t spa_suspended (spa_t *spa)
uint64_t spa_bootfs (spa_t *spa)
uint64_t spa_delegation (spa_t *spa)
objset_tspa_meta_objset (spa_t *spa)
void spa_activate_mos_feature (spa_t *spa, const char *feature)
void spa_deactivate_mos_feature (spa_t *spa, const char *feature)
int spa_rename (const char *oldname, const char *newname)
 Rename a spa_t.
spa_tspa_by_guid (uint64_t pool_guid, uint64_t device_guid)
 Return the spa_t associated with given pool_guid, if it exists.
boolean_t spa_guid_exists (uint64_t pool_guid, uint64_t device_guid)
 Determine whether a pool with the given pool_guid exists.
char * spa_strdup (const char *)
void spa_strfree (char *)
uint64_t spa_get_random (uint64_t range)
uint64_t spa_generate_guid (spa_t *spa)
void sprintf_blkptr (char *buf, const blkptr_t *bp)
void spa_freeze (spa_t *spa)
int spa_change_guid (spa_t *spa)
 Change the GUID for the pool.
void spa_upgrade (spa_t *spa, uint64_t version)
void spa_evict_all (void)
 Remove all pools in the system.
vdev_tspa_lookup_by_guid (spa_t *spa, uint64_t guid, boolean_t l2cache)
boolean_t spa_has_spare (spa_t *, uint64_t guid)
uint64_t dva_get_dsize_sync (spa_t *spa, const dva_t *dva)
uint64_t bp_get_dsize_sync (spa_t *spa, const blkptr_t *bp)
uint64_t bp_get_dsize (spa_t *spa, const blkptr_t *bp)
boolean_t spa_has_slogs (spa_t *spa)
 Return whether this pool has slogs.
boolean_t spa_is_root (spa_t *spa)
boolean_t spa_writeable (spa_t *spa)
int spa_mode (spa_t *spa)
uint64_t zfs_strtonum (const char *str, char **nptr)
 This is a stripped-down version of strtoull, suitable only for converting lowercase hexadecimal numbers that don't overflow.
void spa_history_create_obj (spa_t *spa, dmu_tx_t *tx)
int spa_history_get (spa_t *spa, uint64_t *offset, uint64_t *len_read, char *his_buf)
 Read out the command history.
int spa_history_log (spa_t *spa, const char *his_buf, history_log_type_t what)
 Write out a history event.
void spa_history_log_internal (history_internal_events_t event, spa_t *spa, dmu_tx_t *tx, const char *fmt,...)
void spa_history_log_version (spa_t *spa, history_internal_events_t evt)
void spa_log_error (spa_t *spa, zio_t *zio)
 Log an uncorrectable error to the persistent error log.
void zfs_ereport_post (const char *cls, spa_t *spa, vdev_t *vd, zio_t *zio, uint64_t stateoroffset, uint64_t length)
void zfs_post_remove (spa_t *spa, vdev_t *vd)
 The 'resource.fs.zfs.removed' event is an internal signal that the given vdev has been removed from the system.
void zfs_post_state_change (spa_t *spa, vdev_t *vd)
 The 'resource.fs.zfs.statechange' event is an internal signal that the given vdev has transitioned its state to DEGRADED or HEALTHY.
void zfs_post_autoreplace (spa_t *spa, vdev_t *vd)
 The 'resource.fs.zfs.autoreplace' event is an internal signal that the pool has the 'autoreplace' property set, and therefore any broken vdevs will be handled by higher level logic, and no vdev fault should be generated.
uint64_t spa_get_errlog_size (spa_t *spa)
 Return the number of errors currently in the error log.
int spa_get_errlog (spa_t *spa, void *uaddr, size_t *count)
 Copy all known errors to userland as an array of bookmarks.
void spa_errlog_rotate (spa_t *spa)
 Called when a scrub completes.
void spa_errlog_drain (spa_t *spa)
 Discard any pending errors from the spa_t.
void spa_errlog_sync (spa_t *spa, uint64_t txg)
 Sync the error log out to disk.
void spa_get_errlists (spa_t *spa, avl_tree_t *last, avl_tree_t *scrub)
 Utility function which retrieves copies of the current logs and re-initializes them in the process.
void vdev_cache_stat_init (void)
void vdev_cache_stat_fini (void)
void spa_init (int flags)
void spa_fini (void)
void spa_boot_init ()
int spa_prop_set (spa_t *spa, nvlist_t *nvp)
int spa_prop_get (spa_t *spa, nvlist_t **nvp)
 Get zpool property values.
void spa_prop_clear_bootfs (spa_t *spa, uint64_t obj, dmu_tx_t *tx)
 If the bootfs property value is dsobj, clear it.
void spa_configfile_set (spa_t *, nvlist_t *, boolean_t)
void spa_event_notify (spa_t *spa, vdev_t *vdev, const char *name)
 Post a sysevent corresponding to the given event.
boolean_t spa_debug_enabled (spa_t *spa)

Variables

kmutex_t spa_namespace_lock
 spa namespace global mutex
char * spa_his_ievent_table []
int spa_mode_global
 mode, e.g.

Define Documentation

#define BF32_DECODE (   x,
  low,
  len 
)    P2PHASE((x) >> (low), 1U << (len))

Definition at line 60 of file spa.h.

#define BF32_ENCODE (   x,
  low,
  len 
)    (P2PHASE((x), 1U << (len)) << (low))

Definition at line 62 of file spa.h.

#define BF32_GET (   x,
  low,
  len 
)    BF32_DECODE(x, low, len)

Definition at line 65 of file spa.h.

#define BF32_GET_SB (   x,
  low,
  len,
  shift,
  bias 
)    ((BF32_GET(x, low, len) + (bias)) << (shift))

Definition at line 73 of file spa.h.

#define BF32_SET (   x,
  low,
  len,
  val 
)    ((x) ^= BF32_ENCODE((x >> low) ^ (val), low, len))

Definition at line 68 of file spa.h.

#define BF32_SET_SB (   x,
  low,
  len,
  shift,
  bias,
  val 
)    BF32_SET(x, low, len, ((val) >> (shift)) - (bias))

Definition at line 78 of file spa.h.

#define BF64_DECODE (   x,
  low,
  len 
)    P2PHASE((x) >> (low), 1ULL << (len))

Definition at line 61 of file spa.h.

#define BF64_ENCODE (   x,
  low,
  len 
)    (P2PHASE((x), 1ULL << (len)) << (low))

Definition at line 63 of file spa.h.

#define BF64_GET (   x,
  low,
  len 
)    BF64_DECODE(x, low, len)

Definition at line 66 of file spa.h.

#define BF64_GET_SB (   x,
  low,
  len,
  shift,
  bias 
)    ((BF64_GET(x, low, len) + (bias)) << (shift))

Definition at line 75 of file spa.h.

#define BF64_SET (   x,
  low,
  len,
  val 
)    ((x) ^= BF64_ENCODE((x >> low) ^ (val), low, len))

Definition at line 70 of file spa.h.

#define BF64_SET_SB (   x,
  low,
  len,
  shift,
  bias,
  val 
)    BF64_SET(x, low, len, ((val) >> (shift)) - (bias))

Definition at line 80 of file spa.h.

#define BP_COUNT_GANG (   bp)
Value:
(DVA_GET_GANG(&(bp)->blk_dva[0]) + \
        DVA_GET_GANG(&(bp)->blk_dva[1]) + \
        DVA_GET_GANG(&(bp)->blk_dva[2]))

Definition at line 276 of file spa.h.

#define BP_EQUAL (   bp1,
  bp2 
)
Value:
(BP_PHYSICAL_BIRTH(bp1) == BP_PHYSICAL_BIRTH(bp2) &&    \
        DVA_EQUAL(&(bp1)->blk_dva[0], &(bp2)->blk_dva[0]) &&    \
        DVA_EQUAL(&(bp1)->blk_dva[1], &(bp2)->blk_dva[1]) &&    \
        DVA_EQUAL(&(bp1)->blk_dva[2], &(bp2)->blk_dva[2]))

Definition at line 285 of file spa.h.

#define BP_GET_ASIZE (   bp)
Value:
(DVA_GET_ASIZE(&(bp)->blk_dva[0]) + DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \
                DVA_GET_ASIZE(&(bp)->blk_dva[2]))

Definition at line 263 of file spa.h.

#define BP_GET_BUFC_TYPE (   bp)
Value:

Definition at line 409 of file spa.h.

#define BP_GET_BYTEORDER (   bp)    (0 - BF64_GET((bp)->blk_prop, 63, 1))

Definition at line 251 of file spa.h.

#define BP_GET_CHECKSUM (   bp)    BF64_GET((bp)->blk_prop, 40, 8)

Definition at line 236 of file spa.h.

#define BP_GET_COMPRESS (   bp)    BF64_GET((bp)->blk_prop, 32, 8)

Definition at line 233 of file spa.h.

#define BP_GET_DEDUP (   bp)    BF64_GET((bp)->blk_prop, 62, 1)

Definition at line 248 of file spa.h.

#define BP_GET_LEVEL (   bp)    BF64_GET((bp)->blk_prop, 56, 5)

Definition at line 242 of file spa.h.

#define BP_GET_LSIZE (   bp)    BF64_GET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1)

Definition at line 223 of file spa.h.

#define BP_GET_NDVAS (   bp)
Value:
(!!DVA_GET_ASIZE(&(bp)->blk_dva[0]) + \
        !!DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \
        !!DVA_GET_ASIZE(&(bp)->blk_dva[2]))

Definition at line 271 of file spa.h.

#define BP_GET_PROP_BIT_61 (   bp)    BF64_GET((bp)->blk_prop, 61, 1)

Definition at line 245 of file spa.h.

#define BP_GET_PSIZE (   bp)    BF64_GET_SB((bp)->blk_prop, 16, 16, SPA_MINBLOCKSHIFT, 1)

Definition at line 228 of file spa.h.

#define BP_GET_TYPE (   bp)    BF64_GET((bp)->blk_prop, 48, 8)

Definition at line 239 of file spa.h.

#define BP_GET_UCSIZE (   bp)
Value:

Definition at line 267 of file spa.h.

#define BP_IDENTITY (   bp)    (&(bp)->blk_dva[0])

Definition at line 307 of file spa.h.

#define BP_IS_GANG (   bp)    DVA_GET_GANG(BP_IDENTITY(bp))

Definition at line 308 of file spa.h.

#define BP_IS_HOLE (   bp)    ((bp)->blk_birth == 0)

Definition at line 309 of file spa.h.

#define BP_IS_RAIDZ (   bp)
Value:
(DVA_GET_ASIZE(&(bp)->blk_dva[0]) > \
                                BP_GET_PSIZE(bp))

BP_IS_RAIDZ(bp) assumes no block compression.

Definition at line 313 of file spa.h.

#define BP_PHYSICAL_BIRTH (   bp)    ((bp)->blk_phys_birth ? (bp)->blk_phys_birth : (bp)->blk_birth)

Definition at line 254 of file spa.h.

#define BP_SET_BIRTH (   bp,
  logical,
  physical 
)
Value:
{                                               \
        (bp)->blk_birth = (logical);            \
        (bp)->blk_phys_birth = ((logical) == (physical) ? 0 : (physical)); \
}

Definition at line 257 of file spa.h.

#define BP_SET_BYTEORDER (   bp,
 
)    BF64_SET((bp)->blk_prop, 63, 1, x)

Definition at line 252 of file spa.h.

#define BP_SET_CHECKSUM (   bp,
 
)    BF64_SET((bp)->blk_prop, 40, 8, x)

Definition at line 237 of file spa.h.

#define BP_SET_COMPRESS (   bp,
 
)    BF64_SET((bp)->blk_prop, 32, 8, x)

Definition at line 234 of file spa.h.

#define BP_SET_DEDUP (   bp,
 
)    BF64_SET((bp)->blk_prop, 62, 1, x)

Definition at line 249 of file spa.h.

#define BP_SET_LEVEL (   bp,
 
)    BF64_SET((bp)->blk_prop, 56, 5, x)

Definition at line 243 of file spa.h.

#define BP_SET_LSIZE (   bp,
 
)    BF64_SET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1, x)

Definition at line 225 of file spa.h.

#define BP_SET_PROP_BIT_61 (   bp,
 
)    BF64_SET((bp)->blk_prop, 61, 1, x)

Definition at line 246 of file spa.h.

#define BP_SET_PSIZE (   bp,
 
)    BF64_SET_SB((bp)->blk_prop, 16, 16, SPA_MINBLOCKSHIFT, 1, x)

Definition at line 230 of file spa.h.

#define BP_SET_TYPE (   bp,
 
)    BF64_SET((bp)->blk_prop, 48, 8, x)

Definition at line 240 of file spa.h.

#define BP_SHOULD_BYTESWAP (   bp)    (BP_GET_BYTEORDER(bp) != ZFS_HOST_BYTEORDER)

Definition at line 343 of file spa.h.

#define BP_SPRINTF_LEN   320

Definition at line 345 of file spa.h.

#define BP_ZERO (   bp)
Value:
{                                               \
        (bp)->blk_dva[0].dva_word[0] = 0;       \
        (bp)->blk_dva[0].dva_word[1] = 0;       \
        (bp)->blk_dva[1].dva_word[0] = 0;       \
        (bp)->blk_dva[1].dva_word[1] = 0;       \
        (bp)->blk_dva[2].dva_word[0] = 0;       \
        (bp)->blk_dva[2].dva_word[1] = 0;       \
        (bp)->blk_prop = 0;                     \
        (bp)->blk_pad[0] = 0;                   \
        (bp)->blk_pad[1] = 0;                   \
        (bp)->blk_phys_birth = 0;               \
        (bp)->blk_birth = 0;                    \
        (bp)->blk_fill = 0;                     \
        ZIO_SET_CHECKSUM(&(bp)->blk_cksum, 0, 0, 0, 0); \
}

Definition at line 316 of file spa.h.

#define dprintf_bp (   bp,
  fmt,
  ... 
)

Definition at line 716 of file spa.h.

#define DVA_EQUAL (   dva1,
  dva2 
)
Value:
((dva1)->dva_word[1] == (dva2)->dva_word[1] && \
        (dva1)->dva_word[0] == (dva2)->dva_word[0])

Definition at line 281 of file spa.h.

#define DVA_GET_ASIZE (   dva)    BF64_GET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, 0)

Definition at line 204 of file spa.h.

#define DVA_GET_GANG (   dva)    BF64_GET((dva)->dva_word[1], 63, 1)

Definition at line 220 of file spa.h.

#define DVA_GET_GRID (   dva)    BF64_GET((dva)->dva_word[0], 24, 8)

Definition at line 209 of file spa.h.

#define DVA_GET_OFFSET (   dva)    BF64_GET_SB((dva)->dva_word[1], 0, 63, SPA_MINBLOCKSHIFT, 0)

Definition at line 215 of file spa.h.

#define DVA_GET_VDEV (   dva)    BF64_GET((dva)->dva_word[0], 32, 32)

Definition at line 212 of file spa.h.

#define DVA_IS_VALID (   dva)    (DVA_GET_ASIZE(dva) != 0)

Definition at line 297 of file spa.h.

#define DVA_SET_ASIZE (   dva,
 
)    BF64_SET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, 0, x)

Definition at line 206 of file spa.h.

#define DVA_SET_GANG (   dva,
 
)    BF64_SET((dva)->dva_word[1], 63, 1, x)

Definition at line 221 of file spa.h.

#define DVA_SET_GRID (   dva,
 
)    BF64_SET((dva)->dva_word[0], 24, 8, x)

Definition at line 210 of file spa.h.

#define DVA_SET_OFFSET (   dva,
 
)    BF64_SET_SB((dva)->dva_word[1], 0, 63, SPA_MINBLOCKSHIFT, 0, x)

Definition at line 217 of file spa.h.

#define DVA_SET_VDEV (   dva,
 
)    BF64_SET((dva)->dva_word[0], 32, 32, x)

Definition at line 213 of file spa.h.

#define SCL_ALL   ((1 << SCL_LOCKS) - 1)

Definition at line 550 of file spa.h.

#define SCL_ALLOC   0x08

Definition at line 545 of file spa.h.

#define SCL_CONFIG   0x01

Definition at line 542 of file spa.h.

#define SCL_FREE   0x20

Definition at line 547 of file spa.h.

#define SCL_L2ARC   0x04

hack until L2ARC 2.0

Definition at line 544 of file spa.h.

#define SCL_LOCKS   7

Definition at line 549 of file spa.h.

#define SCL_NONE   0x00

Definition at line 541 of file spa.h.

#define SCL_STATE   0x02

Definition at line 543 of file spa.h.

#define SCL_STATE_ALL   (SCL_STATE | SCL_L2ARC | SCL_ZIO)

Definition at line 551 of file spa.h.

#define SCL_VDEV   0x40

Definition at line 548 of file spa.h.

#define SCL_ZIO   0x10

Definition at line 546 of file spa.h.

#define SPA_ASIZEBITS   24

The DVA size encodings for LSIZE and PSIZE support blocks up to 32MB.

The ASIZE encoding should be at least 64 times larger (6 more bits) to support up to 4-way RAID-Z mirror mode with worst-case gang block overhead, three DVAs per bp, plus one more bit in case we do anything else that expands the ASIZE.

Definition at line 110 of file spa.h.

#define SPA_ASYNC_AUTOEXPAND   0x20

Definition at line 452 of file spa.h.

#define SPA_ASYNC_CONFIG_UPDATE   0x01

Definition at line 447 of file spa.h.

#define SPA_ASYNC_PROBE   0x04

Definition at line 449 of file spa.h.

#define SPA_ASYNC_REMOVE   0x02

Definition at line 448 of file spa.h.

#define SPA_ASYNC_REMOVE_DONE   0x40

Definition at line 453 of file spa.h.

#define SPA_ASYNC_REMOVE_STOP   0x80

Definition at line 454 of file spa.h.

#define SPA_ASYNC_RESILVER   0x10

Definition at line 451 of file spa.h.

#define SPA_ASYNC_RESILVER_DONE   0x08

Definition at line 450 of file spa.h.

#define SPA_BLKPTRSHIFT   7

blkptr_t is 128 bytes

Definition at line 127 of file spa.h.

#define SPA_BLOCKSIZES   (SPA_MAXBLOCKSHIFT - SPA_MINBLOCKSHIFT + 1)

We currently support nine block sizes, from 512 bytes to 128K.

We could go higher, but the benefits are near-zero and the cost of COWing a giant block to modify one byte would become excessive.

Definition at line 94 of file spa.h.

#define SPA_CONFIG_BLOCKSIZE   (1ULL << 14)

Size of block to hold the configuration data (a packed nvlist)

Definition at line 99 of file spa.h.

#define SPA_CONFIG_UPDATE_POOL   0

Definition at line 515 of file spa.h.

#define SPA_CONFIG_UPDATE_VDEVS   1

Definition at line 516 of file spa.h.

#define spa_dbgmsg (   spa,
  ... 
)
Value:
{                                               \
        if (spa_debug_enabled(spa))             \
                zfs_dbgmsg(__VA_ARGS__);        \
}

Definition at line 720 of file spa.h.

#define SPA_DVAS_PER_BP   3

Number of DVAs in a bp.

Definition at line 128 of file spa.h.

#define SPA_LSIZEBITS   16

Definition at line 101 of file spa.h.

#define SPA_MAXBLOCKSHIFT   17

Definition at line 85 of file spa.h.

#define SPA_MAXBLOCKSIZE   (1ULL << SPA_MAXBLOCKSHIFT)

Definition at line 87 of file spa.h.

#define SPA_MINBLOCKSHIFT   9

Definition at line 84 of file spa.h.

#define SPA_MINBLOCKSIZE   (1ULL << SPA_MINBLOCKSHIFT)

Definition at line 86 of file spa.h.

#define SPA_PSIZEBITS   16

Definition at line 102 of file spa.h.

#define SPA_REMOVE_DONE   0x02

Definition at line 461 of file spa.h.

#define SPA_REMOVE_UNSPARE   0x01

Definition at line 460 of file spa.h.

#define SPRINTF_BLKPTR (   func,
  ws,
  buf,
  bp,
  type,
  checksum,
  compress 
)

This macro allows code sharing between zfs, libzpool, and mdb.

'func' is either snprintf() or mdb_snprintf(). 'ws' (whitespace) can be ' ' for single-line format, '
' for multi-line.

Definition at line 352 of file spa.h.

#define strtonum (   str,
  nptr 
)    zfs_strtonum((str), (nptr))

Definition at line 645 of file spa.h.

#define SYNC_PASS_DEFERRED_FREE   2

Defer frees after this pass.

DEFERRED_FREE must be large enough that regular blocks are not deferred. XXX so can't we change it back to 1?

Definition at line 504 of file spa.h.

#define SYNC_PASS_DONT_COMPRESS   4

don't compress after this pass

Definition at line 505 of file spa.h.

#define SYNC_PASS_REWRITE   1

rewrite new bps after this pass

Definition at line 506 of file spa.h.

#define ZFS_HOST_BYTEORDER   (0ULL)
Note:
The byteorder is either 0 or -1, both of which are palindromes. This simplifies the endianness handling a bit.

Definition at line 338 of file spa.h.

#define ZIO_CHECKSUM_EQUAL (   zc1,
  zc2 
)
Value:
(0 == (((zc1).zc_word[0] - (zc2).zc_word[0]) | \
        ((zc1).zc_word[1] - (zc2).zc_word[1]) | \
        ((zc1).zc_word[2] - (zc2).zc_word[2]) | \
        ((zc1).zc_word[3] - (zc2).zc_word[3])))

Definition at line 291 of file spa.h.

#define ZIO_SET_CHECKSUM (   zcp,
  w0,
  w1,
  w2,
  w3 
)
Value:
{                                               \
        (zcp)->zc_word[0] = w0;                 \
        (zcp)->zc_word[1] = w1;                 \
        (zcp)->zc_word[2] = w2;                 \
        (zcp)->zc_word[3] = w3;                 \
}

Definition at line 299 of file spa.h.


Typedef Documentation

typedef struct blkptr blkptr_t

Each block is described by its DVAs, time of birth, checksum, etc.

The word-by-word, bit-by-bit layout of the blkptr is as follows:

	64	56	48	40	32	24	16	8	0
	+-------+-------+-------+-------+-------+-------+-------+-------+
   0	|		vdev1		| GRID  |	  ASIZE		|
	+-------+-------+-------+-------+-------+-------+-------+-------+
   1	|G|			 offset1				|
	+-------+-------+-------+-------+-------+-------+-------+-------+
   2	|		vdev2		| GRID  |	  ASIZE		|
	+-------+-------+-------+-------+-------+-------+-------+-------+
   3	|G|			 offset2				|
	+-------+-------+-------+-------+-------+-------+-------+-------+
   4	|		vdev3		| GRID  |	  ASIZE		|
	+-------+-------+-------+-------+-------+-------+-------+-------+
   5	|G|			 offset3				|
	+-------+-------+-------+-------+-------+-------+-------+-------+
   6	|BDX|lvl| type	| cksum | comp	|     PSIZE	|     LSIZE	|
	+-------+-------+-------+-------+-------+-------+-------+-------+
   7	|			padding					|
	+-------+-------+-------+-------+-------+-------+-------+-------+
   8	|			padding					|
	+-------+-------+-------+-------+-------+-------+-------+-------+
   9	|			physical birth txg			|
	+-------+-------+-------+-------+-------+-------+-------+-------+
   a	|			logical birth txg			|
	+-------+-------+-------+-------+-------+-------+-------+-------+
   b	|			fill count				|
	+-------+-------+-------+-------+-------+-------+-------+-------+
   c	|			checksum[0]				|
	+-------+-------+-------+-------+-------+-------+-------+-------+
   d	|			checksum[1]				|
	+-------+-------+-------+-------+-------+-------+-------+-------+
   e	|			checksum[2]				|
	+-------+-------+-------+-------+-------+-------+-------+-------+
   f	|			checksum[3]				|
	+-------+-------+-------+-------+-------+-------+-------+-------+
 

Legend:

  • vdev virtual device ID
  • offset offset into virtual device
  • LSIZE logical size
  • PSIZE physical size (after compression)
  • ASIZE allocated size (including RAID-Z parity and gang block headers)
  • GRID RAID-Z layout information (reserved for future use)
  • cksum checksum function
  • comp compression function
  • G gang block indicator
  • B byteorder (endianness)
  • D dedup
  • X unused
  • lvl level of indirection
  • type DMU object type
  • phys birth txg of block allocation; zero if same as logical birth txg
  • log. birth transaction group in which the block was logically born
  • fill count number of non-zero blocks under this bp
  • checksum[4] 256-bit checksum of the data this bp describes
typedef struct ddt_entry ddt_entry_t

Definition at line 53 of file spa.h.

typedef struct ddt ddt_t

Definition at line 52 of file spa.h.

typedef struct dva dva_t

All SPA data is represented by 128-bit data virtual addresses (DVAs).

The members of the dva_t should be considered opaque outside the SPA.

typedef struct history_arg history_arg_t

History logging.

Definition at line 48 of file spa.h.

Definition at line 47 of file spa.h.

typedef struct metaslab metaslab_t

Definition at line 46 of file spa.h.

typedef struct spa_aux_vdev spa_aux_vdev_t

Definition at line 51 of file spa.h.

Log state.

typedef struct spa spa_t

Definition at line 44 of file spa.h.

typedef struct vdev vdev_t

Definition at line 45 of file spa.h.

typedef struct zilog zilog_t

Definition at line 50 of file spa.h.

typedef struct zio_cksum zio_cksum_t

Each block has a 256-bit checksum -- strong enough for cryptographic hashes.

typedef struct zio zio_t

Definition at line 49 of file spa.h.


Enumeration Type Documentation

History logging.

Enumerator:
LOG_CMD_POOL_CREATE 
LOG_CMD_NORMAL 
LOG_INTERNAL 

Definition at line 648 of file spa.h.

Enumerator:
SPA_IMPORT_EXISTING 
SPA_IMPORT_ASSEMBLE 

Definition at line 413 of file spa.h.

Log state.

Enumerator:
SPA_LOG_UNKNOWN 

unknown log state

SPA_LOG_MISSING 

missing log(s)

SPA_LOG_CLEAR 

clear the log(s)

SPA_LOG_GOOD 

log(s) are good

Definition at line 571 of file spa.h.


Function Documentation

uint64_t bp_get_dsize ( spa_t spa,
const blkptr_t bp 
)

Definition at line 1534 of file spa_misc.c.

uint64_t bp_get_dsize_sync ( spa_t spa,
const blkptr_t bp 
)

Definition at line 1523 of file spa_misc.c.

uint64_t dva_get_dsize_sync ( spa_t spa,
const dva_t dva 
)

Definition at line 1507 of file spa_misc.c.

void spa_activate_mos_feature ( spa_t spa,
const char *  feature 
)

Definition at line 1046 of file spa_misc.c.

spa_t* spa_add ( const char *  name,
nvlist_t *  config,
const char *  altroot 
)

Create an uninitialized spa_t with the given name.

Requires spa_namespace_lock. The caller must ensure that the spa_t doesn't already exist by calling spa_lookup() first.

Definition at line 414 of file spa_misc.c.

nvlist_t* spa_all_configs ( uint64_t *  generation)

Sigh.

Inside a local zone, we don't have access to /etc/zfs/zpool.cache, and we don't want to allow the local zone to see all the pools anyway. So we have to invent the ZFS_IOC_CONFIG ioctl to grab the configuration information for all pool visible within the zone.

Definition at line 305 of file spa_config.c.

void spa_altroot ( spa_t ,
char *  ,
size_t   
)

Definition at line 1325 of file spa_misc.c.

void spa_async_request ( spa_t spa,
int  flag 
)

Definition at line 5817 of file spa.c.

void spa_async_resume ( spa_t spa)

Definition at line 5775 of file spa.c.

void spa_async_suspend ( spa_t spa)

Definition at line 5765 of file spa.c.

void spa_async_unrequest ( spa_t spa,
int  flag 
)
void spa_boot_init ( )

Definition at line 1576 of file spa_misc.c.

uint64_t spa_bootfs ( spa_t spa)

Definition at line 1692 of file spa_misc.c.

int spa_busy ( void  )

Definition at line 1570 of file spa_misc.c.

spa_t* spa_by_guid ( uint64_t  pool_guid,
uint64_t  device_guid 
)

Return the spa_t associated with given pool_guid, if it exists.

If device_guid is non-zero, determine whether the pool exists *and* contains a device with the specified device_guid.

Definition at line 1115 of file spa_misc.c.

int spa_change_guid ( spa_t spa)

Change the GUID for the pool.

This is done so that we can later re-import a pool built from a clone of our own vdevs. We will modify the root vdev's guid, our own pool guid, and then mark all of our vdevs dirty. Note that we must make sure that all our vdevs are online when we do this, or else any vdevs that weren't present would be orphaned from our pool. We are also going to issue a sysevent to update any watchers.

Definition at line 768 of file spa.c.

void spa_claim_notify ( zio_t zio)

Log claim callback.

Definition at line 1766 of file spa.c.

void spa_close ( spa_t spa,
void *  tag 
)

Remove a reference to the given spa_t.

Must have at least one reference, or have the namespace lock held.

Definition at line 596 of file spa_misc.c.

void spa_config_enter ( spa_t spa,
int  locks,
void *  tag,
krw_t  rw 
)

Definition at line 302 of file spa_misc.c.

void spa_config_exit ( spa_t spa,
int  locks,
void *  tag 
)

Definition at line 333 of file spa_misc.c.

nvlist_t* spa_config_generate ( spa_t spa,
vdev_t vd,
uint64_t  txg,
int  getstats 
)

Generate the pool's configuration based on the current in-core state.

We infer whether to generate a complete config or just one top-level config based on whether vd is the root vdev.

Definition at line 348 of file spa_config.c.

int spa_config_held ( spa_t spa,
int  locks,
krw_t  rw 
)

Definition at line 352 of file spa_misc.c.

void spa_config_load ( void  )

Called when the module is first loaded, this routine loads the configuration file into the SPA namespace.

It does not actually open or load the pools; it only populates the namespace.

Definition at line 77 of file spa_config.c.

void spa_config_set ( spa_t spa,
nvlist_t *  config 
)

Definition at line 332 of file spa_config.c.

void spa_config_sync ( spa_t target,
boolean_t  removing,
boolean_t  postsysevent 
)

Synchronize pool configuration to disk.

This must be called with the namespace lock held.

Definition at line 202 of file spa_config.c.

int spa_config_tryenter ( spa_t spa,
int  locks,
void *  tag,
krw_t  rw 
)

Definition at line 273 of file spa_misc.c.

void spa_config_update ( spa_t spa,
int  what 
)

Update all disk labels, generate a fresh config based on the current in-core state, and sync the global config cache (do not sync the config cache if this is a booting rootpool).

Definition at line 490 of file spa_config.c.

void spa_configfile_set ( spa_t ,
nvlist_t *  ,
boolean_t   
)

Definition at line 612 of file spa.c.

int spa_create ( const char *  pool,
nvlist_t *  config,
nvlist_t *  props,
const char *  history_str,
nvlist_t *  zplprops 
)

Pool Creation.

Definition at line 3346 of file spa.c.

void spa_deactivate_mos_feature ( spa_t spa,
const char *  feature 
)

Definition at line 1053 of file spa_misc.c.

boolean_t spa_debug_enabled ( spa_t spa)

Definition at line 1758 of file spa_misc.c.

boolean_t spa_deflate ( spa_t spa)

Definition at line 1470 of file spa_misc.c.

uint64_t spa_delegation ( spa_t spa)

Definition at line 1698 of file spa_misc.c.

int spa_destroy ( char *  pool)

Destroy a storage pool.

Definition at line 4285 of file spa.c.

void spa_errlog_drain ( spa_t spa)

Discard any pending errors from the spa_t.

Called when unloading a faulted pool, as the errors encountered during the open cannot be synced to disk.

Definition at line 277 of file spa_errlog.c.

void spa_errlog_rotate ( spa_t spa)

Called when a scrub completes.

This simply set a bit which tells which AVL tree to add new errors. spa_errlog_sync() is responsible for actually syncing the changes to the underlying objects.

Definition at line 265 of file spa_errlog.c.

void spa_errlog_sync ( spa_t spa,
uint64_t  txg 
)

Sync the error log out to disk.

This is a little tricky because the act of writing the error log requires the spa_errlist_lock. So, we need to lock the error lists, take a copy of the lists, and then reinitialize them. Then, we drop the error list lock and take the error log lock, at which point we do the errlog processing. Then, if we encounter an I/O error during this process, we can successfully add the error to the list. Note that this will result in the perpetual recycling of errors, but it is an unlikely situation and not a performance critical operation.

Definition at line 341 of file spa_errlog.c.

void spa_event_notify ( spa_t spa,
vdev_t vd,
const char *  name 
)

Post a sysevent corresponding to the given event.

Parameters:
[in]spaProvides information for the event payload
[in]vdOptional. If not null, provides informationfor the event payload
[in]namemust be one of the event definitions in sys/sysevent/eventdefs.h

This doesn't do anything in the userland libzpool, as we don't want consumers to misinterpret ztest or zdb as real changes.

Definition at line 6551 of file spa.c.

void spa_evict_all ( void  )

Remove all pools in the system.

Definition at line 6416 of file spa.c.

int spa_export ( char *  pool,
nvlist_t **  oldconfig,
boolean_t  force,
boolean_t  hardforce 
)

Export a storage pool.

Definition at line 4295 of file spa.c.

void spa_fini ( void  )

Definition at line 1627 of file spa_misc.c.

uint64_t spa_first_txg ( spa_t spa)

Definition at line 1391 of file spa_misc.c.

void spa_freeze ( spa_t spa)

Definition at line 1233 of file spa_misc.c.

uint64_t spa_freeze_txg ( spa_t spa)

Definition at line 1415 of file spa_misc.c.

uint64_t spa_generate_guid ( spa_t spa)

Definition at line 1191 of file spa_misc.c.

uint64_t spa_get_asize ( spa_t spa,
uint64_t  lsize 
)

Definition at line 1422 of file spa_misc.c.

struct dsl_pool* spa_get_dsl ( spa_t spa) [read]

Definition at line 1301 of file spa_misc.c.

uint64_t spa_get_dspace ( spa_t spa)

Definition at line 1435 of file spa_misc.c.

void spa_get_errlists ( spa_t spa,
avl_tree_t *  last,
avl_tree_t *  scrub 
)

Utility function which retrieves copies of the current logs and re-initializes them in the process.

Definition at line 818 of file spa.c.

int spa_get_errlog ( spa_t spa,
void *  uaddr,
size_t *  count 
)

Copy all known errors to userland as an array of bookmarks.

This is actually a union of the on-disk last log and current log, as well as any pending error requests.

Because the act of reading the on-disk log could cause errors to be generated, we have two separate locks: one for the error log and one for the in-core error lists. We only need the error list lock to log and error, so we grab the error log lock while we read the on-disk logs, and only pick up the error list lock when we are finished.

Definition at line 231 of file spa_errlog.c.

uint64_t spa_get_errlog_size ( spa_t spa)

Return the number of errors currently in the error log.

This is actually the sum of both the last log and the current log, since we don't know the union of these logs until we reach userland.

Definition at line 138 of file spa_errlog.c.

uint8_t spa_get_failmode ( spa_t spa)

Return the failure mode that has been set to this pool.

The default behavior will be to block all I/Os when a complete failure occurs.

Definition at line 1452 of file spa_misc.c.

spa_log_state_t spa_get_log_state ( spa_t spa)

Definition at line 1662 of file spa_misc.c.

uint64_t spa_get_random ( uint64_t  range)

Definition at line 1179 of file spa_misc.c.

blkptr_t* spa_get_rootblkptr ( spa_t spa)

Definition at line 1313 of file spa_misc.c.

int spa_get_stats ( const char *  pool,
nvlist_t **  config,
char *  altroot,
size_t  buflen 
)

Definition at line 3102 of file spa.c.

uint64_t spa_guid ( spa_t spa)

Definition at line 1346 of file spa_misc.c.

boolean_t spa_guid_exists ( uint64_t  pool_guid,
uint64_t  device_guid 
)

Determine whether a pool with the given pool_guid exists.

Definition at line 1153 of file spa_misc.c.

boolean_t spa_has_slogs ( spa_t spa)

Return whether this pool has slogs.

No locking needed. It's not a problem if the wrong answer is returned as it's only for performance and not correctness

Definition at line 1656 of file spa_misc.c.

boolean_t spa_has_spare ( spa_t ,
uint64_t  guid 
)

Definition at line 6496 of file spa.c.

void spa_history_create_obj ( spa_t spa,
dmu_tx_t tx 
)

Definition at line 85 of file spa_history.c.

int spa_history_get ( spa_t spa,
uint64_t *  offset,
uint64_t *  len_read,
char *  his_buf 
)

Read out the command history.

Definition at line 341 of file spa_history.c.

int spa_history_log ( spa_t spa,
const char *  his_buf,
history_log_type_t  what 
)

Write out a history event.

Definition at line 304 of file spa_history.c.

void spa_history_log_internal ( history_internal_events_t  event,
spa_t spa,
dmu_tx_t tx,
const char *  fmt,
  ... 
)

Definition at line 474 of file spa_history.c.

void spa_history_log_version ( spa_t spa,
history_internal_events_t  evt 
)

Definition at line 499 of file spa_history.c.

int spa_import ( const char *  pool,
nvlist_t *  config,
nvlist_t *  props,
uint64_t  flags 
)

Import a non-root pool into the system.

Definition at line 3894 of file spa.c.

int spa_import_rootpool ( const char *  name)

Definition at line 3824 of file spa.c.

void spa_init ( int  flags)

Definition at line 1582 of file spa_misc.c.

spa_t* spa_inject_addref ( char *  name)

Increment a SPA's inject count.

Lookup the given spa_t, incrementing the inject count in the process, preventing it from being exported or destroyed.

Definition at line 2933 of file spa.c.

void spa_inject_delref ( spa_t spa)

Definition at line 2949 of file spa.c.

boolean_t spa_is_initializing ( spa_t spa)

Definition at line 1307 of file spa_misc.c.

boolean_t spa_is_root ( spa_t spa)

Definition at line 1674 of file spa_misc.c.

void spa_l2cache_activate ( vdev_t vd)

Definition at line 845 of file spa_misc.c.

void spa_l2cache_add ( vdev_t vd)

Definition at line 813 of file spa_misc.c.

void spa_l2cache_drop ( spa_t spa)

Stop and drop level 2 ARC devices.

Definition at line 3324 of file spa.c.

boolean_t spa_l2cache_exists ( uint64_t  guid,
uint64_t *  pool 
)

Definition at line 833 of file spa_misc.c.

void spa_l2cache_remove ( vdev_t vd)

Definition at line 823 of file spa_misc.c.

uint64_t spa_last_synced_txg ( spa_t spa)

Definition at line 1385 of file spa_misc.c.

uint64_t spa_load_guid ( spa_t spa)

Definition at line 1374 of file spa_misc.c.

spa_load_state_t spa_load_state ( spa_t spa)

Definition at line 1409 of file spa_misc.c.

metaslab_class_t* spa_log_class ( spa_t spa)

Definition at line 1482 of file spa_misc.c.

void spa_log_error ( spa_t spa,
zio_t zio 
)

Log an uncorrectable error to the persistent error log.

We add it to the spa's list of pending errors. The changes are actually synced out to disk during spa_errlog_sync().

Definition at line 93 of file spa_errlog.c.

spa_t* spa_lookup ( const char *  name)

Lookup the named spa_t in the AVL tree.

The spa_namespace_lock must be held. Returns NULL if no matching spa_t is found.

Definition at line 379 of file spa_misc.c.

vdev_t* spa_lookup_by_guid ( spa_t spa,
uint64_t  guid,
boolean_t  l2cache 
)

Definition at line 6447 of file spa.c.

int spa_max_replication ( spa_t spa)

Definition at line 1488 of file spa_misc.c.

objset_t* spa_meta_objset ( spa_t spa)

Definition at line 1704 of file spa_misc.c.

int spa_mode ( spa_t spa)

Definition at line 1686 of file spa_misc.c.

char* spa_name ( spa_t spa)

Definition at line 1340 of file spa_misc.c.

spa_t* spa_next ( spa_t prev)

Find the next pool.

Given a pool, return the next pool in the namespace, or NULL if there is none. If 'prev' is NULL, return the first pool.

Definition at line 563 of file spa_misc.c.

metaslab_class_t* spa_normal_class ( spa_t spa)

Definition at line 1476 of file spa_misc.c.

int spa_offline_log ( spa_t spa)

Definition at line 1736 of file spa.c.

int spa_open ( const char *  pool,
spa_t **  ,
void *  tag 
)

Definition at line 2921 of file spa.c.

void spa_open_ref ( spa_t spa,
void *  tag 
)

Add a reference to the given spa_t.

Must have at least one reference, or have the namespace lock held.

Definition at line 584 of file spa_misc.c.

int spa_open_rewind ( const char *  pool,
spa_t **  ,
void *  tag,
nvlist_t *  policy,
nvlist_t **  config 
)

Definition at line 2914 of file spa.c.

int spa_prev_software_version ( spa_t spa)

Definition at line 1501 of file spa_misc.c.

void spa_prop_clear_bootfs ( spa_t spa,
uint64_t  obj,
dmu_tx_t tx 
)

If the bootfs property value is dsobj, clear it.

Definition at line 698 of file spa.c.

int spa_prop_get ( spa_t spa,
nvlist_t **  nvp 
)

Get zpool property values.

Definition at line 292 of file spa.c.

int spa_prop_set ( spa_t spa,
nvlist_t *  nvp 
)

Definition at line 637 of file spa.c.

boolean_t spa_refcount_zero ( spa_t spa)

Check to see if the spa refcount is zero.

Must be called with spa_namespace_lock held. We really compare against spa_minref, which is the number of references acquired when opening a pool

Definition at line 609 of file spa_misc.c.

void spa_remove ( spa_t spa)

Removes a spa_t from the namespace, freeing up any memory used.

Requires spa_namespace_lock. This is called only after the spa_t has been closed and deactivated.

Definition at line 501 of file spa_misc.c.

int spa_rename ( const char *  oldname,
const char *  newname 
)

Rename a spa_t.

Definition at line 1063 of file spa_misc.c.

int spa_reset ( char *  pool)

Reset a storage pool.

Similar to spa_export(), this unloads the spa_t without actually removing it from the namespace in any way.

Definition at line 4309 of file spa.c.

int spa_scan ( spa_t spa,
pool_scan_func_t  func 
)

Definition at line 5588 of file spa.c.

int spa_scan_get_stats ( spa_t spa,
pool_scan_stat_t *  ps 
)

Get scan stats for zpool status reports.

Definition at line 1731 of file spa_misc.c.

void spa_scan_stat_init ( spa_t spa)

Reset pool scan stat per scan pass (or reboot).

Definition at line 1719 of file spa_misc.c.

int spa_scan_stop ( spa_t spa)

Definition at line 5579 of file spa.c.

void spa_set_log_state ( spa_t spa,
spa_log_state_t  state 
)

Definition at line 1668 of file spa_misc.c.

void spa_set_rootblkptr ( spa_t spa,
const blkptr_t bp 
)

Definition at line 1319 of file spa_misc.c.

boolean_t spa_shutting_down ( spa_t spa)

Definition at line 1295 of file spa_misc.c.

void spa_spare_activate ( vdev_t vd)

Definition at line 789 of file spa_misc.c.

void spa_spare_add ( vdev_t vd)

Definition at line 757 of file spa_misc.c.

boolean_t spa_spare_exists ( uint64_t  guid,
uint64_t *  pool,
int *  refcnt 
)

Definition at line 777 of file spa_misc.c.

void spa_spare_remove ( vdev_t vd)

Definition at line 767 of file spa_misc.c.

pool_state_t spa_state ( spa_t spa)

Definition at line 1403 of file spa_misc.c.

char* spa_strdup ( const char *  )

Definition at line 1159 of file spa_misc.c.

void spa_strfree ( char *  )

Definition at line 1173 of file spa_misc.c.

boolean_t spa_suspended ( spa_t spa)

Definition at line 1458 of file spa_misc.c.

void spa_sync ( spa_t spa,
uint64_t  txg 
)

Sync the specified transaction group.

New blocks may be dirtied as part of the process, so we iterate until it converges.

Only for DMU use

Definition at line 6160 of file spa.c.

void spa_sync_allpools ( void  )

Sync all pools.

We don't want to hold the namespace lock across these operations, so we take a reference on the spa_t and drop the lock during the sync.

Definition at line 6389 of file spa.c.

int spa_sync_pass ( spa_t spa)

Definition at line 1334 of file spa_misc.c.

uint64_t spa_syncing_txg ( spa_t spa)

Definition at line 1397 of file spa_misc.c.

nvlist_t* spa_tryimport ( nvlist_t *  tryconfig)

Definition at line 4081 of file spa.c.

void spa_update_dspace ( spa_t spa)

Definition at line 1441 of file spa_misc.c.

void spa_upgrade ( spa_t spa,
uint64_t  version 
)

Definition at line 6473 of file spa.c.

int spa_vdev_add ( spa_t spa,
nvlist_t *  nvroot 
)

Add a device to a storage pool.

Definition at line 4325 of file spa.c.

int spa_vdev_attach ( spa_t spa,
uint64_t  guid,
nvlist_t *  nvroot,
int  replacing 
)

Attach a device to a mirror.

The arguments are the path to any device in the mirror, and the nvroot for the new device. If the path specifies a device that is not mirrored, we automatically insert the mirror vdev.

If 'replacing' is specified, the new device is intended to replace the existing device; in this case the two devices are made into their own mirror using the 'replacing' vdev, which is functionally identical to the mirror vdev (it actually reuses all the same ops) but has a few extra rules: you can't attach to it after it's been created, and upon completion of resilvering, the first disk (the one being replaced) is automatically detached.

Definition at line 4437 of file spa.c.

uint64_t spa_vdev_config_enter ( spa_t spa)

Internal implementation for spa_vdev_enter().

Used when a vdev operation requires multiple syncs (i.e. removing a device) while keeping the spa_namespace_lock held.

Definition at line 879 of file spa_misc.c.

void spa_vdev_config_exit ( spa_t spa,
vdev_t vd,
uint64_t  txg,
int  error,
char *  tag 
)

Used in combination with spa_vdev_config_enter() to allow the syncing of multiple transactions without releasing the spa_namespace_lock.

Definition at line 893 of file spa_misc.c.

int spa_vdev_detach ( spa_t spa,
uint64_t  guid,
uint64_t  pguid,
int  replace_done 
)

Detach a device from a mirror or replacing vdev.

If 'replace_done' is specified, only detach if the parent is a replacing vdev.

Definition at line 4637 of file spa.c.

uint64_t spa_vdev_enter ( spa_t spa)

Lock the given spa_t for the purpose of adding or removing a vdev.

Grabs the global spa_namespace_lock plus the spa config lock for writing. It returns the next transaction group for the spa_t.

Definition at line 866 of file spa_misc.c.

int spa_vdev_exit ( spa_t spa,
vdev_t vd,
uint64_t  txg,
int  error 
)

Unlock the spa_t after adding or removing a vdev.

Besides undoing the locking of spa_vdev_enter(), we also want make sure the transactions have synced to disk, and then update the global configuration cache with the new information.

Definition at line 958 of file spa_misc.c.

int spa_vdev_remove ( spa_t spa,
uint64_t  guid,
boolean_t  unspare 
)

Remove a device from the pool.

Removing a device from the vdev namespace requires several steps and can take a significant amount of time. As a result we use the spa_vdev_config_[enter/exit] functions which allow us to grab and release the spa_config_lock while still holding the namespace lock. During each step the configuration is synced out.

Currently, this supports removing only hot spares, slogs, and level 2 ARC devices.

Definition at line 5300 of file spa.c.

boolean_t spa_vdev_remove_active ( spa_t spa)
int spa_vdev_setfru ( spa_t spa,
uint64_t  guid,
const char *  newfru 
)

Definition at line 5567 of file spa.c.

int spa_vdev_setpath ( spa_t spa,
uint64_t  guid,
const char *  newpath 
)

Definition at line 5561 of file spa.c.

int spa_vdev_split_mirror ( spa_t spa,
char *  newname,
nvlist_t *  config,
nvlist_t *  props,
boolean_t  exp 
)

Split a set of devices from their mirrors, and create a new pool from them.

Definition at line 4875 of file spa.c.

void spa_vdev_state_enter ( spa_t spa,
int  oplock 
)

Lock the given spa_t for the purpose of changing vdev state.

Definition at line 971 of file spa_misc.c.

int spa_vdev_state_exit ( spa_t spa,
vdev_t vd,
int  error 
)

Definition at line 998 of file spa_misc.c.

uint64_t spa_version ( spa_t spa)

Definition at line 1464 of file spa_misc.c.

boolean_t spa_writeable ( spa_t spa)

Definition at line 1680 of file spa_misc.c.

void sprintf_blkptr ( char *  buf,
const blkptr_t bp 
)

Definition at line 1207 of file spa_misc.c.

void vdev_cache_stat_fini ( void  )

Definition at line 437 of file vdev_cache.c.

void vdev_cache_stat_init ( void  )

Definition at line 425 of file vdev_cache.c.

void zfs_ereport_post ( const char *  cls,
spa_t spa,
vdev_t vd,
zio_t zio,
uint64_t  stateoroffset,
uint64_t  length 
)

Definition at line 669 of file zfs_fm.c.

void zfs_post_autoreplace ( spa_t spa,
vdev_t vd 
)

The 'resource.fs.zfs.autoreplace' event is an internal signal that the pool has the 'autoreplace' property set, and therefore any broken vdevs will be handled by higher level logic, and no vdev fault should be generated.

Definition at line 856 of file zfs_fm.c.

void zfs_post_remove ( spa_t spa,
vdev_t vd 
)

The 'resource.fs.zfs.removed' event is an internal signal that the given vdev has been removed from the system.

This will cause the DE to ignore any recent I/O errors, inferring that they are due to the asynchronous device removal.

Definition at line 845 of file zfs_fm.c.

void zfs_post_state_change ( spa_t spa,
vdev_t vd 
)

The 'resource.fs.zfs.statechange' event is an internal signal that the given vdev has transitioned its state to DEGRADED or HEALTHY.

This will cause the retire agent to repair any outstanding fault management cases open because the device was not found (fault.fs.zfs.device).

Definition at line 868 of file zfs_fm.c.

uint64_t zfs_strtonum ( const char *  str,
char **  nptr 
)

This is a stripped-down version of strtoull, suitable only for converting lowercase hexadecimal numbers that don't overflow.

Definition at line 1262 of file spa_misc.c.


Variable Documentation

mode, e.g.

FREAD | FWRITE

Definition at line 218 of file spa_misc.c.

spa namespace global mutex

Definition at line 207 of file spa_misc.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines