Skip to content

Commit 8f02983

Browse files
committed
metaslab: expose condense_pct and sm_blksz tunables on Linux
Expose zfs_metaslab_condense_pct and zfs_metaslab_sm_blksz_* as module parameters on Linux, matching their existing FreeBSD sysctls. Signed-off-by: Christos Longros <chris.longros@gmail.com>
1 parent 20d5683 commit 8f02983

4 files changed

Lines changed: 45 additions & 46 deletions

File tree

include/sys/metaslab_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ struct metaslab_group {
330330
*
331331
* As the space map grows (as a result of the appends) it will
332332
* eventually become space-inefficient. When the metaslab's in-core
333-
* free tree is zfs_condense_pct/100 times the size of the minimal
333+
* free tree is zfs_metaslab_condense_pct/100 times the size of the minimal
334334
* on-disk representation, we rewrite it in its minimized form. If a
335335
* metaslab needs to condense then we must set the ms_condensing flag to
336336
* ensure that allocations are not performed on the metaslab that is

man/man4/zfs.4

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,32 @@ This improves performance, especially when there are many metaslabs per vdev
446446
and the allocation can't actually be satisfied
447447
(so we would otherwise iterate all metaslabs).
448448
.
449+
.It Sy zfs_metaslab_sm_blksz_no_log Ns = Ns Sy 16384 Ns B Po 16 KiB Pc Pq int
450+
Block size for the metaslab space maps in pools where the
451+
.Sy log_spacemap
452+
feature is disabled.
453+
Multiple metaslabs are modified per transaction group, so a smaller block size
454+
lets more, scattered I/O operations be issued.
455+
Must be a power of 2 greater than
456+
.Sy 4096 .
457+
This parameter can only be set at module load time.
458+
.
459+
.It Sy zfs_metaslab_sm_blksz_with_log Ns = Ns Sy 131072 Ns B Po 128 KiB Pc Pq int
460+
Block size for the metaslab space maps in pools where the
461+
.Sy log_spacemap
462+
feature is enabled.
463+
Changes are batched in the per-pool log spacemap and flushed to each metaslab's
464+
space map only occasionally, so a larger block size is more efficient.
465+
Must be a power of 2 greater than
466+
.Sy 4096 .
467+
This parameter can only be set at module load time.
468+
.
469+
.It Sy zfs_metaslab_condense_pct Ns = Ns Sy 200 Ns % Pq uint
470+
Condense an on-disk space map when its size exceeds this percentage of
471+
the in-memory representation.
472+
The minimum is
473+
.Sy 100 .
474+
.
449475
.It Sy zfs_vdev_default_ms_count Ns = Ns Sy 200 Pq uint
450476
When a vdev is added, target this number of metaslabs per top-level vdev.
451477
.

module/os/freebsd/zfs/sysctl_os.c

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -289,46 +289,6 @@ param_set_active_allocator(SYSCTL_HANDLER_ARGS)
289289
return (param_set_active_allocator_common(buf));
290290
}
291291

