Skip to content

Commit f3dff9d

Browse files
author
Paul Dagnelie
committed
Expand fragmentation table size to reflect larger possibility space for allocation sizes
Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Signed-off-by: Paul Dagnelie <[email protected]>
1 parent fe44c5a commit f3dff9d

File tree

2 files changed

+30
-24
lines changed

2 files changed

+30
-24
lines changed

man/man4/zfs.4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,7 @@ Normally disabled because these datasets may be missing key data.
17781778
.It Sy zfs_min_metaslabs_to_flush Ns = Ns Sy 1 Pq u64
17791779
Minimum number of metaslabs to flush per dirty TXG.
17801780
.
1781-
.It Sy zfs_metaslab_fragmentation_threshold Ns = Ns Sy 70 Ns % Pq uint
1781+
.It Sy zfs_metaslab_fragmentation_threshold Ns = Ns Sy 85 Ns % Pq uint
17821782
Allow metaslabs to keep their active state as long as their fragmentation
17831783
percentage is no more than this value.
17841784
An active metaslab that exceeds this threshold

module/zfs/metaslab.c

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static uint_t zfs_mg_fragmentation_threshold = 95;
146146
* active metaslab that exceeds this threshold will no longer keep its active
147147
* status allowing better metaslabs to be selected.
148148
*/
149-
static uint_t zfs_metaslab_fragmentation_threshold = 70;
149+
static uint_t zfs_metaslab_fragmentation_threshold = 85;
150150

151151
/*
152152
* When set will load all metaslabs when pool is first opened.
@@ -2889,8 +2889,6 @@ metaslab_fini(metaslab_t *msp)
28892889
kmem_free(msp, sizeof (metaslab_t));
28902890
}
28912891

2892-
#define FRAGMENTATION_TABLE_SIZE 17
2893-
28942892
/*
28952893
* This table defines a segment size based fragmentation metric that will
28962894
* allow each metaslab to derive its own fragmentation value. This is done
@@ -2901,33 +2899,41 @@ metaslab_fini(metaslab_t *msp)
29012899
* us the fragmentation metric. This means that a high fragmentation metric
29022900
* equates to most of the free space being comprised of small segments.
29032901
* Conversely, if the metric is low, then most of the free space is in
2904-
* large segments. A 10% change in fragmentation equates to approximately
2905-
* double the number of segments.
2902+
* large segments.
29062903
*
2907-
* This table defines 0% fragmented space using 16MB segments. Testing has
2908-
* shown that segments that are greater than or equal to 16MB do not suffer
2909-
* from drastic performance problems. Using this value, we derive the rest
2910-
* of the table. Since the fragmentation value is never stored on disk, it
2911-
* is possible to change these calculations in the future.
2904+
* This table defines 0% fragmented space using 1G segments. Using this value,
2905+
* we derive the rest of the table. This table originally went up to 16MB, but
2906+
* with larger recordsizes, larger ashifts, and use of raidz3, it is possible
2907+
* to have significantly larger allocations than were previously possible.
2908+
* Since the fragmentation value is never stored on disk, it is possible to
2909+
* change these calculations in the future.
29122910
*/
2913-
static const int zfs_frag_table[FRAGMENTATION_TABLE_SIZE] = {
2911+
static const int zfs_frag_table[] = {
29142912
100, /* 512B */
29152913
100, /* 1K */
29162914
98, /* 2K */
29172915
95, /* 4K */
2918-
90, /* 8K */
2919-
80, /* 16K */
2920-
70, /* 32K */
2921-
60, /* 64K */
2922-
50, /* 128K */
2923-
40, /* 256K */
2924-
30, /* 512K */
2925-
20, /* 1M */
2926-
15, /* 2M */
2927-
10, /* 4M */
2928-
5, /* 8M */
2929-
0 /* 16M */
2916+
92, /* 8K */
2917+
90, /* 16K */
2918+
85, /* 32K */
2919+
80, /* 64K */
2920+
75, /* 128K */
2921+
70, /* 256K */
2922+
60, /* 512K */
2923+
50, /* 1M */
2924+
40, /* 2M */
2925+
35, /* 4M */
2926+
30, /* 8M */
2927+
25, /* 16M */
2928+
20, /* 32M */
2929+
15, /* 64M */
2930+
10, /* 128M */
2931+
5, /* 256M */
2932+
2, /* 512M */
2933+
0, /* 1G */
29302934
};
2935+
#define FRAGMENTATION_TABLE_SIZE \
2936+
(sizeof (zfs_frag_table)/(sizeof (zfs_frag_table[0])))
29312937

29322938
/*
29332939
* Calculate the metaslab's fragmentation metric and set ms_fragmentation.

0 commit comments

Comments
 (0)