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 <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2017-09-13 11:10:57 +02:00 committed by Wolfgang Bumiller
parent 1c62fde24d
commit 8555b100bb

View File

@ -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');