Project

General

Profile

Bug #40831 » use-system-zstd-and-fix-zstd-1.4.0-compatbility.patch

Thore Bödecker, 07/19/2019 11:17 AM

View differences:

src/compressor/zstd/ZstdCompressor.h 2019-04-25 20:15:48.000000000 +0200 → src/compressor/zstd/ZstdCompressor.h 2019-07-17 19:11:33.177014923 +0200
#define CEPH_ZSTDCOMPRESSOR_H
#define ZSTD_STATIC_LINKING_ONLY
#include "zstd/lib/zstd.h"
#include <zstd.h>
#include "include/buffer.h"
#include "include/encoding.h"
......
int compress(const bufferlist &src, bufferlist &dst) override {
ZSTD_CStream *s = ZSTD_createCStream();
ZSTD_initCStream_srcSize(s, COMPRESSION_LEVEL, src.length());
// ZSTD_initCStream_srcSize(s, COMPRESSION_LEVEL, src.length());
ZSTD_CCtx_reset(s, ZSTD_reset_session_only);
ZSTD_CCtx_refCDict(s, NULL); // clear the dictionary (if any)
ZSTD_CCtx_setParameter(s, ZSTD_c_compressionLevel, COMPRESSION_LEVEL);
ZSTD_CCtx_setPledgedSrcSize(s, src.length());
auto p = src.begin();
size_t left = src.length();
......
inbuf.size = p.get_ptr_and_advance(left, (const char**)&inbuf.src);
left -= inbuf.size;
ZSTD_EndDirective const zed = (left==0) ? ZSTD_e_end : ZSTD_e_continue;
size_t r = ZSTD_compress_generic(s, &outbuf, &inbuf, zed);
size_t r = ZSTD_compressStream2(s, &outbuf, &inbuf, zed);
if (ZSTD_isError(r)) {
return -EINVAL;
}
(1-1/3)