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.
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.
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]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright (c) 2011 by Delphix. All rights reserved.
27 #ifndef _SYS_METASLAB_IMPL_H
28 #define _SYS_METASLAB_IMPL_H
30 #include <sys/metaslab.h>
31 #include <sys/space_map.h>
40 struct metaslab_class
{
42 metaslab_group_t
*mc_rotor
;
43 space_map_ops_t
*mc_ops
;
45 uint64_t mc_alloc
; /* total allocated space */
46 uint64_t mc_deferred
; /* total deferred frees */
47 uint64_t mc_space
; /* total space (alloc + free) */
48 uint64_t mc_dspace
; /* total deflated space */
51 struct metaslab_group
{
53 avl_tree_t mg_metaslab_tree
;
55 uint64_t mg_bonus_area
;
56 uint64_t mg_alloc_failures
;
58 int64_t mg_activation_count
;
59 metaslab_class_t
*mg_class
;
61 metaslab_group_t
*mg_prev
;
62 metaslab_group_t
*mg_next
;
66 * Each metaslab's free space is tracked in space map object in the MOS,
67 * which is only updated in syncing context. Each time we sync a txg,
68 * we append the allocs and frees from that txg to the space map object.
69 * When the txg is done syncing, metaslab_sync_done() updates ms_smo
70 * to ms_smo_syncing. Everything in ms_smo is always safe to allocate.
73 kmutex_t ms_lock
; /* metaslab lock */
74 space_map_obj_t ms_smo
; /* synced space map object */
75 space_map_obj_t ms_smo_syncing
; /* syncing space map object */
76 space_map_t ms_allocmap
[TXG_SIZE
]; /* allocated this txg */
77 space_map_t ms_freemap
[TXG_SIZE
]; /* freed this txg */
78 space_map_t ms_defermap
[TXG_DEFER_SIZE
]; /* deferred frees */
79 space_map_t ms_map
; /* in-core free space map */
80 int64_t ms_deferspace
; /* sum of ms_defermap[] space */
81 uint64_t ms_weight
; /* weight vs. others in group */
82 metaslab_group_t
*ms_group
; /* metaslab group */
83 avl_node_t ms_group_node
; /* node in metaslab group tree */
84 txg_node_t ms_txg_node
; /* per-txg dirty metaslab links */
91 #endif /* _SYS_METASLAB_IMPL_H */