metaslab: add tuneables to better control when to force ganging

Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
(cherry picked from commit cf152e9d4da8fc82c940355ba444de915a00d754)
This commit is contained in:
Rob Norris 2023-07-21 09:26:20 +10:00 committed by Geoff Amey
parent 564e07e5c8
commit f615207ee6
1 changed files with 12 additions and 2 deletions

View File

@ -58,6 +58,11 @@ unsigned long metaslab_aliquot = 512 << 10;
*/ */
unsigned long metaslab_force_ganging = SPA_MAXBLOCKSIZE + 1; unsigned long metaslab_force_ganging = SPA_MAXBLOCKSIZE + 1;
/*
* Of blocks of size >= metaslab_force_ganging, actually gang them this often.
*/
unsigned long metaslab_force_ganging_pct = 3;
/* /*
* In pools where the log space map feature is not enabled we touch * In pools where the log space map feature is not enabled we touch
* multiple metaslabs (and their respective space maps) with each * multiple metaslabs (and their respective space maps) with each
@ -5131,7 +5136,9 @@ metaslab_alloc_dva(spa_t *spa, metaslab_class_t *mc, uint64_t psize,
* damage can result in extremely long reconstruction times. This * damage can result in extremely long reconstruction times. This
* will also test spilling from special to normal. * will also test spilling from special to normal.
*/ */
if (psize >= metaslab_force_ganging && (random_in_range(100) < 3)) { if (psize >= metaslab_force_ganging &&
metaslab_force_ganging_pct > 0 &&
(random_in_range(100) < MIN(metaslab_force_ganging_pct, 100))) {
metaslab_trace_add(zal, NULL, NULL, psize, d, TRACE_FORCE_GANG, metaslab_trace_add(zal, NULL, NULL, psize, d, TRACE_FORCE_GANG,
allocator); allocator);
return (SET_ERROR(ENOSPC)); return (SET_ERROR(ENOSPC));
@ -6286,7 +6293,10 @@ ZFS_MODULE_PARAM(zfs_metaslab, zfs_metaslab_, switch_threshold, INT, ZMOD_RW,
"Segment-based metaslab selection maximum buckets before switching"); "Segment-based metaslab selection maximum buckets before switching");
ZFS_MODULE_PARAM(zfs_metaslab, metaslab_, force_ganging, ULONG, ZMOD_RW, ZFS_MODULE_PARAM(zfs_metaslab, metaslab_, force_ganging, ULONG, ZMOD_RW,
"Blocks larger than this size are forced to be gang blocks"); "Blocks larger than this size are sometimes forced to be gang blocks");
ZFS_MODULE_PARAM(zfs_metaslab, metaslab_, force_ganging_pct, ULONG, ZMOD_RW,
"Percentage of large blocks that will be forced to be gang blocks");
ZFS_MODULE_PARAM(zfs_metaslab, metaslab_, df_max_search, INT, ZMOD_RW, ZFS_MODULE_PARAM(zfs_metaslab, metaslab_, df_max_search, INT, ZMOD_RW,
"Max distance (bytes) to search forward before using size tree"); "Max distance (bytes) to search forward before using size tree");