]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/bluestore_types: add length to the compression_header_t
authorSage Weil <sage@redhat.com>
Mon, 23 May 2016 19:01:40 +0000 (15:01 -0400)
committerSage Weil <sage@redhat.com>
Wed, 1 Jun 2016 15:40:48 +0000 (11:40 -0400)
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>
src/os/bluestore/BlueStore.cc
src/os/bluestore/bluestore_types.cc
src/os/bluestore/bluestore_types.h

index 907e7010f35e7b4eb128a7ac6e3fbd0e9875155d..a429ee419189104af20748754a9f4fadfb71ffe5 100644 (file)
@@ -3132,7 +3132,9 @@ int BlueStore::_decompress(bufferlist& source, bufferlist* result)
     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;
index f3de90eb70904ccc216ef0fbbdda68cebf1eb9e7..5f1f0ae397d4645250a5dba1d5f01ca99e31da05 100644 (file)
@@ -1018,6 +1018,7 @@ void bluestore_compression_header_t::encode(bufferlist& bl) const
 {
   ENCODE_START(1, 1, bl);
   ::encode(type, bl);
+  ::encode(length, bl);
   ENCODE_FINISH(bl);
 }
 
@@ -1025,12 +1026,14 @@ void bluestore_compression_header_t::decode(bufferlist::iterator& p)
 {
   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(
@@ -1038,4 +1041,5 @@ 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;
 }
index 3382c6254af306c39370dc19ce0cb55ebedf9ae0..efc971cb1f243788a66877fe7dc0ee23035bbac6 100644 (file)
@@ -704,6 +704,8 @@ WRITE_CLASS_ENCODER(bluestore_wal_transaction_t)
 
 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) {}