]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/messages/MOSDMap.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / messages / MOSDMap.h
index 9a5062c64ce6703520903283f003b48c698e2f35..41728b7f8bfca36443f6f33385d09e1d41375ccc 100644 (file)
 #include "osd/OSDMap.h"
 #include "include/ceph_features.h"
 
-class MOSDMap : public MessageInstance<MOSDMap> {
-public:
-  friend factory;
+class MOSDMap : public Message {
 private:
   static constexpr int HEAD_VERSION = 4;
   static constexpr int COMPAT_VERSION = 3;
 
- public:
+public:
   uuid_d fsid;
   uint64_t encode_features = 0;
-  map<epoch_t, bufferlist> maps;
-  map<epoch_t, bufferlist> incremental_maps;
+  std::map<epoch_t, ceph::buffer::list> maps;
+  std::map<epoch_t, ceph::buffer::list> incremental_maps;
   epoch_t oldest_map =0, newest_map = 0;
 
-  // if we are fetching maps from the mon and have to jump a gap
-  // (client's next needed map is older than mon's oldest) we can
-  // share removed snaps from the gap here.
-  mempool::osdmap::map<int64_t,OSDMap::snap_interval_set_t> gap_removed_snaps;
-
   epoch_t get_first() const {
     epoch_t e = 0;
-    map<epoch_t, bufferlist>::const_iterator i = maps.begin();
-    if (i != maps.end())  e = i->first;
+    auto i = maps.cbegin();
+    if (i != maps.cend())  e = i->first;
     i = incremental_maps.begin();    
     if (i != incremental_maps.end() &&
         (e == 0 || i->first < e)) e = i->first;
@@ -50,8 +43,8 @@ private:
   }
   epoch_t get_last() const {
     epoch_t e = 0;
-    map<epoch_t, bufferlist>::const_reverse_iterator i = maps.rbegin();
-    if (i != maps.rend())  e = i->first;
+    auto i = maps.crbegin();
+    if (i != maps.crend())  e = i->first;
     i = incremental_maps.rbegin();    
     if (i != incremental_maps.rend() &&
         (e == 0 || i->first > e)) e = i->first;
@@ -65,9 +58,9 @@ private:
   }
 
 
-  MOSDMap() : MessageInstance(CEPH_MSG_OSD_MAP, HEAD_VERSION, COMPAT_VERSION) { }
+  MOSDMap() : Message{CEPH_MSG_OSD_MAP, HEAD_VERSION, COMPAT_VERSION} { }
   MOSDMap(const uuid_d &f, const uint64_t features)
-    : MessageInstance(CEPH_MSG_OSD_MAP, HEAD_VERSION, COMPAT_VERSION),
+    : Message{CEPH_MSG_OSD_MAP, HEAD_VERSION, COMPAT_VERSION},
       fsid(f), encode_features(features),
       oldest_map(0), newest_map(0) { }
 private:
@@ -75,6 +68,7 @@ private:
 public:
   // marshalling
   void decode_payload() override {
+    using ceph::decode;
     auto p = payload.cbegin();
     decode(fsid, p);
     decode(incremental_maps, p);
@@ -87,6 +81,8 @@ public:
       newest_map = 0;
     }
     if (header.version >= 4) {
+      // removed in octopus
+      mempool::osdmap::map<int64_t,snap_interval_set_t> gap_removed_snaps;
       decode(gap_removed_snaps, p);
     }
   }
@@ -111,9 +107,7 @@ public:
       // FIXME: this can probably be done more efficiently higher up
       // the stack, or maybe replaced with something that only
       // includes the pools the client cares about.
-      for (map<epoch_t,bufferlist>::iterator p = incremental_maps.begin();
-          p != incremental_maps.end();
-          ++p) {
+      for (auto p = incremental_maps.begin(); p != incremental_maps.end(); ++p) {
        OSDMap::Incremental inc;
        auto q = p->second.cbegin();
        inc.decode(q);
@@ -121,14 +115,14 @@ public:
        uint64_t f = inc.encode_features & features;
        p->second.clear();
        if (inc.fullmap.length()) {
-         // embedded full map?
+         // embedded full std::map?
          OSDMap m;
          m.decode(inc.fullmap);
          inc.fullmap.clear();
          m.encode(inc.fullmap, f | CEPH_FEATURE_RESERVED);
        }
        if (inc.crush.length()) {
-         // embedded crush map
+         // embedded crush std::map
          CrushWrapper c;
          auto p = inc.crush.cbegin();
          c.decode(p);
@@ -137,9 +131,7 @@ public:
        }
        inc.encode(p->second, f | CEPH_FEATURE_RESERVED);
       }
-      for (map<epoch_t,bufferlist>::iterator p = maps.begin();
-          p != maps.end();
-          ++p) {
+      for (auto p = maps.begin(); p != maps.end(); ++p) {
        OSDMap m;
        m.decode(p->second);
        // always encode with subset of osdmaps canonical features
@@ -155,19 +147,20 @@ public:
       encode(newest_map, payload);
     }
     if (header.version >= 4) {
-      encode(gap_removed_snaps, payload);
+      encode((uint32_t)0, payload);
     }
   }
 
   std::string_view get_type_name() const override { return "osdmap"; }
-  void print(ostream& out) const override {
+  void print(std::ostream& out) const override {
     out << "osd_map(" << get_first() << ".." << get_last();
     if (oldest_map || newest_map)
       out << " src has " << oldest_map << ".." << newest_map;
-    if (!gap_removed_snaps.empty())
-      out << " +gap_removed_snaps";
     out << ")";
   }
+private:
+  template<class T, typename... Args>
+  friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
 };
 
 #endif