Commit d67a3aaa authored by Thomas Lamprecht's avatar Thomas Lamprecht Committed by Dietmar Maurer

Added parallel compress support for vzdump with pigz.

Added a vzdump.conf option to controll gzip compression.
When 'pigz' (defaults to 0) is >0, pigz support is enabled.
When the pigz option equals 1 pigz uses #cores/2 threads,
else it spawns N threads. To use it select gzip in the web
interface and set the aproppriate option in /etc/vzdump.conf
Signed-off-by: 's avatarThomas Lamprecht <t.lamprecht@proxmox.com>
parent 7ab76d30
...@@ -189,6 +189,7 @@ sub read_vzdump_defaults { ...@@ -189,6 +189,7 @@ sub read_vzdump_defaults {
stopwait => 10, # 10 minutes stopwait => 10, # 10 minutes
mode => 'snapshot', mode => 'snapshot',
maxfiles => 1, maxfiles => 1,
pigz => 0,
}; };
my $fh = IO::File->new ("<$fn"); my $fh = IO::File->new ("<$fn");
...@@ -225,6 +226,8 @@ sub read_vzdump_defaults { ...@@ -225,6 +226,8 @@ sub read_vzdump_defaults {
$res->{'exclude-path'} = PVE::Tools::split_args($1); $res->{'exclude-path'} = PVE::Tools::split_args($1);
} elsif ($line =~ m/mode:\s*(stop|snapshot|suspend)\s*$/) { } elsif ($line =~ m/mode:\s*(stop|snapshot|suspend)\s*$/) {
$res->{mode} = $1; $res->{mode} = $1;
} elsif($line =~ m/pigz:\s*(\d+)\s*/) {
$res->{pigz} = $1;
} else { } else {
debugmsg ('warn', "unable to parse configuration file '$fn' - error at line " . $., undef, 1); debugmsg ('warn', "unable to parse configuration file '$fn' - error at line " . $., undef, 1);
} }
...@@ -678,14 +681,22 @@ sub run_hook_script { ...@@ -678,14 +681,22 @@ sub run_hook_script {
} }
sub compressor_info { sub compressor_info {
my ($opt_compress) = @_; my ($opts) = @_;
my $opt_compress = $opts->{compress};
if (!$opt_compress || $opt_compress eq '0') { if (!$opt_compress || $opt_compress eq '0') {
return undef; return undef;
} elsif ($opt_compress eq '1' || $opt_compress eq 'lzo') { } elsif ($opt_compress eq '1' || $opt_compress eq 'lzo') {
return ('lzop', 'lzo'); return ('lzop', 'lzo');
} elsif ($opt_compress eq 'gzip') { } elsif ($opt_compress eq 'gzip') {
return ('gzip', 'gz'); 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);
return ("pigz -p ${pigz_threads}", 'gz');
} else {
return ('gzip', 'gz');
}
} else { } else {
die "internal error - unknown compression option '$opt_compress'"; die "internal error - unknown compression option '$opt_compress'";
} }
...@@ -748,7 +759,7 @@ sub exec_backup_task { ...@@ -748,7 +759,7 @@ sub exec_backup_task {
my $logfile = $task->{logfile} = "$opts->{dumpdir}/$basename.log"; my $logfile = $task->{logfile} = "$opts->{dumpdir}/$basename.log";
my $ext = $vmtype eq 'qemu' ? '.vma' : '.tar'; my $ext = $vmtype eq 'qemu' ? '.vma' : '.tar';
my ($comp, $comp_ext) = compressor_info($opts->{compress}); my ($comp, $comp_ext) = compressor_info($opts);
if ($comp && $comp_ext) { if ($comp && $comp_ext) {
$ext .= ".${comp_ext}"; $ext .= ".${comp_ext}";
} }
...@@ -1123,6 +1134,13 @@ my $confdesc = { ...@@ -1123,6 +1134,13 @@ my $confdesc = {
enum => ['0', '1', 'gzip', 'lzo'], enum => ['0', '1', 'gzip', 'lzo'],
default => 'lzo', default => 'lzo',
}, },
pigz=> {
type => "integer",
description => "Uses pigz instead of gzip when N>0.".
" N=1 uses half of cores, N>1 uses N as thread count.",
optional => 1,
default => 0,
},
quiet => { quiet => {
type => 'boolean', type => 'boolean',
description => "Be quiet.", description => "Be quiet.",
......
...@@ -12,3 +12,4 @@ ...@@ -12,3 +12,4 @@
#maxfiles: N #maxfiles: N
#script: FILENAME #script: FILENAME
#exclude-path: PATHLIST #exclude-path: PATHLIST
#pigz: N:
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment