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

sys/vdev_impl.h File Reference

Virtual device descriptors. More...

#include <sys/avl.h>
#include <sys/dmu.h>
#include <sys/metaslab.h>
#include <sys/nvpair.h>
#include <sys/space_map.h>
#include <sys/vdev.h>
#include <sys/dkio.h>
#include <sys/uberblock_impl.h>
#include <sys/metaslab.h>
#include <sys/uberblock_impl.h>
Include dependency graph for vdev_impl.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  vdev_ops
struct  vdev_cache_entry
struct  vdev_cache
struct  vdev_queue
 A virtual device property. More...
struct  vdev
 Virtual device descriptor. More...
struct  vdev_phys
struct  vdev_label

Defines

#define VDEV_RAIDZ_MAXPARITY   3
#define VDEV_PAD_SIZE   (8 << 10)
#define VDEV_SKIP_SIZE   VDEV_PAD_SIZE * 2
 2 padding areas (vl_pad1 and vl_pad2) to skip
#define VDEV_PHYS_SIZE   (112 << 10)
#define VDEV_UBERBLOCK_RING   (128 << 10)
#define VDEV_UBERBLOCK_SHIFT(vd)   MAX((vd)->vdev_top->vdev_ashift, UBERBLOCK_SHIFT)
#define VDEV_UBERBLOCK_COUNT(vd)   (VDEV_UBERBLOCK_RING >> VDEV_UBERBLOCK_SHIFT(vd))
#define VDEV_UBERBLOCK_OFFSET(vd, n)   offsetof(vdev_label_t, vl_uberblock[(n) << VDEV_UBERBLOCK_SHIFT(vd)])
#define VDEV_UBERBLOCK_SIZE(vd)   (1ULL << VDEV_UBERBLOCK_SHIFT(vd))
#define VDD_METASLAB   0x01
 vdev_dirty() flags
#define VDD_DTL   0x02
#define VDEV_BOOT_OFFSET   (2 * sizeof (vdev_label_t))
 Offset of embedded boot loader region on each label.
#define VDEV_BOOT_SIZE   (7ULL << 19)
 Size of embedded boot loader region on each label.
#define VDEV_LABEL_START_SIZE   (2 * sizeof (vdev_label_t) + VDEV_BOOT_SIZE)
#define VDEV_LABEL_END_SIZE   (2 * sizeof (vdev_label_t))
#define VDEV_LABELS   4
#define VDEV_BEST_LABEL   VDEV_LABELS
#define VDEV_ALLOC_LOAD   0
#define VDEV_ALLOC_ADD   1
#define VDEV_ALLOC_SPARE   2
#define VDEV_ALLOC_L2CACHE   3
#define VDEV_ALLOC_ROOTPOOL   4
#define VDEV_ALLOC_SPLIT   5
#define VDEV_ALLOC_ATTACH   6

Typedefs

typedef struct vdev_queue vdev_queue_t
typedef struct vdev_cache vdev_cache_t
typedef struct vdev_cache_entry vdev_cache_entry_t
typedef struct vdev_ops vdev_ops_t
typedef struct vdev_phys vdev_phys_t
typedef struct vdev_label vdev_label_t
VDev Operation types

typedefs used only for vdev_ops table

typedef int vdev_open_func_t (vdev_t *vd, uint64_t *size, uint64_t *max_size, uint64_t *ashift)
typedef void vdev_close_func_t (vdev_t *vd)
typedef uint64_t vdev_asize_func_t (vdev_t *vd, uint64_t psize)
typedef int vdev_io_start_func_t (zio_t *zio)
typedef void vdev_io_done_func_t (zio_t *zio)
typedef void vdev_state_change_func_t (vdev_t *vd, int, int)
typedef void vdev_hold_func_t (vdev_t *vd)
typedef void vdev_rele_func_t (vdev_t *vd)

Functions

vdev_tvdev_alloc_common (spa_t *spa, uint_t id, uint64_t guid, vdev_ops_t *ops)
 Allocate and minimally initialize a vdev_t.
int vdev_alloc (spa_t *spa, vdev_t **vdp, nvlist_t *config, vdev_t *parent, uint_t id, int alloctype)
 Allocate a new vdev.
void vdev_free (vdev_t *vd)
void vdev_add_child (vdev_t *pvd, vdev_t *cvd)
void vdev_remove_child (vdev_t *pvd, vdev_t *cvd)
void vdev_compact_children (vdev_t *pvd)
 Remove any holes in the child array.
vdev_tvdev_add_parent (vdev_t *cvd, vdev_ops_t *ops)
 Add a mirror/replacing vdev above an existing vdev.
void vdev_remove_parent (vdev_t *cvd)
 Remove a 1-way mirror/replacing vdev from the tree.
void vdev_load_log_state (vdev_t *nvd, vdev_t *ovd)
 Load the state from the original vdev tree (ovd) which we've retrieved from the MOS config object.
