From: Igor Fedotov Date: Tue, 28 Jun 2016 12:11:36 +0000 (+0300) Subject: os/bluestore: add compressed_length_orig field to bluestore_blob_t to track original... X-Git-Tag: ses5-milestone5~268^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dc23080bb643162cec489edcd75918d0bf32e7d2;p=ceph.git os/bluestore: add compressed_length_orig field to bluestore_blob_t to track original length for compressed blobs Signed-off-by: Igor Fedotov --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index c4ba07b251af..fc66885296b7 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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() diff --git a/src/os/bluestore/bluestore_types.cc b/src/os/bluestore/bluestore_types.cc index 44262f7a533e..48ff4ec06bbe 100644 --- a/src/os/bluestore/bluestore_types.cc +++ b/src/os/bluestore/bluestore_types.cc @@ -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& 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(); } diff --git a/src/os/bluestore/bluestore_types.h b/src/os/bluestore/bluestore_types.h index 03f36d321c69..f2e2ed70eb17 100644 --- a/src/os/bluestore/bluestore_types.h +++ b/src/os/bluestore/bluestore_types.h @@ -223,6 +223,7 @@ struct bluestore_blob_t { } vector 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());