FreeBSD ZFS
The Zettabyte File System
Functions | Variables

space_map.c File Reference

Space map routines. More...

#include <sys/zfs_context.h>
#include <sys/spa.h>
#include <sys/dmu.h>
#include <sys/zio.h>
#include <sys/space_map.h>
Include dependency graph for space_map.c:

Go to the source code of this file.

Functions

 SYSCTL_DECL (_vfs_zfs)
 TUNABLE_INT ("vfs.zfs.space_map_last_hope",&space_map_last_hope)
 SYSCTL_INT (_vfs_zfs, OID_AUTO, space_map_last_hope, CTLFLAG_RDTUN,&space_map_last_hope, 0,"If kernel panic in space_map code on pool import, import the pool in readonly mode and backup all your data before trying this option.")
static int space_map_seg_compare (const void *x1, const void *x2)
void space_map_create (space_map_t *sm, uint64_t start, uint64_t size, uint8_t shift, kmutex_t *lp)
void space_map_destroy (space_map_t *sm)
void space_map_add (space_map_t *sm, uint64_t start, uint64_t size)
void space_map_remove (space_map_t *sm, uint64_t start, uint64_t size)
boolean_t space_map_contains (space_map_t *sm, uint64_t start, uint64_t size)
void space_map_vacate (space_map_t *sm, space_map_func_t *func, space_map_t *mdest)
void space_map_walk (space_map_t *sm, space_map_func_t *func, space_map_t *mdest)
void space_map_load_wait (space_map_t *sm)
 Wait for any in-progress space_map_load() to complete.
int space_map_load (space_map_t *sm, space_map_ops_t *ops, uint8_t maptype, space_map_obj_t *smo, objset_t *os)
 Note: space_map_load() will drop sm_lock across dmu_read() calls.
void space_map_unload (space_map_t *sm)
uint64_t space_map_maxsize (space_map_t *sm)
uint64_t space_map_alloc (space_map_t *sm, uint64_t size)
void space_map_claim (space_map_t *sm, uint64_t start, uint64_t size)
void space_map_free (space_map_t *sm, uint64_t start, uint64_t size)
void space_map_sync (space_map_t *sm, uint8_t maptype, space_map_obj_t *smo, objset_t *os, dmu_tx_t *tx)
 Note: space_map_sync() will drop sm_lock across dmu_write() calls.
void space_map_truncate (space_map_obj_t *smo, objset_t *os, dmu_tx_t *tx)
static int space_map_ref_compare (const void *x1, const void *x2)
 Space map reference trees.
void space_map_ref_create (avl_tree_t *t)
void space_map_ref_destroy (avl_tree_t *t)
static void space_map_ref_add_node (avl_tree_t *t, uint64_t offset, int64_t refcnt)
void space_map_ref_add_seg (avl_tree_t *t, uint64_t start, uint64_t end, int64_t refcnt)
void space_map_ref_add_map (avl_tree_t *t, space_map_t *sm, int64_t refcnt)
 Convert (or add) a space map into a reference tree.
void space_map_ref_generate_map (avl_tree_t *t, space_map_t *sm, int64_t minref)
 Convert a reference tree into a space map.

Variables

static int space_map_last_hope

Detailed Description

Space map routines.

Note:
Caller is responsible for all locking.

Definition in file space_map.c.


Function Documentation

void space_map_add ( space_map_t sm,
uint64_t  start,
uint64_t  size 
)

Definition at line 94 of file space_map.c.

uint64_t space_map_alloc ( space_map_t sm,
uint64_t  size 
)

Definition at line 403 of file space_map.c.

void space_map_claim ( space_map_t sm,
uint64_t  start,
uint64_t  size 
)

Definition at line 414 of file space_map.c.

boolean_t space_map_contains ( space_map_t sm,
uint64_t  start,
uint64_t  size 
)

Definition at line 236 of file space_map.c.

void space_map_create ( space_map_t sm,
uint64_t  start,
uint64_t  size,
uint8_t  shift,
kmutex_t *  lp 
)

Definition at line 68 of file space_map.c.

void space_map_destroy ( space_map_t sm)

Definition at line 85 of file space_map.c.

void space_map_free ( space_map_t sm,
uint64_t  start,
uint64_t  size 
)