boolean_t vdev_log_state_valid (vdev_t *vd)
 Determine if a log device has valid content.
void vdev_load (vdev_t *vd)
void vdev_sync (vdev_t *vd, uint64_t txg)
void vdev_sync_done (vdev_t *vd, uint64_t txg)
void vdev_dirty (vdev_t *vd, int flags, void *arg, uint64_t txg)
uint64_t vdev_default_asize (vdev_t *vd, uint64_t psize)
 Default asize function.
uint64_t vdev_get_min_asize (vdev_t *vd)
 Get the minimum allocatable size.
void vdev_set_min_asize (vdev_t *vd)

Variables

vdev_ops_t vdev_root_ops
vdev_ops_t vdev_mirror_ops
vdev_ops_t vdev_replacing_ops
vdev_ops_t vdev_raidz_ops
vdev_ops_t vdev_geom_ops
 Vector table for the vdev_geom module.
vdev_ops_t vdev_file_ops
vdev_ops_t vdev_missing_ops
vdev_ops_t vdev_hole_ops
vdev_ops_t vdev_spare_ops
int zfs_vdev_cache_size

Detailed Description

Virtual device descriptors.

All storage pool operations go through the virtual device framework, which provides data replication and I/O scheduling.

Definition in file vdev_impl.h.


Define Documentation

#define VDD_DTL   0x02

Definition at line 267 of file vdev_impl.h.

#define VDD_METASLAB   0x01

vdev_dirty() flags

Definition at line 266 of file vdev_impl.h.

#define VDEV_ALLOC_ADD   1

Definition at line 286 of file vdev_impl.h.

#define VDEV_ALLOC_ATTACH   6

Definition at line 291 of file vdev_impl.h.

#define VDEV_ALLOC_L2CACHE   3

Definition at line 288 of file vdev_impl.h.

#define VDEV_ALLOC_LOAD   0

Definition at line 285 of file vdev_impl.h.

#define VDEV_ALLOC_ROOTPOOL   4

Definition at line 289 of file vdev_impl.h.

#define VDEV_ALLOC_SPARE   2

Definition at line 287 of file vdev_impl.h.

#define VDEV_ALLOC_SPLIT   5

Definition at line 290 of file vdev_impl.h.

#define VDEV_BEST_LABEL   VDEV_LABELS

Definition at line 283 of file vdev_impl.h.

#define VDEV_BOOT_OFFSET   (2 * sizeof (vdev_label_t))

Offset of embedded boot loader region on each label.

Definition at line 270 of file vdev_impl.h.

#define VDEV_BOOT_SIZE   (7ULL << 19)

Size of embedded boot loader region on each label.

The total size of the first two labels plus the boot area is 4MB.

Definition at line 275 of file vdev_impl.h.

#define VDEV_LABEL_END_SIZE   (2 * sizeof (vdev_label_t))

Definition at line 281 of file vdev_impl.h.

#define VDEV_LABEL_START_SIZE   (2 * sizeof (vdev_label_t) + VDEV_BOOT_SIZE)

Definition at line 280 of file vdev_impl.h.

#define VDEV_LABELS   4

Definition at line 282 of file vdev_impl.h.

#define VDEV_PAD_SIZE   (8 << 10)

Definition at line 236 of file vdev_impl.h.

#define VDEV_PHYS_SIZE   (112 << 10)

Definition at line 239 of file vdev_impl.h.

#define VDEV_RAIDZ_MAXPARITY   3

Definition at line 234 of file vdev_impl.h.

#define VDEV_SKIP_SIZE   VDEV_PAD_SIZE * 2

2 padding areas (vl_pad1 and vl_pad2) to skip

Definition at line 238 of file vdev_impl.h.

#define VDEV_UBERBLOCK_COUNT (   vd)    (VDEV_UBERBLOCK_RING >> VDEV_UBERBLOCK_SHIFT(vd))

Definition at line 244 of file vdev_impl.h.

#define VDEV_UBERBLOCK_OFFSET (   vd,
 
)    offsetof(vdev_label_t, vl_uberblock[(n) << VDEV_UBERBLOCK_SHIFT(vd)])

Definition at line 246 of file vdev_impl.h.

#define VDEV_UBERBLOCK_RING   (128 << 10)

Definition at line 240 of file vdev_impl.h.

#define VDEV_UBERBLOCK_SHIFT (   vd)    MAX((vd)->vdev_top->vdev_ashift, UBERBLOCK_SHIFT)

Definition at line 242 of file vdev_impl.h.

#define VDEV_UBERBLOCK_SIZE (   vd)    (1ULL << VDEV_UBERBLOCK_SHIFT(vd))

Definition at line 248 of file vdev_impl.h.


Typedef Documentation

typedef uint64_t vdev_asize_func_t(vdev_t *vd, uint64_t psize)

Definition at line 65 of file vdev_impl.h.

