From 049309cc0d087c86818bf7596a0ad3ee00784004 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 21 Jun 2016 12:37:47 -0400 Subject: [PATCH] os/bluestore/bluestore_types: delta encode for ref_map offsets Signed-off-by: Sage Weil --- src/os/bluestore/bluestore_types.cc | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/os/bluestore/bluestore_types.cc b/src/os/bluestore/bluestore_types.cc index 548b21c8f07b..b1d159c2a3b8 100644 --- a/src/os/bluestore/bluestore_types.cc +++ b/src/os/bluestore/bluestore_types.cc @@ -311,9 +311,17 @@ void bluestore_extent_ref_map_t::encode(bufferlist& bl) const { 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); + if (n) { + auto p = ref_map.begin(); + small_encode_varint_lowz(p->first, bl); + p->second.encode(bl); + int32_t pos = p->first; + while (--n) { + ++p; + small_encode_signed_varint_lowz((int64_t)p->first - pos, bl); + p->second.encode(bl); + pos = p->first; + } } } @@ -321,10 +329,17 @@ void bluestore_extent_ref_map_t::decode(bufferlist::iterator& 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); + if (n) { + int64_t pos; + small_decode_varint_lowz(pos, p); + ref_map[pos].decode(p); + while (--n) { + int64_t delta; + uint64_t length; + small_decode_signed_varint_lowz(delta, p); + pos += delta; + ref_map[pos].decode(p); + } } } -- 2.47.3