Print this page
3954 metaslabs continue to load even after hitting zfs_mg_alloc_failure limit
4080 zpool clear fails to clear pool
4081 need zfs_mg_noalloc_threshold
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/fs/zfs/sys/metaslab_impl.h
+++ new/usr/src/uts/common/fs/zfs/sys/metaslab_impl.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26 /*
27 - * Copyright (c) 2012 by Delphix. All rights reserved.
27 + * Copyright (c) 2013 by Delphix. All rights reserved.
28 28 */
29 29
30 30 #ifndef _SYS_METASLAB_IMPL_H
31 31 #define _SYS_METASLAB_IMPL_H
32 32
33 33 #include <sys/metaslab.h>
34 34 #include <sys/space_map.h>
35 35 #include <sys/vdev.h>
36 36 #include <sys/txg.h>
37 37 #include <sys/avl.h>
38 38
39 39 #ifdef __cplusplus
40 40 extern "C" {
41 41 #endif
42 42
43 43 struct metaslab_class {
44 44 spa_t *mc_spa;
45 45 metaslab_group_t *mc_rotor;
46 46 space_map_ops_t *mc_ops;
47 47 uint64_t mc_aliquot;
48 + uint64_t mc_alloc_groups; /* # of allocatable groups */
48 49 uint64_t mc_alloc; /* total allocated space */
49 50 uint64_t mc_deferred; /* total deferred frees */
50 51 uint64_t mc_space; /* total space (alloc + free) */
51 52 uint64_t mc_dspace; /* total deflated space */
52 53 };
53 54
54 55 struct metaslab_group {
55 56 kmutex_t mg_lock;
56 57 avl_tree_t mg_metaslab_tree;
57 58 uint64_t mg_aliquot;
58 59 uint64_t mg_bonus_area;
59 60 uint64_t mg_alloc_failures;
61 + boolean_t mg_allocatable; /* can we allocate? */
62 + uint64_t mg_free_capacity; /* percentage free */
60 63 int64_t mg_bias;
61 64 int64_t mg_activation_count;
62 65 metaslab_class_t *mg_class;
63 66 vdev_t *mg_vd;
64 67 metaslab_group_t *mg_prev;
65 68 metaslab_group_t *mg_next;
66 69 };
67 70
68 71 /*
69 72 * Each metaslab maintains an in-core free map (ms_map) that contains the
70 73 * current list of free segments. As blocks are allocated, the allocated
71 74 * segment is removed from the ms_map and added to a per txg allocation map.
72 75 * As blocks are freed, they are added to the per txg free map. These per
73 76 * txg maps allow us to process all allocations and frees in syncing context
74 77 * where it is safe to update the on-disk space maps.
75 78 *
76 79 * Each metaslab's free space is tracked in a space map object in the MOS,
77 80 * which is only updated in syncing context. Each time we sync a txg,
78 81 * we append the allocs and frees from that txg to the space map object.
79 82 * When the txg is done syncing, metaslab_sync_done() updates ms_smo
80 83 * to ms_smo_syncing. Everything in ms_smo is always safe to allocate.
81 84 *
82 85 * To load the in-core free map we read the space map object from disk.
83 86 * This object contains a series of alloc and free records that are
84 87 * combined to make up the list of all free segments in this metaslab. These
85 88 * segments are represented in-core by the ms_map and are stored in an
86 89 * AVL tree.
87 90 *
88 91 * As the space map objects grows (as a result of the appends) it will
89 92 * eventually become space-inefficient. When the space map object is
90 93 * zfs_condense_pct/100 times the size of the minimal on-disk representation,
91 94 * we rewrite it in its minimized form.
92 95 */
93 96 struct metaslab {
94 97 kmutex_t ms_lock; /* metaslab lock */
95 98 space_map_obj_t ms_smo; /* synced space map object */
96 99 space_map_obj_t ms_smo_syncing; /* syncing space map object */
97 100 space_map_t *ms_allocmap[TXG_SIZE]; /* allocated this txg */
98 101 space_map_t *ms_freemap[TXG_SIZE]; /* freed this txg */
99 102 space_map_t *ms_defermap[TXG_DEFER_SIZE]; /* deferred frees */
100 103 space_map_t *ms_map; /* in-core free space map */
101 104 int64_t ms_deferspace; /* sum of ms_defermap[] space */
102 105 uint64_t ms_weight; /* weight vs. others in group */
103 106 metaslab_group_t *ms_group; /* metaslab group */
104 107 avl_node_t ms_group_node; /* node in metaslab group tree */
105 108 txg_node_t ms_txg_node; /* per-txg dirty metaslab links */
106 109 };
107 110
108 111 #ifdef __cplusplus
109 112 }
110 113 #endif
111 114
112 115 #endif /* _SYS_METASLAB_IMPL_H */
↓ open down ↓ |
43 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX