}
}
-void BlueStore::Blob::decode(
- bufferptr::const_iterator& p,
- uint64_t struct_v,
- uint64_t* sbid,
- bool include_ref_map,
- Collection *coll)
-{
- denc(blob, p, struct_v);
- if (blob.is_shared()) {
- denc(*sbid, p);
- }
- if (include_ref_map) {
- if (struct_v > 1) {
- used_in_blob.decode(p);
- } else {
- used_in_blob.clear();
- bluestore_extent_ref_map_t legacy_ref_map;
- legacy_ref_map.decode(p);
- if (coll) {
- for (auto r : legacy_ref_map.ref_map) {
- get_ref(
- coll,
- r.first,
- r.second.refs * r.second.length);
- }
- }
- }
- }
-}
-
// Extent
void BlueStore::Extent::dump(Formatter* f) const
consume_blobid(le, false, blobid - 1);
} else {
// dummy onodes might not have collections, we need a check for it.
- BlobRef b = c ? c->new_blob() : new Blob(nullptr);
uint64_t sbid = 0;
- b->decode(p, struct_v, &sbid, false, c);
+ BlobRef b = decode_create_blob(p, struct_v, &sbid, false, c);
consume_blob(le, extent_pos, sbid, b);
}
}
unsigned n;
denc_varint(n, p);
while (n--) {
- BlobRef b = c ? c->new_blob() : new Blob(nullptr);
- denc_varint(b->id, p);
+ decltype(Blob::id) id;
+ denc_varint(id, p);
+
uint64_t sbid = 0;
- b->decode(p, struct_v, &sbid, true, c);
+ BlobRef b = decode_create_blob(p, struct_v, &sbid, true, c);
+ b->id = id;
consume_spanning_blob(sbid, b);
}
}
/////////////////// BlueStore::ExtentMap::DecoderExtentFull ///////////
+
+BlueStore::BlobRef BlueStore::ExtentMap::ExtentDecoderFull::decode_create_blob(
+ bptr_c_it_t& p,
+ __u8 struct_v,
+ uint64_t* sbid,
+ bool include_ref_map,
+ Collection* c) {
+ BlobRef b = c ? c->new_blob() : new Blob(nullptr);
+ b->decode<true>(p, struct_v, sbid, include_ref_map, c);
+ return b;
+}
+
void BlueStore::ExtentMap::ExtentDecoderFull::consume_blobid(
BlueStore::Extent* le, bool spanning, uint64_t blobid) {
ceph_assert(le);
sbmap->set(offset >> min_alloc_size_order, length >> min_alloc_size_order);
}
+BlueStore::BlobRef BlueStore::ExtentDecoderPartial::decode_create_blob(
+ bptr_c_it_t& p,
+ __u8 struct_v,
+ uint64_t* sbid,
+ bool include_ref_map,
+ Collection* c) {
+ BlobRef b = c ? c->new_blob() : new Blob(nullptr);
+ b->decode<true>(p, struct_v, sbid, include_ref_map, c);
+ return b;
+}
void BlueStore::ExtentDecoderPartial::_consume_new_blob(bool spanning,
uint64_t extent_no,
uint64_t sbid,
used_in_blob.encode(p);
}
}
+ template <bool decode_csum = true>
void decode(
ceph::buffer::ptr::const_iterator& p,
uint64_t struct_v,
uint64_t* sbid,
bool include_ref_map,
- Collection *coll);
+ Collection *coll) {
+ if constexpr (decode_csum)
+ blob.decode<true>(p, struct_v);
+ else
+ blob.decode<false>(p, struct_v);
+ if (blob.is_shared()) {
+ denc(*sbid, p);
+ }
+ if (include_ref_map) {
+ if (struct_v > 1) {
+ used_in_blob.decode(p);
+ } else {
+ used_in_blob.clear();
+ bluestore_extent_ref_map_t legacy_ref_map;
+ legacy_ref_map.decode(p);
+ if (coll) {
+ for (const auto& r : legacy_ref_map.ref_map) {
+ get_ref(coll, r.first, r.second.refs * r.second.length);
+ }
+ }
+ }
+ }
+ }
};
+
typedef boost::intrusive_ptr<Blob> BlobRef;
typedef mempool::bluestore_cache_meta::map<int,BlobRef> blob_map_t;
uint64_t prev_len = 0;
uint64_t extent_pos = 0;
protected:
+ // Decodes Blob from bitstream.
+ // The returned Blob is then used in \ref consume_blob or \ref consume_spanning_blob
+ virtual BlobRef decode_create_blob(
+ bptr_c_it_t& p,
+ __u8 struct_v,
+ uint64_t* sbid, // shared blobid, is Blob turns out to be shared blob
+ bool include_ref_map, // only spanning blobs have references stored
+ Collection* c) = 0;
+
virtual void consume_blobid(Extent* le,
bool spanning,
uint64_t blobid) = 0;
ExtentMap& extent_map;
std::vector<BlobRef> blobs;
protected:
+ BlobRef decode_create_blob(
+ bptr_c_it_t& p,
+ __u8 struct_v,
+ uint64_t* sbid,
+ bool include_ref_map,
+ Collection* c) override;
+
void consume_blobid(Extent* le, bool spanning, uint64_t blobid) override;
void consume_blob(Extent* le,
uint64_t extent_no,
volatile_statfs* per_pool_statfs = nullptr;
blob_map_t blobs;
blob_map_t spanning_blobs;
-
+ virtual BlobRef decode_create_blob(
+ bptr_c_it_t& p,
+ __u8 struct_v,
+ uint64_t* sbid,
+ bool include_ref_map,
+ Collection* c) override;
void _consume_new_blob(bool spanning,
uint64_t extent_no,
uint64_t sbid,
denc(unused, p);
}
}
-
- void decode(ceph::buffer::ptr::const_iterator& p, uint64_t struct_v) {
+ struct empty_context_t {};
+ template <bool decode_csum = true, typename context_t = empty_context_t>
+ void decode(ceph::buffer::ptr::const_iterator& p, uint64_t struct_v,
+ context_t context = empty_context_t()) {
ceph_assert(struct_v == 1 || struct_v == 2);
denc(extents, p);
denc_varint(flags, p);
denc(csum_chunk_order, p);
int len;
denc_varint(len, p);
- csum_data = p.get_ptr(len);
- csum_data.reassign_to_mempool(mempool::mempool_bluestore_cache_other);
+ if (decode_csum) {
+ csum_data = p.get_ptr(len);
+ csum_data.reassign_to_mempool(mempool::mempool_bluestore_cache_other);
+ } else {
+ p += len;
+ }
}
if (has_unused()) {
denc(unused, p);