log_spacemap: make zfs_log_sm_blksz tunable

Make the block size used for the log space map feature's space maps 
settable at runtime.

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Signed-off-by: Christos Longros <[email protected]>
Closes #18974
This commit is contained in:
Christos Longros authored and GitHub committed 2026-09-03 12:15:55 -07:00
1 parent 47d09bf414
commit b19fa7c97d
2 files changed
+14 -3

No files matched your search

+6
View File
@@ -346,6 +346,12 @@ This applies primarily to
.It Sy zfs_keep_log_spacemaps_at_export Ns = Ns Sy 0 Ns | Ns 1 Pq int
Prevent log spacemaps from being destroyed during pool exports and destroys.
.
.It Sy zfs_log_sm_blksz Ns = Ns Sy 131072 Ns B Po 128 KiB Pc Pq int
This is used as the block size for the space maps used for the
log space map feature.
These space maps benefit from a bigger block size
as we expect to be writing a lot of data to them at once.
.
.It Sy zfs_metaslab_segment_weight_enabled Ns = Ns Sy 1 Ns | Ns 0 Pq int
Enable/disable segment-based metaslab selection.
.
+8 -3
View File
@@ -170,7 +170,7 @@
* block size as we expect to be writing a lot of data to them at
* once.
*/
static const unsigned long zfs_log_sm_blksz = 1ULL << 17;
static int zfs_log_sm_blksz = (1 << 17);
/*
* Percentage of the overall system's memory that ZFS allows to be
@@ -1332,6 +1332,7 @@ spa_ld_log_sm_data(spa_t *spa)
uint_t pn = 0;
uint64_t ps = 0;
uint64_t nsm = 0;
uint64_t nbytes = 0;
psls = sls = avl_first(&spa->spa_sm_logs_by_txg);
while (sls != NULL) {
/* Prefetch log spacemaps up to 16 TXGs or MBs ahead. */
@@ -1383,6 +1384,7 @@ spa_ld_log_sm_data(spa_t *spa)
pn--;
ps -= space_map_length(sls->sls_sm);
nbytes += space_map_length(sls->sls_sm);
nsm++;
space_map_close(sls->sls_sm);
sls->sls_sm = NULL;
@@ -1394,10 +1396,10 @@ spa_ld_log_sm_data(spa_t *spa)
hrtime_t read_logs_endtime = gethrtime();
spa_load_note(spa,
"Read %lu log space maps (%llu total blocks - blksz = %llu bytes) "
"Read %lu log space maps (%llu total blocks - %llu total bytes) "
"in %lld ms", avl_numnodes(&spa->spa_sm_logs_by_txg),
(u_longlong_t)spa_log_sm_nblocks(spa),
(u_longlong_t)zfs_log_sm_blksz,
(u_longlong_t)nbytes,
(longlong_t)NSEC2MSEC(read_logs_endtime - read_logs_starttime));
out:
@@ -1575,6 +1577,9 @@ ZFS_MODULE_PARAM(zfs, zfs_, keep_log_spacemaps_at_export, INT, ZMOD_RW,
"Prevent the log spacemaps from being flushed and destroyed "
"during pool export/destroy");
ZFS_MODULE_PARAM(zfs, zfs_, log_sm_blksz, INT, ZMOD_RW,
"Block size for the space maps used for the log space map feature");
ZFS_MODULE_PARAM(zfs, zfs_, max_logsm_summary_length, U64, ZMOD_RW,
"Maximum number of rows allowed in the summary of the spacemap log");