mirror of
https://git.proxmox.com/git/pve-installer
synced 2025-08-05 04:38:29 +00:00
run env: always return proper value for default zfs max arc size
In preparation for fixing #6285 [0]. `0` means to just skip writing the module parameter. But (especially) with the upcoming change in ZFS 2.3 - which makes the size basically that of the system memory minus 1 GiB - we want to always write some value. [0] https://bugzilla.proxmox.com/show_bug.cgi?id=6285 Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
This commit is contained in:
parent
b8176fd732
commit
54c76175f0
@ -337,14 +337,15 @@ sub default_zfs_arc_max {
|
|||||||
my $product = Proxmox::Install::ISOEnv::get('product');
|
my $product = Proxmox::Install::ISOEnv::get('product');
|
||||||
my $total_memory = query_total_memory();
|
my $total_memory = query_total_memory();
|
||||||
|
|
||||||
# By default limit PVE and low-memory systems, for all others let ZFS decide on its own by
|
# By default limit PVE and low-memory systems, for all just use the 50% of system memory
|
||||||
# returning `0`, which causes the installer to skip writing the `zfs_arc_max` module parameter.
|
|
||||||
if ($product ne 'pve') {
|
if ($product ne 'pve') {
|
||||||
return 0 if $total_memory >= 2048 && $product ne 'pmg';
|
my $zfs_default_mib = int(sprintf('%.0f', $total_memory / 2));
|
||||||
return 0 if $total_memory >= 4096; # PMG's base memory requirement is much higer
|
return $zfs_default_mib if $total_memory >= 2048 && $product ne 'pmg';
|
||||||
|
return $zfs_default_mib if $total_memory >= 4096; # PMG's base memory requirement is much higher
|
||||||
}
|
}
|
||||||
|
|
||||||
my $default_mib = $total_memory * $ZFS_ARC_SYSMEM_PERCENTAGE;
|
my $default_mib = $total_memory * $ZFS_ARC_SYSMEM_PERCENTAGE;
|
||||||
|
# int(sprintf()) rounds up instead of truncating
|
||||||
my $rounded_mib = int(sprintf('%.0f', $default_mib));
|
my $rounded_mib = int(sprintf('%.0f', $default_mib));
|
||||||
|
|
||||||
if ($rounded_mib > $ZFS_ARC_MAX_SIZE_MIB) {
|
if ($rounded_mib > $ZFS_ARC_MAX_SIZE_MIB) {
|
||||||
|
@ -21,8 +21,10 @@ sub mock_product {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
my %default_tests = (
|
use constant ZFS_ARC_MIN_MIB => 64;
|
||||||
16 => 64, # at least 64 MiB
|
|
||||||
|
my %default_tests_pve = (
|
||||||
|
16 => ZFS_ARC_MIN_MIB, # at least 64 MiB
|
||||||
1024 => 102,
|
1024 => 102,
|
||||||
4 * 1024 => 410,
|
4 * 1024 => 410,
|
||||||
8 * 1024 => 819,
|
8 * 1024 => 819,
|
||||||
@ -31,26 +33,36 @@ my %default_tests = (
|
|||||||
1024 * 1024 => 16384, # maximum of 16 GiB
|
1024 * 1024 => 16384, # maximum of 16 GiB
|
||||||
);
|
);
|
||||||
|
|
||||||
while (my ($total_mem, $expected) = each %default_tests) {
|
my %default_tests_others = (
|
||||||
|
16 => ZFS_ARC_MIN_MIB, # at least 64 MiB
|
||||||
|
1024 => 102,
|
||||||
|
4 * 1024 => 2048,
|
||||||
|
8 * 1024 => 4096,
|
||||||
|
150 * 1024 => 76800,
|
||||||
|
160 * 1024 => 81920,
|
||||||
|
1024 * 1024 => 524288,
|
||||||
|
);
|
||||||
|
|
||||||
|
mock_product('pve');
|
||||||
|
while (my ($total_mem, $expected) = each %default_tests_pve) {
|
||||||
$proxmox_install_runenv->redefine(
|
$proxmox_install_runenv->redefine(
|
||||||
query_total_memory => sub { return $total_mem; },
|
query_total_memory => sub { return $total_mem; },
|
||||||
);
|
);
|
||||||
|
|
||||||
mock_product('pve');
|
|
||||||
is(Proxmox::Install::RunEnv::default_zfs_arc_max(), $expected,
|
is(Proxmox::Install::RunEnv::default_zfs_arc_max(), $expected,
|
||||||
"$expected MiB should be zfs_arc_max for PVE with $total_mem MiB system memory");
|
"zfs_arc_max should default to $expected for pve with $total_mem MiB system memory");
|
||||||
|
}
|
||||||
|
|
||||||
mock_product('pbs');
|
while (my ($total_mem, $expected) = each %default_tests_others) {
|
||||||
is(Proxmox::Install::RunEnv::default_zfs_arc_max(), $total_mem < 2048 ? $expected : 0,
|
$proxmox_install_runenv->redefine(
|
||||||
"zfs_arc_max should default to `0` for PBS with $total_mem MiB system memory");
|
query_total_memory => sub { return $total_mem; },
|
||||||
|
);
|
||||||
|
|
||||||
mock_product('pmg');
|
foreach my $product ('pbs', 'pmg', 'pdm') {
|
||||||
is(Proxmox::Install::RunEnv::default_zfs_arc_max(), $total_mem < 4096 ? $expected : 0,
|
mock_product($product);
|
||||||
"zfs_arc_max should default to `0` for PMG with $total_mem MiB system memory");
|
is(Proxmox::Install::RunEnv::default_zfs_arc_max(), $expected,
|
||||||
|
"zfs_arc_max should default to $expected for $product with $total_mem MiB system memory");
|
||||||
mock_product('pdm');
|
}
|
||||||
is(Proxmox::Install::RunEnv::default_zfs_arc_max(), $total_mem < 2048 ? $expected : 0,
|
|
||||||
"zfs_arc_max should default to `0` for PDM with $total_mem MiB system memory");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my @clamp_tests = (
|
my @clamp_tests = (
|
||||||
|
Loading…
Reference in New Issue
Block a user