xref: /titanic_41/usr/src/uts/common/fs/zfs/sys/metaslab.h (revision c138f478d2bc94e73ab8f6a084e323bec25e62f5)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_METASLAB_H
28 #define	_SYS_METASLAB_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/spa.h>
33 #include <sys/space_map.h>
34 #include <sys/txg.h>
35 #include <sys/zio.h>
36 #include <sys/avl.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 typedef struct metaslab_class metaslab_class_t;
43 typedef struct metaslab_group metaslab_group_t;
44 
45 extern void metaslab_init(metaslab_group_t *mg, space_map_obj_t *smo,
46     metaslab_t **mspp, uint64_t offset, uint64_t size, uint64_t txg);
47 extern void metaslab_fini(metaslab_t *msp);
48 extern void metaslab_sync(metaslab_t *msp, uint64_t txg);
49 extern void metaslab_sync_done(metaslab_t *msp, uint64_t txg);
50 
51 extern int metaslab_alloc(spa_t *spa, uint64_t size, dva_t *dva, uint64_t txg);
52 extern void metaslab_free(spa_t *spa, dva_t *dva, uint64_t txg);
53 extern int metaslab_claim(spa_t *spa, dva_t *dva, uint64_t txg);
54 
55 extern metaslab_class_t *metaslab_class_create(void);
56 extern void metaslab_class_destroy(metaslab_class_t *mc);
57 extern void metaslab_class_add(metaslab_class_t *mc, metaslab_group_t *mg);
58 extern void metaslab_class_remove(metaslab_class_t *mc, metaslab_group_t *mg);
59 
60 extern metaslab_group_t *metaslab_group_create(metaslab_class_t *mc,
61     vdev_t *vd);
62 extern void metaslab_group_destroy(metaslab_group_t *mg);
63 extern void metaslab_group_add(metaslab_group_t *mg, metaslab_t *msp,
64     uint64_t weight);
65 extern void metaslab_group_remove(metaslab_group_t *mg, metaslab_t *msp);
66 extern void metaslab_group_sort(metaslab_group_t *mg, metaslab_t *msp,
67     uint64_t weight);
68 
69 #ifdef	__cplusplus
70 }
71 #endif
72 
73 #endif	/* _SYS_METASLAB_H */
74