292-
/*
293-
* In pools where the log space map feature is not enabled we touch
294-
* multiple metaslabs (and their respective space maps) with each
295-
* transaction group. Thus, we benefit from having a small space map
296-
* block size since it allows us to issue more I/O operations scattered
297-
* around the disk. So a sane default for the space map block size
298-
* is 8~16K.
299-
*/
300-
extern int zfs_metaslab_sm_blksz_no_log;
301-
302-
SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, sm_blksz_no_log,
303-
CTLFLAG_RDTUN, &zfs_metaslab_sm_blksz_no_log, 0,
304-
"Block size for space map in pools with log space map disabled. "
305-
"Power of 2 greater than 4096.");
306-
307-
/*
308-
* When the log space map feature is enabled, we accumulate a lot of
309-
* changes per metaslab that are flushed once in a while so we benefit
310-
* from a bigger block size like 128K for the metaslab space maps.
311-
*/
312-
extern int zfs_metaslab_sm_blksz_with_log;
313-
314-
SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, sm_blksz_with_log,
315-
CTLFLAG_RDTUN, &zfs_metaslab_sm_blksz_with_log, 0,
316-
"Block size for space map in pools with log space map enabled. "
317-
"Power of 2 greater than 4096.");
318-
319-
/*
320-
* The in-core space map representation is more compact than its on-disk form.
321-
* The zfs_condense_pct determines how much more compact the in-core
322-
* space map representation must be before we compact it on-disk.
323-
* Values should be greater than or equal to 100.
324-
*/
325-
extern uint_t zfs_condense_pct;
326-
327-
SYSCTL_UINT(_vfs_zfs, OID_AUTO, condense_pct,
328-
CTLFLAG_RWTUN, &zfs_condense_pct, 0,
329-
"Condense on-disk spacemap when it is more than this many percents"
330-
" of in-memory counterpart");
331-
332292
/*
333293
* Minimum size which forces the dynamic allocator to change
334294
* it's allocation strategy. Once the space map cannot satisfy

module/zfs/metaslab.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ int zfs_metaslab_sm_blksz_with_log = (1 << 17);
8282

8383
/*
8484
* The in-core space map representation is more compact than its on-disk form.
85-
* The zfs_condense_pct determines how much more compact the in-core
85+
* The zfs_metaslab_condense_pct determines how much more compact the in-core
8686
* space map representation must be before we compact it on-disk.
8787
* Values should be greater than or equal to 100.
8888
*/
89-
uint_t zfs_condense_pct = 200;
89+
uint_t zfs_metaslab_condense_pct = 200;
9090

9191
/*
9292
* Condensing a metaslab is not guaranteed to actually reduce the amount of
@@ -3826,8 +3826,8 @@ metaslab_group_preload(metaslab_group_t *mg)
38263826
* increase as a result of writing out the free space range tree.
38273827
*
38283828
* 2. Condense if the on on-disk space map representation is at least
3829-
* zfs_condense_pct/100 times the size of the optimal representation
3830-
* (i.e. zfs_condense_pct = 110 and in-core = 1MB, optimal = 1.1MB).
3829+
* zfs_metaslab_condense_pct/100 times the size of the optimal representation
3830+
* (i.e. zfs_metaslab_condense_pct = 110 and in-core = 1MB, optimal = 1.1MB).
38313831
*
38323832
* 3. Do not condense if the on-disk size of the space map does not actually
38333833
* decrease.
@@ -3863,7 +3863,8 @@ metaslab_should_condense(metaslab_t *msp)
38633863
uint64_t optimal_size = space_map_estimate_optimal_size(sm,
38643864
msp->ms_allocatable, SM_NO_VDEVID);
38653865

3866-
return (object_size >= (optimal_size * zfs_condense_pct / 100) &&
3866+
return (object_size >=
3867+
(optimal_size * zfs_metaslab_condense_pct / 100) &&
38673868
object_size > zfs_metaslab_condense_block_threshold * record_size);
38683869
}
38693870

@@ -6454,6 +6455,18 @@ ZFS_MODULE_PARAM(zfs_metaslab, zfs_metaslab_, try_hard_before_gang, INT,
64546455
ZFS_MODULE_PARAM(zfs_metaslab, zfs_metaslab_, find_max_tries, UINT, ZMOD_RW,
64556456
"Normally only consider this many of the best metaslabs in each vdev");
64566457

6458+
ZFS_MODULE_PARAM(zfs_metaslab, zfs_metaslab_, sm_blksz_no_log, INT, ZMOD_RW,
6459+
"Block size for space map in pools with log space map disabled. "
6460+
"Power of 2 greater than 4096.");
6461+
6462+
ZFS_MODULE_PARAM(zfs_metaslab, zfs_metaslab_, sm_blksz_with_log, INT, ZMOD_RW,
6463+
"Block size for space map in pools with log space map enabled. "
6464+
"Power of 2 greater than 4096.");
6465+
64576466
ZFS_MODULE_PARAM_CALL(zfs, zfs_, active_allocator,
64586467
param_set_active_allocator, param_get_charp, ZMOD_RW,
64596468
"SPA active allocator");
6469+
6470+
ZFS_MODULE_PARAM(zfs_metaslab, zfs_metaslab_, condense_pct, UINT, ZMOD_RW,
6471+
"Condense on-disk spacemap when it is more than this many percents "
6472+
"of in-memory counterpart");

0 commit comments

Comments
 (0)