Definition at line 55 of file vdev_impl.h.

typedef struct vdev_cache vdev_cache_t

Definition at line 54 of file vdev_impl.h.

typedef void vdev_close_func_t(vdev_t *vd)

Definition at line 64 of file vdev_impl.h.

typedef void vdev_hold_func_t(vdev_t *vd)

Definition at line 69 of file vdev_impl.h.

typedef void vdev_io_done_func_t(zio_t *zio)

Definition at line 67 of file vdev_impl.h.

Definition at line 66 of file vdev_impl.h.

typedef struct vdev_label vdev_label_t
Note:
256K total size
typedef int vdev_open_func_t(vdev_t *vd, uint64_t *size, uint64_t *max_size, uint64_t *ashift)

Definition at line 62 of file vdev_impl.h.

typedef struct vdev_ops vdev_ops_t
typedef struct vdev_phys vdev_phys_t
typedef struct vdev_queue vdev_queue_t

Definition at line 53 of file vdev_impl.h.

typedef void vdev_rele_func_t(vdev_t *vd)

Definition at line 70 of file vdev_impl.h.

typedef void vdev_state_change_func_t(vdev_t *vd, int, int)

Definition at line 68 of file vdev_impl.h.


Function Documentation

void vdev_add_child ( vdev_t pvd,
vdev_t cvd 
)

Definition at line 183 of file vdev.c.

vdev_t* vdev_add_parent ( vdev_t cvd,
vdev_ops_t ops 
)

Add a mirror/replacing vdev above an existing vdev.

Definition at line 736 of file vdev.c.

int vdev_alloc ( spa_t spa,
vdev_t **  vdp,
nvlist_t *  nv,
vdev_t parent,
uint_t  id,
int  alloctype 
)

Allocate a new vdev.

The 'alloctype' is used to control whether we are creating a new vdev or loading an existing one - the behavior is slightly different for each case.

Definition at line 350 of file vdev.c.

vdev_t* vdev_alloc_common ( spa_t spa,
uint_t  id,
uint64_t  guid,
vdev_ops_t ops 
)

Allocate and minimally initialize a vdev_t.

Definition at line 290 of file vdev.c.

void vdev_compact_children ( vdev_t pvd)

Remove any holes in the child array.

Definition at line 260 of file vdev.c.

uint64_t vdev_default_asize ( vdev_t vd,
uint64_t  psize 
)

Default asize function.

Return the MAX of psize with the asize of all children. This is what's used by anything other than RAID-Z.

Definition at line 94 of file vdev.c.

void vdev_dirty ( vdev_t vd,
int  flags,
void *  arg,
uint64_t  txg 
)

Definition at line 1579 of file vdev.c.

void vdev_free ( vdev_t vd)

Definition at line 573 of file vdev.c.

uint64_t vdev_get_min_asize ( vdev_t vd)

Get the minimum allocatable size.

We define the allocatable size as the vdev's asize rounded to the nearest metaslab. This allows us to replace or attach devices which don't have the same physical size but can still satisfy the same number of allocations.

Definition at line 114 of file vdev.c.

void vdev_load ( vdev_t vd)

Definition at line 1947 of file vdev.c.

void vdev_load_log_state ( vdev_t nvd,
vdev_t ovd 
)

Load the state from the original vdev tree (ovd) which we've retrieved from the MOS config object.

If the original vdev was offline or faulted then we transfer that state to the device in the current vdev tree (nvd).

Definition at line 3109 of file vdev.c.

boolean_t vdev_log_state_valid ( vdev_t vd)

Determine if a log device has valid content.

If the vdev was removed or faulted in the MOS config then we know that the content on the log device has already been written to the pool.

Definition at line 3137 of file vdev.c.

void vdev_remove_child ( vdev_t pvd,
vdev_t cvd 
)

Definition at line 223 of file vdev.c.

void vdev_remove_parent ( vdev_t cvd)

Remove a 1-way mirror/replacing vdev from the tree.

Definition at line 769 of file vdev.c.

void vdev_set_min_asize ( vdev_t vd)

Definition at line 143 of file vdev.c.

void vdev_sync ( vdev_t vd,
uint64_t  txg 
)

Definition at line 2066 of file vdev.c.

void vdev_sync_done ( vdev_t vd,
uint64_t  txg 
)

Definition at line 2051 of file vdev.c.


Variable Documentation

Definition at line 200 of file vdev_file.c.

Vector table for the vdev_geom module.

This is the only entry point for vdev_geom

Definition at line 923 of file vdev_geom.c.

Definition at line 98 of file vdev_missing.c.

Definition at line 458 of file vdev_mirror.c.

Definition at line 85 of file vdev_missing.c.

Definition at line 2224 of file vdev_raidz.c.

Definition at line 471 of file vdev_mirror.c.

Definition at line 112 of file vdev_root.c.

Definition at line 484 of file vdev_mirror.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines