Snappy fails to decompress if there are extra zeros in the input buffer.
So, store the length explicitly in the header to avoid feeding them into
the decompressor.
Signed-off-by: Sage Weil <sage@redhat.com>
derr << __func__ << " can't load decompressor " << chdr.type << dendl;
r = -EIO;
} else {
- r = compressor->decompress(i, *result);
+ bufferlist t;
+ i.copy(chdr.length, t);
+ r = compressor->decompress(t, *result);
if (r < 0) {
derr << __func__ << " decompression failed with exit code " << r << dendl;
r = -EIO;
{
ENCODE_START(1, 1, bl);
::encode(type, bl);
+ ::encode(length, bl);
ENCODE_FINISH(bl);
}
{
DECODE_START(1, p);
::decode(type, p);
+ ::decode(length, p);
DECODE_FINISH(p);
}
void bluestore_compression_header_t::dump(Formatter *f) const
{
f->dump_string("type", type);
+ f->dump_unsigned("length", length);
}
void bluestore_compression_header_t::generate_test_instances(
{
o.push_back(new bluestore_compression_header_t);
o.push_back(new bluestore_compression_header_t("some_header"));
+ o.back()->length = 1234;
}
struct bluestore_compression_header_t {
std::string type;
+ uint32_t length = 0;
+
bluestore_compression_header_t() {}
bluestore_compression_header_t(const std::string& _type)
: type(_type) {}