diff --git a/btrbk b/btrbk index 081e552..9e7f2cb 100755 --- a/btrbk +++ b/btrbk @@ -54,7 +54,7 @@ my %compression = ( xz => { name => 'xz', format => 'xz', compress_cmd => [ 'xz', '-c' ], decompress_cmd => [ 'xz', '-d', '-c' ], level_min => 0, level_max => 9, threads => '-T' }, lzo => { name => 'lzo', format => 'lzo', compress_cmd => [ 'lzop', '-c' ], decompress_cmd => [ 'lzop', '-d', '-c' ], level_min => 1, level_max => 9 }, lz4 => { name => 'lz4', format => 'lz4', compress_cmd => [ 'lz4', '-c' ], decompress_cmd => [ 'lz4', '-d', '-c' ], level_min => 1, level_max => 9 }, - zstd => { name => 'zstd', format => 'zst', compress_cmd => [ 'zstd', '-c' ], decompress_cmd => [ 'zstd', '-d', '-c' ], level_min => 1, level_max => 19, threads => '-T', long => '--long=' }, + zstd => { name => 'zstd', format => 'zst', compress_cmd => [ 'zstd', '-c' ], decompress_cmd => [ 'zstd', '-d', '-c' ], level_min => 1, level_max => 19, threads => '-T', long => '--long=', adapt => '--adapt' }, ); my $compress_format_alt = join '|', map { $_->{format} } values %compression; # note: this contains duplicate alternations @@ -110,6 +110,7 @@ my %config_options = ( stream_compress_level => { default => "default", accept => [ "default" ], accept_numeric => 1 }, stream_compress_long => { default => "default", accept => [ "default" ], accept_numeric => 1 }, stream_compress_threads => { default => "default", accept => [ "default" ], accept_numeric => 1 }, + stream_compress_adapt => { default => undef, accept => [ "yes", "no" ] }, raw_target_compress => { default => undef, accept => [ "no", (keys %compression) ] }, raw_target_compress_level => { default => "default", accept => [ "default" ], accept_numeric => 1 }, @@ -737,6 +738,15 @@ sub compress_cmd_text($;$) WARN_ONCE "Long distance matching is not supported for '$cc->{name}', ignoring"; } } + if(defined($def->{adapt})) { + my $adapt_opt = $cc->{adapt}; + if($adapt_opt) { + push @cmd, $adapt_opt; + } + else { + WARN_ONCE "Adaptive compression is not supported for '$cc->{name}', ignoring"; + } + } return { cmd_text => join(' ', @cmd) }; } @@ -3994,6 +4004,7 @@ sub config_compress_hash($$) level => config_key($config, $config_key . "_level"), long => config_key($config, $config_key . "_long"), threads => config_key($config, $config_key . "_threads"), + adapt => config_key($config, $config_key . "_adapt"), }; } diff --git a/doc/btrbk.conf.5.asciidoc b/doc/btrbk.conf.5.asciidoc index eb19abd..ff5ba1c 100644 --- a/doc/btrbk.conf.5.asciidoc +++ b/doc/btrbk.conf.5.asciidoc @@ -307,6 +307,10 @@ option in ssh_config(5). Number of threads to use for . Only supported for "pigz", "pbzip2", "zstd" and recent versions of "xz". +*stream_compress_adapt* default|:: + Enable adaptive compression for . Only supported + for "zstd" (version >= 1.3.6). + *stream_buffer* |no:: Add a buffer to the btrfs send stream (locally, on uncompressed data), with a maximum size of ''. This can give a speed