]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: add compressed_length_orig field to bluestore_blob_t to track original...
authorIgor Fedotov <ifedotov@mirantis.com>
Tue, 28 Jun 2016 12:11:36 +0000 (15:11 +0300)
committerIgor Fedotov <ifedotov@mirantis.com>
Mon, 18 Jul 2016 16:06:35 +0000 (19:06 +0300)
Signed-off-by: Igor Fedotov <ifedotov@mirantis.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/bluestore_types.cc
src/os/bluestore/bluestore_types.h

index c4ba07b251af50f52d98df5c919c8388634b5ee9..fc66885296b7a1542dd4acf1b051f664d27d936d 100644 (file)
@@ -6021,7 +6021,7 @@ int BlueStore::_do_alloc_write(
        final_length = newlen;
        csum_length = newlen;
        csum_order = ctz(newlen);
-       b->blob.set_compressed(rawlen);
+       b->blob.set_compressed(wi.blob_length, rawlen);
        compressed = true;
       } else {
        dout(20) << __func__ << hex << "  compressed 0x" << l->length()
index 44262f7a533e8e8c05375215138c43f070c4437b..48ff4ec06bbeb82450b52e58b58d466663c6dc22 100644 (file)
@@ -438,6 +438,7 @@ void bluestore_blob_t::encode(bufferlist& bl) const
   small_encode(extents, bl);
   small_encode_varint(flags, bl);
   if (is_compressed()) {
+    small_encode_varint_lowz(compressed_length_orig, bl);
     small_encode_varint_lowz(compressed_length, bl);
   }
   if (has_csum()) {
@@ -460,9 +461,10 @@ void bluestore_blob_t::decode(bufferlist::iterator& p)
   small_decode(extents, p);
   small_decode_varint(flags, p);
   if (is_compressed()) {
+    small_decode_varint_lowz(compressed_length_orig, p);
     small_decode_varint_lowz(compressed_length, p);
   } else {
-    compressed_length = 0;
+    compressed_length_orig = compressed_length = 0;
   }
   if (has_csum()) {
     small_decode_varint(csum_type, p);
@@ -490,6 +492,7 @@ void bluestore_blob_t::dump(Formatter *f) const
     f->dump_object("extent", p);
   }
   f->close_section();
+  f->dump_unsigned("compressed_length_original", compressed_length_orig);
   f->dump_unsigned("compressed_length", compressed_length);
   f->dump_unsigned("flags", flags);
   f->dump_unsigned("csum_type", csum_type);
@@ -524,7 +527,11 @@ void bluestore_blob_t::generate_test_instances(list<bluestore_blob_t*>& ls)
 ostream& operator<<(ostream& out, const bluestore_blob_t& o)
 {
   out << "blob(" << o.extents
-      << " clen 0x" << std::hex << o.compressed_length << std::dec;
+      << " clen 0x" << std::hex
+      << o.compressed_length_orig
+      << " -> " << std::hex
+      << o.compressed_length
+      << std::dec;
   if (o.flags) {
     out << " " << o.get_flags_string();
   }
index 03f36d321c6900ebaa42d9e757c6e89fa8093f73..f2e2ed70eb171f86f1c285ebb556e4b5f05adb7f 100644 (file)
@@ -223,6 +223,7 @@ struct bluestore_blob_t {
   }
 
   vector<bluestore_pextent_t> extents;///< raw data position on device
+  uint32_t compressed_length_orig = 0;///< original length of compressed blob if any
   uint32_t compressed_length = 0;     ///< compressed length if any
   uint32_t flags = 0;                 ///< FLAG_*
 
@@ -258,8 +259,9 @@ struct bluestore_blob_t {
     return get_flags_string(flags);
   }
 
-  void set_compressed(uint64_t clen) {
+  void set_compressed(uint64_t clen_orig, uint64_t clen) {
     set_flag(FLAG_COMPRESSED);
+    compressed_length_orig = clen_orig;
     compressed_length = clen;
   }
   bool is_mutable() const {
@@ -288,6 +290,9 @@ struct bluestore_blob_t {
   uint32_t get_compressed_payload_length() const {
     return is_compressed() ? compressed_length : 0;
   }
+  uint32_t get_compressed_payload_original_length() const {
+    return is_compressed() ? compressed_length_orig : 0;
+  }
   uint64_t calc_offset(uint64_t x_off, uint64_t *plen) const {
     auto p = extents.begin();
     assert(p != extents.end());