Definition at line 421 of file space_map.c.

int space_map_load ( space_map_t sm,
space_map_ops_t ops,
uint8_t  maptype,
space_map_obj_t smo,
objset_t os 
)

Note: space_map_load() will drop sm_lock across dmu_read() calls.

The caller must be OK with this.

Definition at line 300 of file space_map.c.

void space_map_load_wait ( space_map_t sm)

Wait for any in-progress space_map_load() to complete.

Definition at line 285 of file space_map.c.

uint64_t space_map_maxsize ( space_map_t sm)

Definition at line 396 of file space_map.c.

void space_map_ref_add_map ( avl_tree_t *  t,
space_map_t sm,
int64_t  refcnt 
)

Convert (or add) a space map into a reference tree.

Definition at line 601 of file space_map.c.

static void space_map_ref_add_node ( avl_tree_t *  t,
uint64_t  offset,
int64_t  refcnt 
) [static]

Definition at line 578 of file space_map.c.

void space_map_ref_add_seg ( avl_tree_t *  t,
uint64_t  start,
uint64_t  end,
int64_t  refcnt 
)

Definition at line 590 of file space_map.c.

static int space_map_ref_compare ( const void *  x1,
const void *  x2 
) [static]

Space map reference trees.

A space map is a collection of integers. Every integer is either in the map, or it's not. A space map reference tree generalizes the idea: it allows its members to have arbitrary reference counts, as opposed to the implicit reference count of 0 or 1 in a space map. This representation comes in handy when computing the union or intersection of multiple space maps. For example, the union of N space maps is the subset of the reference tree with refcnt >= 1. The intersection of N space maps is the subset with refcnt >= N.

[It's very much like a Fourier transform. Unions and intersections are hard to perform in the 'space map domain', so we convert the maps into the 'reference count domain', where it's trivial, then invert.]

vdev_dtl_reassess() uses computations of this form to determine DTL_MISSING and DTL_OUTAGE for interior vdevs -- e.g. a RAID-Z vdev has an outage wherever refcnt >= vdev_nparity + 1, and a mirror vdev has an outage wherever refcnt >= vdev_children.

Definition at line 540 of file space_map.c.

void space_map_ref_create ( avl_tree_t *  t)

Definition at line 559 of file space_map.c.

void space_map_ref_destroy ( avl_tree_t *  t)

Definition at line 566 of file space_map.c.

void space_map_ref_generate_map ( avl_tree_t *  t,
space_map_t sm,
int64_t  minref 
)

Convert a reference tree into a space map.

The space map will contain all members of the reference tree for which refcnt >= minref.

Definition at line 616 of file space_map.c.

void space_map_remove ( space_map_t sm,
uint64_t  start,
uint64_t  size 
)

Definition at line 179 of file space_map.c.

static int space_map_seg_compare ( const void *  x1,
const void *  x2 
) [static]

Definition at line 49 of file space_map.c.

void space_map_sync ( space_map_t sm,
uint8_t  maptype,
space_map_obj_t smo,
objset_t os,
dmu_tx_t tx 
)

Note: space_map_sync() will drop sm_lock across dmu_write() calls.

Definition at line 431 of file space_map.c.

void space_map_truncate ( space_map_obj_t smo,
objset_t os,
dmu_tx_t tx 
)

Definition at line 510 of file space_map.c.

void space_map_unload ( space_map_t sm)

Definition at line 382 of file space_map.c.

void space_map_vacate ( space_map_t sm,
space_map_func_t func,
space_map_t mdest 
)

Definition at line 255 of file space_map.c.

void space_map_walk ( space_map_t sm,
space_map_func_t func,
space_map_t mdest 
)

Definition at line 271 of file space_map.c.

SYSCTL_DECL ( _vfs_zfs  )
SYSCTL_INT ( _vfs_zfs  ,
OID_AUTO  ,
space_map_last_hope  ,
CTLFLAG_RDTUN  ,
space_map_last_hope,
,
"If kernel panic in space_map code on pool  import,
import the pool in readonly mode and backup all your data before trying this option."   
)
TUNABLE_INT ( "vfs.zfs.space_map_last_hope"  ,
space_map_last_hope 
)

Variable Documentation

int space_map_last_hope [static]

Definition at line 36 of file space_map.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines