1fa9e4066Sahrens /* 2fa9e4066Sahrens * CDDL HEADER START 3fa9e4066Sahrens * 4fa9e4066Sahrens * The contents of this file are subject to the terms of the 5ecc2d604Sbonwick * Common Development and Distribution License (the "License"). 6ecc2d604Sbonwick * You may not use this file except in compliance with the License. 7fa9e4066Sahrens * 8fa9e4066Sahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9fa9e4066Sahrens * or http://www.opensolaris.org/os/licensing. 10fa9e4066Sahrens * See the License for the specific language governing permissions 11fa9e4066Sahrens * and limitations under the License. 12fa9e4066Sahrens * 13fa9e4066Sahrens * When distributing Covered Code, include this CDDL HEADER in each 14fa9e4066Sahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15fa9e4066Sahrens * If applicable, add the following below this CDDL HEADER, with the 16fa9e4066Sahrens * fields enclosed by brackets "[]" replaced with your own identifying 17fa9e4066Sahrens * information: Portions Copyright [yyyy] [name of copyright owner] 18fa9e4066Sahrens * 19fa9e4066Sahrens * CDDL HEADER END 20fa9e4066Sahrens */ 21fa9e4066Sahrens /* 22d6e555bdSGeorge Wilson * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23fa9e4066Sahrens * Use is subject to license terms. 24fa9e4066Sahrens */ 25fa9e4066Sahrens 26fa9e4066Sahrens #ifndef _SYS_METASLAB_IMPL_H 27fa9e4066Sahrens #define _SYS_METASLAB_IMPL_H 28fa9e4066Sahrens 29fa9e4066Sahrens #include <sys/metaslab.h> 30fa9e4066Sahrens #include <sys/space_map.h> 31fa9e4066Sahrens #include <sys/vdev.h> 32fa9e4066Sahrens #include <sys/txg.h> 33fa9e4066Sahrens #include <sys/avl.h> 34fa9e4066Sahrens 35fa9e4066Sahrens #ifdef __cplusplus 36fa9e4066Sahrens extern "C" { 37fa9e4066Sahrens #endif 38fa9e4066Sahrens 39fa9e4066Sahrens struct metaslab_class { 40*88ecc943SGeorge Wilson spa_t *mc_spa; 41fa9e4066Sahrens metaslab_group_t *mc_rotor; 42fa9e4066Sahrens uint64_t mc_allocated; 43d6e555bdSGeorge Wilson space_map_ops_t *mc_ops; 44fa9e4066Sahrens }; 45fa9e4066Sahrens 46fa9e4066Sahrens struct metaslab_group { 47fa9e4066Sahrens kmutex_t mg_lock; 48fa9e4066Sahrens avl_tree_t mg_metaslab_tree; 49fa9e4066Sahrens uint64_t mg_aliquot; 50fa9e4066Sahrens int64_t mg_bias; 51fa9e4066Sahrens metaslab_class_t *mg_class; 52fa9e4066Sahrens vdev_t *mg_vd; 53fa9e4066Sahrens metaslab_group_t *mg_prev; 54fa9e4066Sahrens metaslab_group_t *mg_next; 55fa9e4066Sahrens }; 56fa9e4066Sahrens 57fa9e4066Sahrens /* 58ecc2d604Sbonwick * Each metaslab's free space is tracked in space map object in the MOS, 59ecc2d604Sbonwick * which is only updated in syncing context. Each time we sync a txg, 60ecc2d604Sbonwick * we append the allocs and frees from that txg to the space map object. 61ecc2d604Sbonwick * When the txg is done syncing, metaslab_sync_done() updates ms_smo 62ecc2d604Sbonwick * to ms_smo_syncing. Everything in ms_smo is always safe to allocate. 63fa9e4066Sahrens */ 64fa9e4066Sahrens struct metaslab { 65fa9e4066Sahrens kmutex_t ms_lock; /* metaslab lock */ 66ecc2d604Sbonwick space_map_obj_t ms_smo; /* synced space map object */ 67ecc2d604Sbonwick space_map_obj_t ms_smo_syncing; /* syncing space map object */ 68fa9e4066Sahrens space_map_t ms_allocmap[TXG_SIZE]; /* allocated this txg */ 69fa9e4066Sahrens space_map_t ms_freemap[TXG_SIZE]; /* freed this txg */ 70fa9e4066Sahrens space_map_t ms_map; /* in-core free space map */ 71ecc2d604Sbonwick uint64_t ms_weight; /* weight vs. others in group */ 72ecc2d604Sbonwick metaslab_group_t *ms_group; /* metaslab group */ 73ecc2d604Sbonwick avl_node_t ms_group_node; /* node in metaslab group tree */ 74ecc2d604Sbonwick txg_node_t ms_txg_node; /* per-txg dirty metaslab links */ 75fa9e4066Sahrens }; 76fa9e4066Sahrens 77fa9e4066Sahrens #ifdef __cplusplus 78fa9e4066Sahrens } 79fa9e4066Sahrens #endif 80fa9e4066Sahrens 81fa9e4066Sahrens #endif /* _SYS_METASLAB_IMPL_H */ 82