Deleted Added
full compact
metaslab_impl.h (264671) metaslab_impl.h (269118)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 27 unchanged lines hidden (view full) ---

36#include <sys/vdev.h>
37#include <sys/txg.h>
38#include <sys/avl.h>
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 27 unchanged lines hidden (view full) ---

36#include <sys/vdev.h>
37#include <sys/txg.h>
38#include <sys/avl.h>
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44/*
45 * A metaslab class encompasses a category of allocatable top-level vdevs.
46 * Each top-level vdev is associated with a metaslab group which defines
47 * the allocatable region for that vdev. Examples of these categories include
48 * "normal" for data block allocations (i.e. main pool allocations) or "log"
49 * for allocations designated for intent log devices (i.e. slog devices).
50 * When a block allocation is requested from the SPA it is associated with a
51 * metaslab_class_t, and only top-level vdevs (i.e. metaslab groups) belonging
52 * to the class can be used to satisfy that request. Allocations are done
53 * by traversing the metaslab groups that are linked off of the mc_rotor field.
54 * This rotor points to the next metaslab group where allocations will be
55 * attempted. Allocating a block is a 3 step process -- select the metaslab
56 * group, select the metaslab, and then allocate the block. The metaslab
57 * class defines the low-level block allocator that will be used as the
58 * final step in allocation. These allocators are pluggable allowing each class
59 * to use a block allocator that best suits that class.
60 */
44struct metaslab_class {
45 spa_t *mc_spa;
46 metaslab_group_t *mc_rotor;
47 metaslab_ops_t *mc_ops;
48 uint64_t mc_aliquot;
49 uint64_t mc_alloc_groups; /* # of allocatable groups */
50 uint64_t mc_alloc; /* total allocated space */
51 uint64_t mc_deferred; /* total deferred frees */
52 uint64_t mc_space; /* total space (alloc + free) */
53 uint64_t mc_dspace; /* total deflated space */
54 uint64_t mc_minblocksize;
61struct metaslab_class {
62 spa_t *mc_spa;
63 metaslab_group_t *mc_rotor;
64 metaslab_ops_t *mc_ops;
65 uint64_t mc_aliquot;
66 uint64_t mc_alloc_groups; /* # of allocatable groups */
67 uint64_t mc_alloc; /* total allocated space */
68 uint64_t mc_deferred; /* total deferred frees */
69 uint64_t mc_space; /* total space (alloc + free) */
70 uint64_t mc_dspace; /* total deflated space */
71 uint64_t mc_minblocksize;
72 uint64_t mc_histogram[RANGE_TREE_HISTOGRAM_SIZE];
55};
56
73};
74
75/*
76 * Metaslab groups encapsulate all the allocatable regions (i.e. metaslabs)
77 * of a top-level vdev. They are linked togther to form a circular linked
78 * list and can belong to only one metaslab class. Metaslab groups may become
79 * ineligible for allocations for a number of reasons such as limited free
80 * space, fragmentation, or going offline. When this happens the allocator will
81 * simply find the next metaslab group in the linked list and attempt
82 * to allocate from that group instead.
83 */
57struct metaslab_group {
58 kmutex_t mg_lock;
59 avl_tree_t mg_metaslab_tree;
60 uint64_t mg_aliquot;
61 boolean_t mg_allocatable; /* can we allocate? */
62 uint64_t mg_free_capacity; /* percentage free */
63 int64_t mg_bias;
64 int64_t mg_activation_count;
65 metaslab_class_t *mg_class;
66 vdev_t *mg_vd;
67 taskq_t *mg_taskq;
68 metaslab_group_t *mg_prev;
69 metaslab_group_t *mg_next;
84struct metaslab_group {
85 kmutex_t mg_lock;
86 avl_tree_t mg_metaslab_tree;
87 uint64_t mg_aliquot;
88 boolean_t mg_allocatable; /* can we allocate? */
89 uint64_t mg_free_capacity; /* percentage free */
90 int64_t mg_bias;
91 int64_t mg_activation_count;
92 metaslab_class_t *mg_class;
93 vdev_t *mg_vd;
94 taskq_t *mg_taskq;
95 metaslab_group_t *mg_prev;
96 metaslab_group_t *mg_next;
97 uint64_t mg_fragmentation;
98 uint64_t mg_histogram[RANGE_TREE_HISTOGRAM_SIZE];
70};
71
72/*
73 * This value defines the number of elements in the ms_lbas array. The value
99};
100
101/*
102 * This value defines the number of elements in the ms_lbas array. The value
74 * of 64 was chosen as it covers to cover all power of 2 buckets up to
75 * UINT64_MAX. This is the equivalent of highbit(UINT64_MAX).
103 * of 64 was chosen as it covers all power of 2 buckets up to UINT64_MAX.
104 * This is the equivalent of highbit(UINT64_MAX).
76 */
77#define MAX_LBAS 64
78
79/*
80 * Each metaslab maintains a set of in-core trees to track metaslab operations.
81 * The in-core free tree (ms_tree) contains the current list of free segments.
82 * As blocks are allocated, the allocated segment are removed from the ms_tree
83 * and added to a per txg allocation tree (ms_alloctree). As blocks are freed,

--- 46 unchanged lines hidden (view full) ---

130struct metaslab {
131 kmutex_t ms_lock;
132 kcondvar_t ms_load_cv;
133 space_map_t *ms_sm;
134 metaslab_ops_t *ms_ops;
135 uint64_t ms_id;
136 uint64_t ms_start;
137 uint64_t ms_size;
105 */
106#define MAX_LBAS 64
107
108/*
109 * Each metaslab maintains a set of in-core trees to track metaslab operations.
110 * The in-core free tree (ms_tree) contains the current list of free segments.
111 * As blocks are allocated, the allocated segment are removed from the ms_tree
112 * and added to a per txg allocation tree (ms_alloctree). As blocks are freed,

--- 46 unchanged lines hidden (view full) ---

159struct metaslab {
160 kmutex_t ms_lock;
161 kcondvar_t ms_load_cv;
162 space_map_t *ms_sm;
163 metaslab_ops_t *ms_ops;
164 uint64_t ms_id;
165 uint64_t ms_start;
166 uint64_t ms_size;
167 uint64_t ms_fragmentation;
138
139 range_tree_t *ms_alloctree[TXG_SIZE];
140 range_tree_t *ms_freetree[TXG_SIZE];
141 range_tree_t *ms_defertree[TXG_DEFER_SIZE];
142 range_tree_t *ms_tree;
143
144 boolean_t ms_condensing; /* condensing? */
168
169 range_tree_t *ms_alloctree[TXG_SIZE];
170 range_tree_t *ms_freetree[TXG_SIZE];
171 range_tree_t *ms_defertree[TXG_DEFER_SIZE];
172 range_tree_t *ms_tree;
173
174 boolean_t ms_condensing; /* condensing? */
175 boolean_t ms_condense_wanted;
145 boolean_t ms_loaded;
146 boolean_t ms_loading;
147
148 int64_t ms_deferspace; /* sum of ms_defermap[] space */
149 uint64_t ms_weight; /* weight vs. others in group */
176 boolean_t ms_loaded;
177 boolean_t ms_loading;
178
179 int64_t ms_deferspace; /* sum of ms_defermap[] space */
180 uint64_t ms_weight; /* weight vs. others in group */
150 uint64_t ms_factor;
151 uint64_t ms_access_txg;
152
153 /*
154 * The metaslab block allocators can optionally use a size-ordered
155 * range tree and/or an array of LBAs. Not all allocators use
156 * this functionality. The ms_size_tree should always contain the
157 * same number of segments as the ms_tree. The only difference
158 * is that the ms_size_tree is ordered by segment sizes.

--- 14 unchanged lines hidden ---
181 uint64_t ms_access_txg;
182
183 /*
184 * The metaslab block allocators can optionally use a size-ordered
185 * range tree and/or an array of LBAs. Not all allocators use
186 * this functionality. The ms_size_tree should always contain the
187 * same number of segments as the ms_tree. The only difference
188 * is that the ms_size_tree is ordered by segment sizes.

--- 14 unchanged lines hidden ---