From 8555b100bb7af2a1e85786f828b374faeeac5482 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Wed, 13 Sep 2017 11:10:57 +0200 Subject: [PATCH] vzdump/pigz: use ProcFSTools for core count, not sysconf A "sysconf(84)" is not really descripitve. There is no POSIX const entry for _SC_NPROCESSORS_ONLN (number of processors online) as its not standard but an adoption of glibc. Better just use our proven ProcFSTool's cpuinfo method for getting the desired information. This is kept only for backwards compatibillity as we guaranteed that we use #cpus/2 if 'pigz' is set to 1, else I would have removed this alltogether and just directly passed 'pigz' to the command... Signed-off-by: Thomas Lamprecht --- PVE/VZDump.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm index 004672d1..b6209765 100644 --- a/PVE/VZDump.pm +++ b/PVE/VZDump.pm @@ -727,9 +727,11 @@ sub compressor_info { return ('lzop', 'lzo'); } elsif ($opt_compress eq 'gzip') { if ($opts->{pigz} > 0) { - # As default use int((#cores + 1)/2), we need #cores+1 for the case that #cores = 1 - my $cores = POSIX::sysconf(84); - my $pigz_threads = ($opts->{pigz} > 1) ? $opts->{pigz} : int(($cores + 1)/2); + my $pigz_threads = $opts->{pigz}; + if ($pigz_threads == 1) { + my $cpuinfo = PVE::ProcFSTools::read_cpuinfo(); + $pigz_threads = int(($cpuinfo->{cpus} + 1)/2); + } return ("pigz -p ${pigz_threads}", 'gz'); } else { return ('gzip', 'gz');