Skip to content

Commit 46adb28

Browse files
authored
metaslab: tuneable to better control force ganging
metaslab_force_ganging isn't enough to actually force ganging, because it still only forces 3% of the time. This adds metaslab_force_ganging_pct so we can configure how often to force ganging. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Rob Norris <[email protected]> Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Closes #15088
1 parent 34b3d49 commit 46adb28

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

man/man4/zfs.4

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
.\" own identifying information:
1616
.\" Portions Copyright [yyyy] [name of copyright owner]
1717
.\"
18-
.Dd January 10, 2023
18+
.Dd July 21, 2023
1919
.Dt ZFS 4
2020
.Os
2121
.
@@ -239,6 +239,11 @@ relative to the pool.
239239
Make some blocks above a certain size be gang blocks.
240240
This option is used by the test suite to facilitate testing.
241241
.
242+
.It Sy metaslab_force_ganging_pct Ns = Ns Sy 3 Ns % Pq uint
243+
For blocks that could be forced to be a gang block (due to
244+
.Sy metaslab_force_ganging ) ,
245+
force this many of them to be gang blocks.
246+
.
242247
.It Sy zfs_ddt_zap_default_bs Ns = Ns Sy 15 Po 32 KiB Pc Pq int
243248
Default DDT ZAP data block size as a power of 2. Note that changing this after
244249
creating a DDT on the pool will not affect existing DDTs, only newly created

module/zfs/metaslab.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ static uint64_t metaslab_aliquot = 1024 * 1024;
5858
*/
5959
uint64_t metaslab_force_ganging = SPA_MAXBLOCKSIZE + 1;
6060

61+
/*
62+
* Of blocks of size >= metaslab_force_ganging, actually gang them this often.
63+
*/
64+
uint_t metaslab_force_ganging_pct = 3;
65+
6166
/*
6267
* In pools where the log space map feature is not enabled we touch
6368
* multiple metaslabs (and their respective space maps) with each
@@ -5109,7 +5114,9 @@ metaslab_alloc_dva(spa_t *spa, metaslab_class_t *mc, uint64_t psize,
51095114
* damage can result in extremely long reconstruction times. This
51105115
* will also test spilling from special to normal.
51115116
*/
5112-
if (psize >= metaslab_force_ganging && (random_in_range(100) < 3)) {
5117+
if (psize >= metaslab_force_ganging &&
5118+
metaslab_force_ganging_pct > 0 &&
5119+
(random_in_range(100) < MIN(metaslab_force_ganging_pct, 100))) {
51135120
metaslab_trace_add(zal, NULL, NULL, psize, d, TRACE_FORCE_GANG,
51145121
allocator);
51155122
return (SET_ERROR(ENOSPC));
@@ -6266,7 +6273,10 @@ ZFS_MODULE_PARAM(zfs_metaslab, zfs_metaslab_, switch_threshold, INT, ZMOD_RW,
62666273
"Segment-based metaslab selection maximum buckets before switching");
62676274

62686275
ZFS_MODULE_PARAM(zfs_metaslab, metaslab_, force_ganging, U64, ZMOD_RW,
6269-
"Blocks larger than this size are forced to be gang blocks");
6276+
"Blocks larger than this size are sometimes forced to be gang blocks");
6277+
6278+
ZFS_MODULE_PARAM(zfs_metaslab, metaslab_, force_ganging_pct, UINT, ZMOD_RW,
6279+
"Percentage of large blocks that will be forced to be gang blocks");
62706280

62716281
ZFS_MODULE_PARAM(zfs_metaslab, metaslab_, df_max_search, UINT, ZMOD_RW,
62726282
"Max distance (bytes) to search forward before using size tree");

0 commit comments

Comments
 (0)