FreeBSD ZFS
The Zettabyte File System
|
#include <sys/zfs_context.h>
#include <sys/dmu.h>
#include <sys/dmu_tx.h>
#include <sys/space_map.h>
#include <sys/metaslab_impl.h>
#include <sys/vdev_impl.h>
#include <sys/zio.h>
Go to the source code of this file.
Defines | |
#define | CAN_FASTGANG(flags) |
Allow allocations to switch to gang blocks quickly. | |
#define | METASLAB_WEIGHT_PRIMARY (1ULL << 63) |
#define | METASLAB_WEIGHT_SECONDARY (1ULL << 62) |
#define | METASLAB_ACTIVE_MASK (METASLAB_WEIGHT_PRIMARY | METASLAB_WEIGHT_SECONDARY) |
Functions | |
SYSCTL_DECL (_vfs_zfs) | |
SYSCTL_INT (_vfs_zfs, OID_AUTO, mg_alloc_failures, CTLFLAG_RDTUN,&zfs_mg_alloc_failures, 0,"Number of allowed allocation failures per vdev") | |
TUNABLE_INT ("vfs.zfs.mg_alloc_failures",&zfs_mg_alloc_failures) | |
metaslab_class_t * | metaslab_class_create (spa_t *spa, space_map_ops_t *ops) |
void | metaslab_class_destroy (metaslab_class_t *mc) |
int | metaslab_class_validate (metaslab_class_t *mc) |
void | metaslab_class_space_update (metaslab_class_t *mc, int64_t alloc_delta, int64_t defer_delta, int64_t space_delta, int64_t dspace_delta) |
uint64_t | metaslab_class_get_alloc (metaslab_class_t *mc) |
uint64_t | metaslab_class_get_deferred (metaslab_class_t *mc) |
uint64_t | metaslab_class_get_space (metaslab_class_t *mc) |
uint64_t | metaslab_class_get_dspace (metaslab_class_t *mc) |
static int | metaslab_compare (const void *x1, const void *x2) |
metaslab_group_t * | metaslab_group_create (metaslab_class_t *mc, vdev_t *vd) |
void | metaslab_group_destroy (metaslab_group_t *mg) |
void | metaslab_group_activate (metaslab_group_t *mg) |
void | metaslab_group_passivate (metaslab_group_t *mg) |
static void | metaslab_group_add (metaslab_group_t *mg, metaslab_t *msp) |
static void | metaslab_group_remove (metaslab_group_t *mg, metaslab_t *msp) |
static void | metaslab_group_sort (metaslab_group_t *mg, metaslab_t *msp, uint64_t weight) |
static int | metaslab_segsize_compare (const void *x1, const void *x2) |
static uint64_t | metaslab_block_picker (avl_tree_t *t, uint64_t *cursor, uint64_t size, uint64_t align) |
This is a helper function that can be used by the allocator to find a suitable block to allocate. | |
static void | metaslab_pp_load (space_map_t *sm) |
static void | metaslab_pp_unload (space_map_t *sm) |
static void | metaslab_pp_claim (space_map_t *sm, uint64_t start, uint64_t size) |
static void | metaslab_pp_free (space_map_t *sm, uint64_t start, uint64_t size) |
uint64_t | metaslab_pp_maxsize (space_map_t *sm) |
Return the maximum contiguous segment within the metaslab. | |
static uint64_t | metaslab_ff_alloc (space_map_t *sm, uint64_t size) |
boolean_t | metaslab_ff_fragmented (space_map_t *sm) |
static uint64_t | metaslab_df_alloc (space_map_t *sm, uint64_t size) |
static boolean_t | metaslab_df_fragmented (space_map_t *sm) |
static uint64_t | metaslab_cdf_alloc (space_map_t *sm, uint64_t size) |
static boolean_t | metaslab_cdf_fragmented (space_map_t *sm) |
static uint64_t | metaslab_ndf_alloc (space_map_t *sm, uint64_t size) |
static boolean_t | metaslab_ndf_fragmented (space_map_t *sm) |
metaslab_t * | metaslab_init (metaslab_group_t *mg, space_map_obj_t *smo, uint64_t start, uint64_t size, uint64_t txg) |
void | metaslab_fini (metaslab_t *msp) |
static uint64_t | metaslab_weight (metaslab_t *msp) |
static void | metaslab_prefetch (metaslab_group_t *mg) |
static int | metaslab_activate (metaslab_t *msp, uint64_t activation_weight) |
static void | metaslab_passivate (metaslab_t *msp, uint64_t size) |
void | metaslab_sync (metaslab_t *msp, uint64_t txg) |
Write a metaslab to disk in the context of the specified transaction group. | |
void | metaslab_sync_done (metaslab_t *msp, uint64_t txg) |
Called after a transaction group has completely synced to mark all of the metaslab's free space as usable. | |
void | metaslab_sync_reassess (metaslab_group_t *mg) |
static uint64_t | metaslab_distance (metaslab_t *msp, dva_t *dva) |
static uint64_t | metaslab_group_alloc (metaslab_group_t *mg, uint64_t psize, uint64_t asize, uint64_t txg, uint64_t min_distance, dva_t *dva, int d, int flags) |
static int | metaslab_alloc_dva (spa_t *spa, metaslab_class_t *mc, uint64_t psize, dva_t *dva, int d, dva_t *hintdva, uint64_t txg, int flags) |
Allocate a block for the specified i/o. | |
static void | metaslab_free_dva (spa_t *spa, const dva_t *dva, uint64_t txg, boolean_t now) |
Free the block represented by DVA in the context of the specified transaction group. | |
static int | metaslab_claim_dva (spa_t *spa, const dva_t *dva, uint64_t txg) |
Intent log support: upon opening the pool after a crash, notify the SPA of blocks that the intent log has allocated for immediate write, but which are still considered free by the SPA because the last transaction group didn't commit yet. | |
int | metaslab_alloc (spa_t *spa, metaslab_class_t *mc, uint64_t psize, blkptr_t *bp, int ndvas, uint64_t txg, blkptr_t *hintbp, int flags) |
void | metaslab_free (spa_t *spa, const blkptr_t *bp, uint64_t txg, boolean_t now) |
int | metaslab_claim (spa_t *spa, const blkptr_t *bp, uint64_t txg) |
Variables | |
uint64_t | metaslab_aliquot = 512ULL << 10 |
uint64_t | metaslab_gang_bang = SPA_MAXBLOCKSIZE + 1 |
int | zfs_mg_alloc_failures = 0 |
This value defines the number of allowed allocation failures per vdev. | |
static int | metaslab_debug = 0 |
Metaslab debugging: when set, keeps all space maps in core to verify frees. | |
uint64_t | metaslab_df_alloc_threshold = SPA_MAXBLOCKSIZE |
Minimum size which forces the dynamic allocator to change it's allocation strategy. | |
int | metaslab_df_free_pct = 4 |
The minimum free space, in percent, which must be available in a space map to continue allocations in a first-fit fashion. | |
uint64_t | metaslab_min_alloc_size = DMU_MAX_ACCESS |
A metaslab is considered "free" if it contains a contiguous segment which is greater than metaslab_min_alloc_size. | |
int | metaslab_prefetch_limit = SPA_DVAS_PER_BP |
Max number of space_maps to prefetch. | |
int | metaslab_smo_bonus_pct = 150 |
Percentage bonus multiplier for metaslabs that are in the bonus area. | |
static space_map_ops_t | metaslab_ff_ops |
static space_map_ops_t | metaslab_df_ops |
static space_map_ops_t | metaslab_cdf_ops |
uint64_t | metaslab_ndf_clump_shift = 4 |
static space_map_ops_t | metaslab_ndf_ops |
space_map_ops_t * | zfs_metaslab_ops = &metaslab_df_ops |
#define CAN_FASTGANG | ( | flags | ) |
(!((flags) & (METASLAB_GANG_CHILD | METASLAB_GANG_HEADER | \ METASLAB_GANG_AVOID)))
Allow allocations to switch to gang blocks quickly.
We do this to avoid having to load lots of space_maps in a given txg. There are, however, some cases where we want to avoid "fast" ganging and instead we want to do an exhaustive search of all metaslabs on this device. Currently we don't allow any gang, zil, or dump device related allocations to "fast" gang.
Definition at line 42 of file metaslab.c.
#define METASLAB_ACTIVE_MASK (METASLAB_WEIGHT_PRIMARY | METASLAB_WEIGHT_SECONDARY) |
Definition at line 791 of file metaslab.c.
#define METASLAB_WEIGHT_PRIMARY (1ULL << 63) |
Definition at line 789 of file metaslab.c.
#define METASLAB_WEIGHT_SECONDARY (1ULL << 62) |
Definition at line 790 of file metaslab.c.
static int metaslab_activate | ( | metaslab_t * | msp, |
uint64_t | activation_weight | ||
) | [static] |
Definition at line 876 of file metaslab.c.
int metaslab_alloc | ( | spa_t * | spa, |
metaslab_class_t * | mc, | ||
uint64_t | psize, | ||
blkptr_t * | bp, | ||
int | ndvas, | ||
uint64_t | txg, | ||
blkptr_t * | hintbp, | ||
int | flags | ||
) |
Definition at line 1575 of file metaslab.c.
static int metaslab_alloc_dva | ( | spa_t * | spa, |
metaslab_class_t * | mc, | ||
uint64_t | psize, | ||
dva_t * | dva, | ||
int | d, | ||
dva_t * | hintdva, | ||
uint64_t | txg, | ||
int | flags | ||
) | [static] |
Allocate a block for the specified i/o.
Definition at line 1291 of file metaslab.c.
static uint64_t metaslab_block_picker | ( | avl_tree_t * | t, |
uint64_t * | cursor, | ||
uint64_t | size, | ||
uint64_t | align | ||
) | [static] |
This is a helper function that can be used by the allocator to find a suitable block to allocate.
This will search the specified AVL tree looking for a block that matches the specified criteria.
Definition at line 387 of file metaslab.c.
static uint64_t metaslab_cdf_alloc | ( | space_map_t * | sm, |
uint64_t | size | ||
) | [static] |
Definition at line 581 of file metaslab.c.
static boolean_t metaslab_cdf_fragmented | ( | space_map_t * | sm | ) | [static] |
Definition at line 620 of file metaslab.c.
Definition at line 1636 of file metaslab.c.
Intent log support: upon opening the pool after a crash, notify the SPA of blocks that the intent log has allocated for immediate write, but which are still considered free by the SPA because the last transaction group didn't commit yet.
Definition at line 1528 of file metaslab.c.
metaslab_class_t* metaslab_class_create | ( | spa_t * | spa, |
space_map_ops_t * | ops | ||
) |
Definition at line 107 of file metaslab.c.
void metaslab_class_destroy | ( | metaslab_class_t * | mc | ) |
Definition at line 121 of file metaslab.c.
uint64_t metaslab_class_get_alloc | ( | metaslab_class_t * | mc | ) |
Definition at line 169 of file metaslab.c.
uint64_t metaslab_class_get_deferred | ( | metaslab_class_t * | mc | ) |
Definition at line 175 of file metaslab.c.
uint64_t metaslab_class_get_dspace | ( | metaslab_class_t * | mc | ) |
Definition at line 187 of file metaslab.c.
uint64_t metaslab_class_get_space | ( | metaslab_class_t * | mc | ) |
Definition at line 181 of file metaslab.c.
void metaslab_class_space_update | ( | metaslab_class_t * | mc, |
int64_t | alloc_delta, | ||
int64_t | defer_delta, | ||
int64_t | space_delta, | ||
int64_t | dspace_delta | ||
) |
Definition at line 159 of file metaslab.c.
int metaslab_class_validate | ( | metaslab_class_t * | mc | ) |
Definition at line 133 of file metaslab.c.
static int metaslab_compare | ( | const void * | x1, |
const void * | x2 | ||
) | [static] |
Definition at line 198 of file metaslab.c.
static uint64_t metaslab_df_alloc | ( | space_map_t * | sm, |
uint64_t | size | ||
) | [static] |
Definition at line 525 of file metaslab.c.
static boolean_t metaslab_df_fragmented | ( | space_map_t * | sm | ) | [static] |
Definition at line 553 of file metaslab.c.
static uint64_t metaslab_distance | ( | metaslab_t * | msp, |
dva_t * | dva | ||
) | [static] |
Definition at line 1150 of file metaslab.c.
static uint64_t metaslab_ff_alloc | ( | space_map_t * | sm, |
uint64_t | size | ||
) | [static] |
Definition at line 489 of file metaslab.c.
boolean_t metaslab_ff_fragmented | ( | space_map_t * | sm | ) |
Definition at line 500 of file metaslab.c.
void metaslab_fini | ( | metaslab_t * | msp | ) |
Definition at line 759 of file metaslab.c.
Definition at line 1619 of file metaslab.c.
static void metaslab_free_dva | ( | spa_t * | spa, |
const dva_t * | dva, | ||
uint64_t | txg, | ||
boolean_t | now | ||
) | [static] |
Free the block represented by DVA in the context of the specified transaction group.
Definition at line 1480 of file metaslab.c.
void metaslab_group_activate | ( | metaslab_group_t * | mg | ) |
Definition at line 255 of file metaslab.c.
static void metaslab_group_add | ( | metaslab_group_t * | mg, |
metaslab_t * | msp | ||
) | [static] |
Definition at line 317 of file metaslab.c.
static uint64_t metaslab_group_alloc | ( | metaslab_group_t * | mg, |
uint64_t | psize, | ||
uint64_t | asize, | ||
uint64_t | txg, | ||
uint64_t | min_distance, | ||
dva_t * | dva, | ||
int | d, | ||
int | flags | ||
) | [static] |
Definition at line 1167 of file metaslab.c.
metaslab_group_t* metaslab_group_create | ( | metaslab_class_t * | mc, |
vdev_t * | vd | ||
) |
Definition at line 222 of file metaslab.c.
void metaslab_group_destroy | ( | metaslab_group_t * | mg | ) |
Definition at line 238 of file metaslab.c.
void metaslab_group_passivate | ( | metaslab_group_t * | mg | ) |
Definition at line 286 of file metaslab.c.
static void metaslab_group_remove | ( | metaslab_group_t * | mg, |
metaslab_t * | msp | ||
) | [static] |
Definition at line 328 of file metaslab.c.
static void metaslab_group_sort | ( | metaslab_group_t * | mg, |
metaslab_t * | msp, | ||
uint64_t | weight | ||
) | [static] |
Definition at line 338 of file metaslab.c.
metaslab_t* metaslab_init | ( | metaslab_group_t * | mg, |
space_map_obj_t * | smo, | ||
uint64_t | start, | ||
uint64_t | size, | ||
uint64_t | txg | ||
) |
Definition at line 711 of file metaslab.c.
static uint64_t metaslab_ndf_alloc | ( | space_map_t * | sm, |
uint64_t | size | ||
) | [static] |
Definition at line 642 of file metaslab.c.
static boolean_t metaslab_ndf_fragmented | ( | space_map_t * | sm | ) | [static] |
Definition at line 683 of file metaslab.c.
static void metaslab_passivate | ( | metaslab_t * | msp, |
uint64_t | size | ||
) | [static] |
Definition at line 919 of file metaslab.c.
static void metaslab_pp_claim | ( | space_map_t * | sm, |
uint64_t | start, | ||
uint64_t | size | ||
) | [static] |
Definition at line 456 of file metaslab.c.
static void metaslab_pp_free | ( | space_map_t * | sm, |
uint64_t | start, | ||
uint64_t | size | ||
) | [static] |
Definition at line 463 of file metaslab.c.
static void metaslab_pp_load | ( | space_map_t * | sm | ) | [static] |
Definition at line 422 of file metaslab.c.
uint64_t metaslab_pp_maxsize | ( | space_map_t * | sm | ) |
Return the maximum contiguous segment within the metaslab.
Definition at line 472 of file metaslab.c.
static void metaslab_pp_unload | ( | space_map_t * | sm | ) | [static] |
Definition at line 438 of file metaslab.c.
static void metaslab_prefetch | ( | metaslab_group_t * | mg | ) | [static] |
Definition at line 845 of file metaslab.c.
static int metaslab_segsize_compare | ( | const void * | x1, |
const void * | x2 | ||
) | [static] |
Definition at line 361 of file metaslab.c.
void metaslab_sync | ( | metaslab_t * | msp, |
uint64_t | txg | ||
) |
Write a metaslab to disk in the context of the specified transaction group.
Definition at line 935 of file metaslab.c.
void metaslab_sync_done | ( | metaslab_t * | msp, |
uint64_t | txg | ||
) |
Called after a transaction group has completely synced to mark all of the metaslab's free space as usable.
Definition at line 1034 of file metaslab.c.
void metaslab_sync_reassess | ( | metaslab_group_t * | mg | ) |
Definition at line 1121 of file metaslab.c.
static uint64_t metaslab_weight | ( | metaslab_t * | msp | ) | [static] |
Definition at line 795 of file metaslab.c.
SYSCTL_DECL | ( | _vfs_zfs | ) |
SYSCTL_INT | ( | _vfs_zfs | , |
OID_AUTO | , | ||
mg_alloc_failures | , | ||
CTLFLAG_RDTUN | , | ||
& | zfs_mg_alloc_failures, | ||
0 | , | ||
"Number of allowed allocation failures per vdev" | |||
) |
TUNABLE_INT | ( | "vfs.zfs.mg_alloc_failures" | , |
& | zfs_mg_alloc_failures | ||
) |
uint64_t metaslab_aliquot = 512ULL << 10 |
Definition at line 46 of file metaslab.c.
space_map_ops_t metaslab_cdf_ops [static] |
{ metaslab_pp_load, metaslab_pp_unload, metaslab_cdf_alloc, metaslab_pp_claim, metaslab_pp_free, metaslab_pp_maxsize, metaslab_cdf_fragmented }
Definition at line 629 of file metaslab.c.
int metaslab_debug = 0 [static] |
Metaslab debugging: when set, keeps all space maps in core to verify frees.
Definition at line 67 of file metaslab.c.
uint64_t metaslab_df_alloc_threshold = SPA_MAXBLOCKSIZE |
Minimum size which forces the dynamic allocator to change it's allocation strategy.
Once the space map cannot satisfy an allocation of this size then it switches to using more aggressive strategy (i.e search by size rather than offset).
Definition at line 75 of file metaslab.c.
int metaslab_df_free_pct = 4 |
The minimum free space, in percent, which must be available in a space map to continue allocations in a first-fit fashion.
Once the space_map's free space drops below this level we dynamically switch to using best-fit allocations.
Definition at line 83 of file metaslab.c.
space_map_ops_t metaslab_df_ops [static] |
{ metaslab_pp_load, metaslab_pp_unload, metaslab_df_alloc, metaslab_pp_claim, metaslab_pp_free, metaslab_pp_maxsize, metaslab_df_fragmented }
Definition at line 565 of file metaslab.c.
space_map_ops_t metaslab_ff_ops [static] |
{ metaslab_pp_load, metaslab_pp_unload, metaslab_ff_alloc, metaslab_pp_claim, metaslab_pp_free, metaslab_pp_maxsize, metaslab_ff_fragmented }
Definition at line 505 of file metaslab.c.
uint64_t metaslab_gang_bang = SPA_MAXBLOCKSIZE + 1 |
Definition at line 47 of file metaslab.c.
uint64_t metaslab_min_alloc_size = DMU_MAX_ACCESS |
A metaslab is considered "free" if it contains a contiguous segment which is greater than metaslab_min_alloc_size.
Definition at line 89 of file metaslab.c.
uint64_t metaslab_ndf_clump_shift = 4 |
Definition at line 639 of file metaslab.c.
space_map_ops_t metaslab_ndf_ops [static] |
{ metaslab_pp_load, metaslab_pp_unload, metaslab_ndf_alloc, metaslab_pp_claim, metaslab_pp_free, metaslab_pp_maxsize, metaslab_ndf_fragmented }
Definition at line 693 of file metaslab.c.
int metaslab_prefetch_limit = SPA_DVAS_PER_BP |
Max number of space_maps to prefetch.
Definition at line 94 of file metaslab.c.
int metaslab_smo_bonus_pct = 150 |
Percentage bonus multiplier for metaslabs that are in the bonus area.
Definition at line 99 of file metaslab.c.
Definition at line 703 of file metaslab.c.