]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/cas/cls_cas_internal: varint for refs_by_hash
authorSage Weil <sage@newdream.net>
Thu, 21 May 2020 19:12:30 +0000 (14:12 -0500)
committerSage Weil <sage@newdream.net>
Wed, 27 May 2020 16:30:35 +0000 (11:30 -0500)
Signed-off-by: Sage Weil <sage@newdream.net>
src/cls/cas/cls_cas_internal.cc

index fa30b431a412f22b07729f1031924b4c0f16bcd5..cbc9e70d41002cd18089c45639e9e7c265adb06e 100644 (file)
@@ -89,10 +89,35 @@ struct refs_by_hash : public chunk_obj_refcount::refs_t {
     --total;
     return true;
   }
-  DENC(refs_by_hash, v, p) {
+  DENC_HELPERS
+  void bound_encode(size_t& p) const {
+    p += 6 + sizeof(uint64_t) + by_hash.size() * (10 + 10);
+  }
+  void encode(::ceph::buffer::list::contiguous_appender& p) const {
     DENC_START(1, 1, p);
-    denc(v.total, p);
-    denc(v.by_hash, p);
+    denc_varint(total, p);
+    denc_varint(by_hash.size(), p);
+    for (auto& i : by_hash) {
+      denc_signed_varint(i.first.first, p);
+      denc(i.first.second, p);
+      denc_varint(i.second, p);
+    }
+    DENC_FINISH(p);
+  }
+  void decode(::ceph::buffer::ptr::const_iterator& p) {
+    DENC_START(1, 1, p);
+    denc_varint(total, p);
+    uint64_t n;
+    denc_varint(n, p);
+    while (n--) {
+      int64_t poolid;
+      uint32_t hash;
+      uint64_t count;
+      denc_signed_varint(poolid, p);
+      denc(hash, p);
+      denc_varint(count, p);
+      by_hash[make_pair(poolid, hash)] = count;
+    }
     DENC_FINISH(p);
   }
   void dump(Formatter *f) const override {