From 3fcb8ac063cb1a1fba47914471730a7a8db90b00 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 19 Jun 2016 06:29:40 -0400 Subject: [PATCH] os/bluestore: varint or lba encode pextent, lextent, ref_map, onode Certainly not done here, but this is a start. Signed-off-by: Sage Weil --- src/os/bluestore/bluestore_types.cc | 43 +++++++++++++++++------------ src/os/bluestore/bluestore_types.h | 17 ++++++------ 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/os/bluestore/bluestore_types.cc b/src/os/bluestore/bluestore_types.cc index 6bbc851b50071..0173c8ecafa82 100644 --- a/src/os/bluestore/bluestore_types.cc +++ b/src/os/bluestore/bluestore_types.cc @@ -286,16 +286,23 @@ bool bluestore_extent_ref_map_t::intersects( void bluestore_extent_ref_map_t::encode(bufferlist& bl) const { - ENCODE_START(1, 1, bl); - ::encode(ref_map, bl); - ENCODE_FINISH(bl); + uint32_t n = ref_map.size(); + small_encode_varint(n, bl); + for (auto& p : ref_map) { + small_encode_varint_lowz(p.first, bl); + p.second.encode(bl); + } } void bluestore_extent_ref_map_t::decode(bufferlist::iterator& p) { - DECODE_START(1, p); - ::decode(ref_map, p); - DECODE_FINISH(p); + uint32_t n; + small_decode_varint(n, p); + while (n--) { + uint64_t offset; + small_decode_varint_lowz(offset, p); + ref_map[offset].decode(p); + } } void bluestore_extent_ref_map_t::dump(Formatter *f) const @@ -375,28 +382,28 @@ string bluestore_blob_t::get_flags_string(unsigned flags) void bluestore_blob_t::encode(bufferlist& bl) const { ENCODE_START(1, 1, bl); - ::encode(extents, bl); - ::encode(compressed_length, bl); - ::encode(flags, bl); - ::encode(csum_type, bl); - ::encode(csum_chunk_order, bl); + small_encode_obj(extents, bl); + small_encode_varint_lowz(compressed_length, bl); + small_encode_varint(flags, bl); + small_encode_varint(csum_type, bl); + small_encode_varint(csum_chunk_order, bl); ::encode(ref_map, bl); ::encode(unused, bl); - ::encode(csum_data, bl); + small_encode_buf_lowz(csum_data, bl); ENCODE_FINISH(bl); } void bluestore_blob_t::decode(bufferlist::iterator& p) { DECODE_START(1, p); - ::decode(extents, p); - ::decode(compressed_length, p); - ::decode(flags, p); - ::decode(csum_type, p); - ::decode(csum_chunk_order, p); + small_decode_obj(extents, p); + small_decode_varint_lowz(compressed_length, p); + small_decode_varint(flags, p); + small_decode_varint(csum_type, p); + small_decode_varint(csum_chunk_order, p); ::decode(ref_map, p); ::decode(unused, p); - ::decode(csum_data, p); + small_decode_buf_lowz(csum_data, p); DECODE_FINISH(p); } diff --git a/src/os/bluestore/bluestore_types.h b/src/os/bluestore/bluestore_types.h index d149a45e181ff..dd1660e3cd20b 100644 --- a/src/os/bluestore/bluestore_types.h +++ b/src/os/bluestore/bluestore_types.h @@ -19,6 +19,7 @@ #include "include/types.h" #include "include/interval_set.h" #include "include/utime.h" +#include "include/small_encoding.h" #include "common/hobject.h" namespace ceph { @@ -72,12 +73,12 @@ struct bluestore_pextent_t { } void encode(bufferlist& bl) const { - ::encode(offset, bl); - ::encode(length, bl); + small_encode_lba(offset, bl); + small_encode_varint_lowz(length, bl); } void decode(bufferlist::iterator& p) { - ::decode(offset, p); - ::decode(length, p); + small_decode_lba(offset, p); + small_decode_varint_lowz(length, p); } void dump(Formatter *f) const; static void generate_test_instances(list& ls); @@ -94,12 +95,12 @@ struct bluestore_extent_ref_map_t { uint32_t refs; record_t(uint32_t l=0, uint32_t r=0) : length(l), refs(r) {} void encode(bufferlist& bl) const { - ::encode(length, bl); - ::encode(refs, bl); + small_encode_varint_lowz(length, bl); + small_encode_varint(refs, bl); } void decode(bufferlist::iterator& p) { - ::decode(length, p); - ::decode(refs, p); + small_decode_varint_lowz(length, p); + small_decode_varint(refs, p); } }; WRITE_CLASS_ENCODER(record_t) -- 2.39.5