7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /*
27 * Copyright (c) 2012 by Delphix. All rights reserved.
28 */
29
30 #ifndef _SYS_METASLAB_IMPL_H
31 #define _SYS_METASLAB_IMPL_H
32
33 #include <sys/metaslab.h>
34 #include <sys/space_map.h>
35 #include <sys/vdev.h>
36 #include <sys/txg.h>
37 #include <sys/avl.h>
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 struct metaslab_class {
44 spa_t *mc_spa;
45 metaslab_group_t *mc_rotor;
46 space_map_ops_t *mc_ops;
47 uint64_t mc_aliquot;
48 uint64_t mc_alloc; /* total allocated space */
49 uint64_t mc_deferred; /* total deferred frees */
50 uint64_t mc_space; /* total space (alloc + free) */
51 uint64_t mc_dspace; /* total deflated space */
52 };
53
54 struct metaslab_group {
55 kmutex_t mg_lock;
56 avl_tree_t mg_metaslab_tree;
57 uint64_t mg_aliquot;
58 uint64_t mg_bonus_area;
59 uint64_t mg_alloc_failures;
60 int64_t mg_bias;
61 int64_t mg_activation_count;
62 metaslab_class_t *mg_class;
63 vdev_t *mg_vd;
64 metaslab_group_t *mg_prev;
65 metaslab_group_t *mg_next;
66 };
67
68 /*
69 * Each metaslab maintains an in-core free map (ms_map) that contains the
70 * current list of free segments. As blocks are allocated, the allocated
71 * segment is removed from the ms_map and added to a per txg allocation map.
72 * As blocks are freed, they are added to the per txg free map. These per
73 * txg maps allow us to process all allocations and frees in syncing context
74 * where it is safe to update the on-disk space maps.
75 *
76 * Each metaslab's free space is tracked in a space map object in the MOS,
77 * which is only updated in syncing context. Each time we sync a txg,
78 * we append the allocs and frees from that txg to the space map object.
79 * When the txg is done syncing, metaslab_sync_done() updates ms_smo
|
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 /*
27 * Copyright (c) 2013 by Delphix. All rights reserved.
28 */
29
30 #ifndef _SYS_METASLAB_IMPL_H
31 #define _SYS_METASLAB_IMPL_H
32
33 #include <sys/metaslab.h>
34 #include <sys/space_map.h>
35 #include <sys/vdev.h>
36 #include <sys/txg.h>
37 #include <sys/avl.h>
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 struct metaslab_class {
44 spa_t *mc_spa;
45 metaslab_group_t *mc_rotor;
46 space_map_ops_t *mc_ops;
47 uint64_t mc_aliquot;
48 uint64_t mc_alloc_groups; /* # of allocatable groups */
49 uint64_t mc_alloc; /* total allocated space */
50 uint64_t mc_deferred; /* total deferred frees */
51 uint64_t mc_space; /* total space (alloc + free) */
52 uint64_t mc_dspace; /* total deflated space */
53 };
54
55 struct metaslab_group {
56 kmutex_t mg_lock;
57 avl_tree_t mg_metaslab_tree;
58 uint64_t mg_aliquot;
59 uint64_t mg_bonus_area;
60 uint64_t mg_alloc_failures;
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 metaslab_group_t *mg_prev;
68 metaslab_group_t *mg_next;
69 };
70
71 /*
72 * Each metaslab maintains an in-core free map (ms_map) that contains the
73 * current list of free segments. As blocks are allocated, the allocated
74 * segment is removed from the ms_map and added to a per txg allocation map.
75 * As blocks are freed, they are added to the per txg free map. These per
76 * txg maps allow us to process all allocations and frees in syncing context
77 * where it is safe to update the on-disk space maps.
78 *
79 * Each metaslab's free space is tracked in a space map object in the MOS,
80 * which is only updated in syncing context. Each time we sync a txg,
81 * we append the allocs and frees from that txg to the space map object.
82 * When the txg is done syncing, metaslab_sync_done() updates ms_smo
|