[pve-devel] [PATCH v2 manager 3/3] fix #2559: vzdump: handle pigz blocksize property
Thomas Lamprecht
t.lamprecht at proxmox.com
Fri Feb 7 16:55:30 CET 2020
On 2/4/20 3:56 PM, Moayad Almalat wrote:
> From: Moayad <m.almalat at proxmox.com>
>
> potentially improves backup speed.
>
> Signed-off-by: Moayad <m.almalat at proxmox.com>
> ---
> PVE/VZDump.pm | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
> index 0f04d4db..232f0550 100644
> --- a/PVE/VZDump.pm
> +++ b/PVE/VZDump.pm
> @@ -592,7 +592,12 @@ sub compressor_info {
> my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
> $pigz_threads = int(($cpuinfo->{cpus} + 1)/2);
> }
> - return ("pigz -p ${pigz_threads} --rsyncable", 'gz');
> + my $pigz_cmd = "pigz -p ${pigz_threads} --rsyncable";
> + my $pigz_blocksize = $opts->{pigz}->{blocksize};
> + if (defined($pigz_blocksize)) {
> + $pigz_cmd .= " -b ${pigz_blocksize}";
> + }
> + return ($pigz_cmd, 'gz');
OK, seems fine. I'd maybe add some limits for the blocksize
property through setting minimum => 1 and then you could do
just something like:
my $pigz_cmd = "pigz -p ${pigz_threads} --rsyncable";
if (my $pigz_blocksize = $opts->{pigz}->{blocksize}) {
$pigz_cmd .= " -b ${pigz_blocksize}";
}
Makes it a bit more concise. FYI, in general you can also do
if (defined(my $foo = expression)) {
print "foo is defined: $foo\n";
}
sometimes it allows for slightly shorter code.
> } else {
> return ('gzip --rsyncable', 'gz');
> }
>
More information about the pve-devel
mailing list