Changeset View
Changeset View
Standalone View
Standalone View
sys/cddl/boot/zfs/zfsimpl.h
Show First 20 Lines • Show All 709 Lines • ▼ Show 20 Lines | |||||
#define ZPOOL_CONFIG_POOL_GUID "pool_guid" | #define ZPOOL_CONFIG_POOL_GUID "pool_guid" | ||||
#define ZPOOL_CONFIG_CREATE_TXG "create_txg" | #define ZPOOL_CONFIG_CREATE_TXG "create_txg" | ||||
#define ZPOOL_CONFIG_TOP_GUID "top_guid" | #define ZPOOL_CONFIG_TOP_GUID "top_guid" | ||||
#define ZPOOL_CONFIG_VDEV_TREE "vdev_tree" | #define ZPOOL_CONFIG_VDEV_TREE "vdev_tree" | ||||
#define ZPOOL_CONFIG_TYPE "type" | #define ZPOOL_CONFIG_TYPE "type" | ||||
#define ZPOOL_CONFIG_CHILDREN "children" | #define ZPOOL_CONFIG_CHILDREN "children" | ||||
#define ZPOOL_CONFIG_ID "id" | #define ZPOOL_CONFIG_ID "id" | ||||
#define ZPOOL_CONFIG_GUID "guid" | #define ZPOOL_CONFIG_GUID "guid" | ||||
#define ZPOOL_CONFIG_INDIRECT_OBJECT "com.delphix:indirect_object" | |||||
#define ZPOOL_CONFIG_INDIRECT_BIRTHS "com.delphix:indirect_births" | |||||
#define ZPOOL_CONFIG_PREV_INDIRECT_VDEV "com.delphix:prev_indirect_vdev" | |||||
#define ZPOOL_CONFIG_PATH "path" | #define ZPOOL_CONFIG_PATH "path" | ||||
#define ZPOOL_CONFIG_DEVID "devid" | #define ZPOOL_CONFIG_DEVID "devid" | ||||
#define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array" | #define ZPOOL_CONFIG_METASLAB_ARRAY "metaslab_array" | ||||
#define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift" | #define ZPOOL_CONFIG_METASLAB_SHIFT "metaslab_shift" | ||||
#define ZPOOL_CONFIG_ASHIFT "ashift" | #define ZPOOL_CONFIG_ASHIFT "ashift" | ||||
#define ZPOOL_CONFIG_ASIZE "asize" | #define ZPOOL_CONFIG_ASIZE "asize" | ||||
#define ZPOOL_CONFIG_DTL "DTL" | #define ZPOOL_CONFIG_DTL "DTL" | ||||
#define ZPOOL_CONFIG_STATS "stats" | #define ZPOOL_CONFIG_STATS "stats" | ||||
Show All 27 Lines | |||||
#define VDEV_TYPE_RAIDZ "raidz" | #define VDEV_TYPE_RAIDZ "raidz" | ||||
#define VDEV_TYPE_DISK "disk" | #define VDEV_TYPE_DISK "disk" | ||||
#define VDEV_TYPE_FILE "file" | #define VDEV_TYPE_FILE "file" | ||||
#define VDEV_TYPE_MISSING "missing" | #define VDEV_TYPE_MISSING "missing" | ||||
#define VDEV_TYPE_HOLE "hole" | #define VDEV_TYPE_HOLE "hole" | ||||
#define VDEV_TYPE_SPARE "spare" | #define VDEV_TYPE_SPARE "spare" | ||||
#define VDEV_TYPE_LOG "log" | #define VDEV_TYPE_LOG "log" | ||||
#define VDEV_TYPE_L2CACHE "l2cache" | #define VDEV_TYPE_L2CACHE "l2cache" | ||||
#define VDEV_TYPE_INDIRECT "indirect" | |||||
/* | /* | ||||
* This is needed in userland to report the minimum necessary device size. | * This is needed in userland to report the minimum necessary device size. | ||||
*/ | */ | ||||
#define SPA_MINDEVSIZE (64ULL << 20) | #define SPA_MINDEVSIZE (64ULL << 20) | ||||
/* | /* | ||||
* The location of the pool configuration repository, shared between kernel and | * The location of the pool configuration repository, shared between kernel and | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | |||||
#define DNODE_MUST_BE_ALLOCATED 1 | #define DNODE_MUST_BE_ALLOCATED 1 | ||||
#define DNODE_MUST_BE_FREE 2 | #define DNODE_MUST_BE_FREE 2 | ||||
/* | /* | ||||
* Fixed constants. | * Fixed constants. | ||||
*/ | */ | ||||
#define DNODE_SHIFT 9 /* 512 bytes */ | #define DNODE_SHIFT 9 /* 512 bytes */ | ||||
#define DN_MIN_INDBLKSHIFT 12 /* 4k */ | #define DN_MIN_INDBLKSHIFT 12 /* 4k */ | ||||
#define DN_MAX_INDBLKSHIFT 14 /* 16k */ | #define DN_MAX_INDBLKSHIFT 17 /* 128k */ | ||||
#define DNODE_BLOCK_SHIFT 14 /* 16k */ | #define DNODE_BLOCK_SHIFT 14 /* 16k */ | ||||
#define DNODE_CORE_SIZE 64 /* 64 bytes for dnode sans blkptrs */ | #define DNODE_CORE_SIZE 64 /* 64 bytes for dnode sans blkptrs */ | ||||
#define DN_MAX_OBJECT_SHIFT 48 /* 256 trillion (zfs_fid_t limit) */ | #define DN_MAX_OBJECT_SHIFT 48 /* 256 trillion (zfs_fid_t limit) */ | ||||
#define DN_MAX_OFFSET_SHIFT 64 /* 2^64 bytes in a dnode */ | #define DN_MAX_OFFSET_SHIFT 64 /* 2^64 bytes in a dnode */ | ||||
/* | /* | ||||
* Derived constants. | * Derived constants. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 350 Lines • ▼ Show 20 Lines | |||||
#define DMU_POOL_SYNC_BPLIST "sync_bplist" | #define DMU_POOL_SYNC_BPLIST "sync_bplist" | ||||
#define DMU_POOL_ERRLOG_SCRUB "errlog_scrub" | #define DMU_POOL_ERRLOG_SCRUB "errlog_scrub" | ||||
#define DMU_POOL_ERRLOG_LAST "errlog_last" | #define DMU_POOL_ERRLOG_LAST "errlog_last" | ||||
#define DMU_POOL_SPARES "spares" | #define DMU_POOL_SPARES "spares" | ||||
#define DMU_POOL_DEFLATE "deflate" | #define DMU_POOL_DEFLATE "deflate" | ||||
#define DMU_POOL_HISTORY "history" | #define DMU_POOL_HISTORY "history" | ||||
#define DMU_POOL_PROPS "pool_props" | #define DMU_POOL_PROPS "pool_props" | ||||
#define DMU_POOL_CHECKSUM_SALT "org.illumos:checksum_salt" | #define DMU_POOL_CHECKSUM_SALT "org.illumos:checksum_salt" | ||||
#define DMU_POOL_REMOVING "com.delphix:removing" | |||||
#define DMU_POOL_OBSOLETE_BPOBJ "com.delphix:obsolete_bpobj" | |||||
#define DMU_POOL_CONDENSING_INDIRECT "com.delphix:condensing_indirect" | |||||
#define ZAP_MAGIC 0x2F52AB2ABULL | #define ZAP_MAGIC 0x2F52AB2ABULL | ||||
#define FZAP_BLOCK_SHIFT(zap) ((zap)->zap_block_shift) | #define FZAP_BLOCK_SHIFT(zap) ((zap)->zap_block_shift) | ||||
#define ZAP_MAXCD (uint32_t)(-1) | #define ZAP_MAXCD (uint32_t)(-1) | ||||
#define ZAP_HASHBITS 28 | #define ZAP_HASHBITS 28 | ||||
#define MZAP_ENT_LEN 64 | #define MZAP_ENT_LEN 64 | ||||
▲ Show 20 Lines • Show All 297 Lines • ▼ Show 20 Lines | |||||
struct spa; | struct spa; | ||||
typedef int vdev_phys_read_t(struct vdev *vdev, void *priv, | typedef int vdev_phys_read_t(struct vdev *vdev, void *priv, | ||||
off_t offset, void *buf, size_t bytes); | off_t offset, void *buf, size_t bytes); | ||||
typedef int vdev_read_t(struct vdev *vdev, const blkptr_t *bp, | typedef int vdev_read_t(struct vdev *vdev, const blkptr_t *bp, | ||||
void *buf, off_t offset, size_t bytes); | void *buf, off_t offset, size_t bytes); | ||||
typedef STAILQ_HEAD(vdev_list, vdev) vdev_list_t; | typedef STAILQ_HEAD(vdev_list, vdev) vdev_list_t; | ||||
typedef struct vdev_indirect_mapping_entry_phys { | |||||
/* | |||||
* Decode with DVA_MAPPING_* macros. | |||||
* Contains: | |||||
* the source offset (low 63 bits) | |||||
* the one-bit "mark", used for garbage collection (by zdb) | |||||
*/ | |||||
uint64_t vimep_src; | |||||
/* | |||||
* Note: the DVA's asize is 24 bits, and can thus store ranges | |||||
* up to 8GB. | |||||
*/ | |||||
dva_t vimep_dst; | |||||
} vdev_indirect_mapping_entry_phys_t; | |||||
#define DVA_MAPPING_GET_SRC_OFFSET(vimep) \ | |||||
BF64_GET_SB((vimep)->vimep_src, 0, 63, SPA_MINBLOCKSHIFT, 0) | |||||
#define DVA_MAPPING_SET_SRC_OFFSET(vimep, x) \ | |||||
BF64_SET_SB((vimep)->vimep_src, 0, 63, SPA_MINBLOCKSHIFT, 0, x) | |||||
typedef struct vdev_indirect_mapping_entry { | |||||
vdev_indirect_mapping_entry_phys_t vime_mapping; | |||||
uint32_t vime_obsolete_count; | |||||
list_node_t vime_node; | |||||
} vdev_indirect_mapping_entry_t; | |||||
/* | |||||
* This is stored in the bonus buffer of the mapping object, see comment of | |||||
* vdev_indirect_config for more details. | |||||
*/ | |||||
typedef struct vdev_indirect_mapping_phys { | |||||
uint64_t vimp_max_offset; | |||||
uint64_t vimp_bytes_mapped; | |||||
uint64_t vimp_num_entries; /* number of v_i_m_entry_phys_t's */ | |||||
/* | |||||
* For each entry in the mapping object, this object contains an | |||||
* entry representing the number of bytes of that mapping entry | |||||
* that were no longer in use by the pool at the time this indirect | |||||
* vdev was last condensed. | |||||
*/ | |||||
uint64_t vimp_counts_object; | |||||
} vdev_indirect_mapping_phys_t; | |||||
#define VDEV_INDIRECT_MAPPING_SIZE_V0 (3 * sizeof (uint64_t)) | |||||
typedef struct vdev_indirect_mapping { | |||||
uint64_t vim_object; | |||||
boolean_t vim_havecounts; | |||||
/* vim_entries segment offset currently in memory. */ | |||||
uint64_t vim_entry_offset; | |||||
/* vim_entries segment size. */ | |||||
size_t vim_num_entries; | |||||
/* Needed by dnode_read() */ | |||||
const void *vim_spa; | |||||
dnode_phys_t *vim_dn; | |||||
/* | |||||
* An ordered array of mapping entries, sorted by source offset. | |||||
* Note that vim_entries is needed during a removal (and contains | |||||
* mappings that have been synced to disk so far) to handle frees | |||||
* from the removing device. | |||||
*/ | |||||
vdev_indirect_mapping_entry_phys_t *vim_entries; | |||||
objset_phys_t *vim_objset; | |||||
vdev_indirect_mapping_phys_t *vim_phys; | |||||
} vdev_indirect_mapping_t; | |||||
/* | |||||
* On-disk indirect vdev state. | |||||
* | |||||
* An indirect vdev is described exclusively in the MOS config of a pool. | |||||
* The config for an indirect vdev includes several fields, which are | |||||
* accessed in memory by a vdev_indirect_config_t. | |||||
*/ | |||||
typedef struct vdev_indirect_config { | |||||
/* | |||||
* Object (in MOS) which contains the indirect mapping. This object | |||||
* contains an array of vdev_indirect_mapping_entry_phys_t ordered by | |||||
* vimep_src. The bonus buffer for this object is a | |||||
* vdev_indirect_mapping_phys_t. This object is allocated when a vdev | |||||
* removal is initiated. | |||||
* | |||||
* Note that this object can be empty if none of the data on the vdev | |||||
* has been copied yet. | |||||
*/ | |||||
uint64_t vic_mapping_object; | |||||
/* | |||||
* Object (in MOS) which contains the birth times for the mapping | |||||
* entries. This object contains an array of | |||||
* vdev_indirect_birth_entry_phys_t sorted by vibe_offset. The bonus | |||||
* buffer for this object is a vdev_indirect_birth_phys_t. This object | |||||
* is allocated when a vdev removal is initiated. | |||||
* | |||||
* Note that this object can be empty if none of the vdev has yet been | |||||
* copied. | |||||
*/ | |||||
uint64_t vic_births_object; | |||||
/* | |||||
* This is the vdev ID which was removed previous to this vdev, or | |||||
* UINT64_MAX if there are no previously removed vdevs. | |||||
*/ | |||||
uint64_t vic_prev_indirect_vdev; | |||||
} vdev_indirect_config_t; | |||||
typedef struct vdev { | typedef struct vdev { | ||||
STAILQ_ENTRY(vdev) v_childlink; /* link in parent's child list */ | STAILQ_ENTRY(vdev) v_childlink; /* link in parent's child list */ | ||||
STAILQ_ENTRY(vdev) v_alllink; /* link in global vdev list */ | STAILQ_ENTRY(vdev) v_alllink; /* link in global vdev list */ | ||||
vdev_list_t v_children; /* children of this vdev */ | vdev_list_t v_children; /* children of this vdev */ | ||||
const char *v_name; /* vdev name */ | const char *v_name; /* vdev name */ | ||||
uint64_t v_guid; /* vdev guid */ | uint64_t v_guid; /* vdev guid */ | ||||
int v_id; /* index in parent */ | int v_id; /* index in parent */ | ||||
int v_ashift; /* offset to block shift */ | int v_ashift; /* offset to block shift */ | ||||
int v_nparity; /* # parity for raidz */ | int v_nparity; /* # parity for raidz */ | ||||
struct vdev *v_top; /* parent vdev */ | struct vdev *v_top; /* parent vdev */ | ||||
int v_nchildren; /* # children */ | int v_nchildren; /* # children */ | ||||
vdev_state_t v_state; /* current state */ | vdev_state_t v_state; /* current state */ | ||||
vdev_phys_read_t *v_phys_read; /* read from raw leaf vdev */ | vdev_phys_read_t *v_phys_read; /* read from raw leaf vdev */ | ||||
vdev_read_t *v_read; /* read from vdev */ | vdev_read_t *v_read; /* read from vdev */ | ||||
void *v_read_priv; /* private data for read function */ | void *v_read_priv; /* private data for read function */ | ||||
struct spa *spa; /* link to spa */ | struct spa *spa; /* link to spa */ | ||||
/* | |||||
* Values stored in the config for an indirect or removing vdev. | |||||
*/ | |||||
vdev_indirect_config_t vdev_indirect_config; | |||||
vdev_indirect_mapping_t *v_mapping; | |||||
} vdev_t; | } vdev_t; | ||||
/* | /* | ||||
* In-core pool representation. | * In-core pool representation. | ||||
*/ | */ | ||||
typedef STAILQ_HEAD(spa_list, spa) spa_list_t; | typedef STAILQ_HEAD(spa_list, spa) spa_list_t; | ||||
typedef struct spa { | typedef struct spa { | ||||
STAILQ_ENTRY(spa) spa_link; /* link in global pool list */ | STAILQ_ENTRY(spa) spa_link; /* link in global pool list */ | ||||
char *spa_name; /* pool name */ | char *spa_name; /* pool name */ | ||||
uint64_t spa_guid; /* pool guid */ | uint64_t spa_guid; /* pool guid */ | ||||
uint64_t spa_txg; /* most recent transaction */ | uint64_t spa_txg; /* most recent transaction */ | ||||
struct uberblock spa_uberblock; /* best uberblock so far */ | struct uberblock spa_uberblock; /* best uberblock so far */ | ||||
vdev_list_t spa_vdevs; /* list of all toplevel vdevs */ | vdev_list_t spa_vdevs; /* list of all toplevel vdevs */ | ||||
objset_phys_t spa_mos; /* MOS for this pool */ | objset_phys_t spa_mos; /* MOS for this pool */ | ||||
zio_cksum_salt_t spa_cksum_salt; /* secret salt for cksum */ | zio_cksum_salt_t spa_cksum_salt; /* secret salt for cksum */ | ||||
void *spa_cksum_tmpls[ZIO_CHECKSUM_FUNCTIONS]; | void *spa_cksum_tmpls[ZIO_CHECKSUM_FUNCTIONS]; | ||||
int spa_inited; /* initialized */ | int spa_inited; /* initialized */ | ||||
} spa_t; | } spa_t; | ||||
/* IO related arguments. */ | |||||
typedef struct zio { | |||||
spa_t *io_spa; | |||||
blkptr_t *io_bp; | |||||
void *io_data; | |||||
uint64_t io_size; | |||||
uint64_t io_offset; | |||||
/* Stuff for the vdev stack */ | |||||
vdev_t *io_vd; | |||||
void *io_vsd; | |||||
int io_error; | |||||
} zio_t; | |||||
static void decode_embedded_bp_compressed(const blkptr_t *, void *); | static void decode_embedded_bp_compressed(const blkptr_t *, void *); |