]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os/bluestore: version shard and spanning blob buffers, not each blob
authorSage Weil <sage@redhat.com>
Wed, 14 Dec 2016 20:09:36 +0000 (15:09 -0500)
committerSage Weil <sage@redhat.com>
Wed, 14 Dec 2016 20:09:36 +0000 (15:09 -0500)
Instead of versioning every blob encoding, and adding a full byte
per blob, instead version the entire shard or spanning blob
chunk, since they are always encoded together.

We overload the 'features' argument here to pass through a
struct_v.  This is slightly abusing an argument that is normally
used for feature bits, but only slightly.

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h
src/os/bluestore/bluestore_types.h

index c813859d6b88f77c3c9b8e2eacacd723a7432c9b..2e8e66a17850804442922ca052153ab010e2474c 100644 (file)
@@ -1790,8 +1790,11 @@ bool BlueStore::ExtentMap::encode_some(uint32_t offset, uint32_t length,
   auto start = extent_map.lower_bound(dummy);
   uint32_t end = offset + length;
 
+  __u8 struct_v = 1;
+
   unsigned n = 0;
   size_t bound = 0;
+  denc(struct_v, bound);
   denc_varint(0, bound);
   for (auto p = start;
        p != extent_map.end() && p->logical_offset < end;
@@ -1807,11 +1810,12 @@ bool BlueStore::ExtentMap::encode_some(uint32_t offset, uint32_t length,
     denc_varint(0, bound); // logical_offset
     denc_varint(0, bound); // len
     denc_varint(0, bound); // blob_offset
-    p->blob->bound_encode(bound, false);
+    p->blob->bound_encode(bound, struct_v, false);
   }
 
   {
     auto app = bl.get_contiguous_appender(bound);
+    denc(struct_v, app);
     denc_varint(n, app);
     if (pn) {
       *pn = n;
@@ -1858,7 +1862,7 @@ bool BlueStore::ExtentMap::encode_some(uint32_t offset, uint32_t length,
       }
       pos = p->logical_end();
       if (include_blob) {
-       p->blob->encode(app, false);
+       p->blob->encode(app, struct_v, false);
       }
     }
   }
@@ -1880,6 +1884,9 @@ void BlueStore::ExtentMap::decode_some(bufferlist& bl)
 
   assert(bl.get_num_buffers() <= 1);
   auto p = bl.front().begin_deep();
+  __u8 struct_v;
+  denc(struct_v, p);
+  assert(struct_v == 1);
   uint32_t num;
   denc_varint(num, p);
   vector<BlobRef> blobs(num);
@@ -1915,7 +1922,7 @@ void BlueStore::ExtentMap::decode_some(bufferlist& bl)
        assert(le->blob);
       } else {
        Blob *b = new Blob();
-       b->decode(p, false);
+       b->decode(p, struct_v, false);
        blobs[n] = b;
        onode->c->open_shared_blob(b);
        le->assign_blob(b);
@@ -1933,22 +1940,26 @@ void BlueStore::ExtentMap::decode_some(bufferlist& bl)
 
 void BlueStore::ExtentMap::bound_encode_spanning_blobs(size_t& p)
 {
+  __u8 struct_v = 1;
+  denc(struct_v, p);
   denc_varint((uint32_t)0, p);
   size_t key_size = 0;
   denc_varint((uint32_t)0, key_size);
   p += spanning_blob_map.size() * key_size;
   for (const auto& i : spanning_blob_map) {
-    i.second->bound_encode(p, true);
+    i.second->bound_encode(p, struct_v, true);
   }
 }
 
 void BlueStore::ExtentMap::encode_spanning_blobs(
   bufferlist::contiguous_appender& p)
 {
+  __u8 struct_v = 1;
+  denc(struct_v, p);
   denc_varint(spanning_blob_map.size(), p);
   for (auto& i : spanning_blob_map) {
     denc_varint(i.second->id, p);
-    i.second->encode(p, true);
+    i.second->encode(p, struct_v, true);
   }
 }
 
@@ -1956,13 +1967,16 @@ void BlueStore::ExtentMap::decode_spanning_blobs(
   Collection *c,
   bufferptr::iterator& p)
 {
+  __u8 struct_v;
+  denc(struct_v, p);
+  assert(struct_v == 1);
   unsigned n;
   denc_varint(n, p);
   while (n--) {
     BlobRef b(new Blob());
     denc_varint(b->id, p);
     spanning_blob_map[b->id] = b;
-    b->decode(p, true);
+    b->decode(p, struct_v, true);
     c->open_shared_blob(b);
   }
 }
index 07fe50bc0b89f1ee1c0e05646d1d3aff77f0c727..0633bf7983d007890680726569dca797ef394ea3 100644 (file)
@@ -534,20 +534,22 @@ public:
       }
     }
 #else
-    void bound_encode(size_t& p, bool include_ref_map) const {
-      denc(blob, p);
+    void bound_encode(size_t& p, uint64_t struct_v, bool include_ref_map) const {
+      denc(blob, p, struct_v);
       if (include_ref_map) {
         ref_map.bound_encode(p);
       }
     }
-    void encode(bufferlist::contiguous_appender& p, bool include_ref_map) const {
-      denc(blob, p);
+    void encode(bufferlist::contiguous_appender& p, uint64_t struct_v,
+               bool include_ref_map) const {
+      denc(blob, p, struct_v);
       if (include_ref_map) {
         ref_map.encode(p);
       }
     }
-    void decode(bufferptr::iterator& p, bool include_ref_map) {
-      denc(blob, p);
+    void decode(bufferptr::iterator& p, uint64_t struct_v,
+               bool include_ref_map) {
+      denc(blob, p, struct_v);
       if (include_ref_map) {
         ref_map.decode(p);
       }
index 5f7fe18776a52bcda9759dbb5fe13fe552ce6978..571448da0eba90ebf63508278851acf4a70b6c36 100644 (file)
@@ -297,8 +297,8 @@ struct bluestore_blob_t {
   bluestore_blob_t(uint32_t f = 0) : flags(f) {}
 
   DENC_HELPERS;
-  void bound_encode(size_t& p) const {
-    p += 1;
+  void bound_encode(size_t& p, uint64_t struct_v) const {
+    assert(struct_v == 1);
     denc(extents, p);
     denc_varint(flags, p);
     denc_varint(sbid, p);
@@ -310,9 +310,8 @@ struct bluestore_blob_t {
     p += sizeof(unsigned long long);
   }
 
-  void encode(bufferlist::contiguous_appender& p) const {
-    __u8 struct_v = 1;
-    denc(struct_v, p);
+  void encode(bufferlist::contiguous_appender& p, uint64_t struct_v) const {
+    assert(struct_v == 1);
     denc(extents, p);
     denc_varint(flags, p);
     if (is_shared()) {
@@ -332,9 +331,7 @@ struct bluestore_blob_t {
     }
   }
 
-  void decode(bufferptr::iterator& p) {
-    __u8 struct_v;
-    denc(struct_v, p);
+  void decode(bufferptr::iterator& p, uint64_t struct_v) {
     assert(struct_v == 1);
     denc(extents, p);
     denc_varint(flags, p);
@@ -639,7 +636,7 @@ struct bluestore_blob_t {
     }
   }
 };
-WRITE_CLASS_DENC(bluestore_blob_t)
+WRITE_CLASS_DENC_FEATURED(bluestore_blob_t)
 
 ostream& operator<<(ostream& out, const bluestore_blob_t& o);