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 /* 223f9d6ad7SLin Ling * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 232e4c9986SGeorge Wilson * Copyright (c) 2011, 2014 by Delphix. All rights reserved. 24fa9e4066Sahrens */ 25fa9e4066Sahrens 26fa9e4066Sahrens #ifndef _SYS_METASLAB_H 27fa9e4066Sahrens #define _SYS_METASLAB_H 28fa9e4066Sahrens 29fa9e4066Sahrens #include <sys/spa.h> 30fa9e4066Sahrens #include <sys/space_map.h> 31fa9e4066Sahrens #include <sys/txg.h> 32fa9e4066Sahrens #include <sys/zio.h> 33fa9e4066Sahrens #include <sys/avl.h> 34fa9e4066Sahrens 35fa9e4066Sahrens #ifdef __cplusplus 36fa9e4066Sahrens extern "C" { 37fa9e4066Sahrens #endif 38fa9e4066Sahrens 390713e232SGeorge Wilson typedef struct metaslab_ops { 400713e232SGeorge Wilson uint64_t (*msop_alloc)(metaslab_t *msp, uint64_t size); 410713e232SGeorge Wilson } metaslab_ops_t; 42d6e555bdSGeorge Wilson 430713e232SGeorge Wilson extern metaslab_ops_t *zfs_metaslab_ops; 440713e232SGeorge Wilson 45*1e9bd7ecSPrakash Surya int metaslab_init(metaslab_group_t *, uint64_t, uint64_t, uint64_t, 46*1e9bd7ecSPrakash Surya metaslab_t **); 472e4c9986SGeorge Wilson void metaslab_fini(metaslab_t *); 480713e232SGeorge Wilson 492e4c9986SGeorge Wilson void metaslab_load_wait(metaslab_t *); 502e4c9986SGeorge Wilson int metaslab_load(metaslab_t *); 512e4c9986SGeorge Wilson void metaslab_unload(metaslab_t *); 520713e232SGeorge Wilson 532e4c9986SGeorge Wilson void metaslab_sync(metaslab_t *, uint64_t); 542e4c9986SGeorge Wilson void metaslab_sync_done(metaslab_t *, uint64_t); 552e4c9986SGeorge Wilson void metaslab_sync_reassess(metaslab_group_t *); 562e4c9986SGeorge Wilson uint64_t metaslab_block_maxsize(metaslab_t *); 57fa9e4066Sahrens 58e14bb325SJeff Bonwick #define METASLAB_HINTBP_FAVOR 0x0 59e14bb325SJeff Bonwick #define METASLAB_HINTBP_AVOID 0x1 60e14bb325SJeff Bonwick #define METASLAB_GANG_HEADER 0x2 6109c9d376SGeorge Wilson #define METASLAB_GANG_CHILD 0x4 6209c9d376SGeorge Wilson #define METASLAB_GANG_AVOID 0x8 63e14bb325SJeff Bonwick 642e4c9986SGeorge Wilson int metaslab_alloc(spa_t *, metaslab_class_t *, uint64_t, 652e4c9986SGeorge Wilson blkptr_t *, int, uint64_t, blkptr_t *, int); 662e4c9986SGeorge Wilson void metaslab_free(spa_t *, const blkptr_t *, uint64_t, boolean_t); 672e4c9986SGeorge Wilson int metaslab_claim(spa_t *, const blkptr_t *, uint64_t); 682e4c9986SGeorge Wilson void metaslab_check_free(spa_t *, const blkptr_t *); 69fa9e4066Sahrens 702e4c9986SGeorge Wilson metaslab_class_t *metaslab_class_create(spa_t *, metaslab_ops_t *); 712e4c9986SGeorge Wilson void metaslab_class_destroy(metaslab_class_t *); 722e4c9986SGeorge Wilson int metaslab_class_validate(metaslab_class_t *); 732e4c9986SGeorge Wilson void metaslab_class_histogram_verify(metaslab_class_t *); 742e4c9986SGeorge Wilson uint64_t metaslab_class_fragmentation(metaslab_class_t *); 752e4c9986SGeorge Wilson uint64_t metaslab_class_expandable_space(metaslab_class_t *); 76fa9e4066Sahrens 772e4c9986SGeorge Wilson void metaslab_class_space_update(metaslab_class_t *, int64_t, int64_t, 782e4c9986SGeorge Wilson int64_t, int64_t); 792e4c9986SGeorge Wilson uint64_t metaslab_class_get_alloc(metaslab_class_t *); 802e4c9986SGeorge Wilson uint64_t metaslab_class_get_space(metaslab_class_t *); 812e4c9986SGeorge Wilson uint64_t metaslab_class_get_dspace(metaslab_class_t *); 822e4c9986SGeorge Wilson uint64_t metaslab_class_get_deferred(metaslab_class_t *); 83b24ab676SJeff Bonwick 842e4c9986SGeorge Wilson metaslab_group_t *metaslab_group_create(metaslab_class_t *, vdev_t *); 852e4c9986SGeorge Wilson void metaslab_group_destroy(metaslab_group_t *); 862e4c9986SGeorge Wilson void metaslab_group_activate(metaslab_group_t *); 872e4c9986SGeorge Wilson void metaslab_group_passivate(metaslab_group_t *); 882e4c9986SGeorge Wilson uint64_t metaslab_group_get_space(metaslab_group_t *); 892e4c9986SGeorge Wilson void metaslab_group_histogram_verify(metaslab_group_t *); 902e4c9986SGeorge Wilson uint64_t metaslab_group_fragmentation(metaslab_group_t *); 912e4c9986SGeorge Wilson void metaslab_group_histogram_remove(metaslab_group_t *, metaslab_t *); 92fa9e4066Sahrens 93fa9e4066Sahrens #ifdef __cplusplus 94fa9e4066Sahrens } 95fa9e4066Sahrens #endif 96fa9e4066Sahrens 97fa9e4066Sahrens #endif /* _SYS_METASLAB_H */ 98