/* * For compression we enable all used compressors in the fileset. */ bool adjust_compression_buffers(JCR *jcr) { findFILESET *fileset = jcr->ff->fileset; uint32_t compress_buf_size = 0; if (fileset) { int i, j; for (i = 0; i < fileset->include_list.size(); i++) { findINCEXE *incexe = (findINCEXE *)fileset->include_list.get(i); for (j = 0; j < incexe->opts_list.size(); j++) { findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j); if (!setup_compression_buffers(jcr, me->compatible, fo->Compress_algo, &compress_buf_size)) { return false; } } } if (compress_buf_size > 0) { jcr->compress.deflate_buffer = get_memory(compress_buf_size); jcr->compress.deflate_buffer_size = compress_buf_size; } } return true; }
/* * Setup deflate for auto deflate of data streams. */ static bool setup_auto_deflation(DCR *dcr) { JCR *jcr = dcr->jcr; bool retval = false; uint32_t compress_buf_size = 0; if (jcr->buf_size == 0) { jcr->buf_size = DEFAULT_NETWORK_BUFFER_SIZE; } if (!setup_compression_buffers(jcr, sd_enabled_compatible, dcr->device->autodeflate_algorithm, &compress_buf_size)) { goto bail_out; } /* * See if we need to create a new compression buffer or make sure the existing is big enough. */ if (!jcr->compress.deflate_buffer) { jcr->compress.deflate_buffer = get_memory(compress_buf_size); jcr->compress.deflate_buffer_size = compress_buf_size; } else { if (compress_buf_size > jcr->compress.deflate_buffer_size) { jcr->compress.deflate_buffer = realloc_pool_memory(jcr->compress.deflate_buffer, compress_buf_size); jcr->compress.deflate_buffer_size = compress_buf_size; } } switch (dcr->device->autodeflate_algorithm) { #if defined(HAVE_LIBZ) case COMPRESS_GZIP: { int zstat; z_stream *pZlibStream; pZlibStream = (z_stream *)jcr->compress.workset.pZLIB; if ((zstat = deflateParams(pZlibStream, dcr->device->autodeflate_level, Z_DEFAULT_STRATEGY)) != Z_OK) { Jmsg(jcr, M_FATAL, 0, _("Compression deflateParams error: %d\n"), zstat); jcr->setJobStatus(JS_ErrorTerminated); goto bail_out; } break; } #endif #if defined(HAVE_LZO) case COMPRESS_LZO1X: break; #endif #if defined(HAVE_FASTLZ) case COMPRESS_FZFZ: case COMPRESS_FZ4L: case COMPRESS_FZ4H: { int zstat; zfast_stream *pZfastStream; zfast_stream_compressor compressor = COMPRESSOR_FASTLZ; switch (dcr->device->autodeflate_algorithm) { case COMPRESS_FZ4L: case COMPRESS_FZ4H: compressor = COMPRESSOR_LZ4; break; } pZfastStream = (zfast_stream *)jcr->compress.workset.pZFAST; if ((zstat = fastlzlibSetCompressor(pZfastStream, compressor)) != Z_OK) { Jmsg(jcr, M_FATAL, 0, _("Compression fastlzlibSetCompressor error: %d\n"), zstat); jcr->setJobStatus(JS_ErrorTerminated); goto bail_out; } break; } #endif default: break; } retval = true; bail_out: return retval; }