]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
messages/MOSDMap: significant feature bits.
authorXiaoxi CHEN <xiaoxchen@ebay.com>
Mon, 23 Apr 2018 17:58:11 +0000 (12:58 -0500)
committerSage Weil <sage@redhat.com>
Fri, 27 Apr 2018 16:12:43 +0000 (11:12 -0500)
1. MOSDMap go with features indicating the features
this map encoded for.

2. Only reencode if significant bits mismatch between
target features and my features.

also update mon/OSDMonitor and osd/OSDService to adopt this change.

Signed-off-by: Xiaoxi CHEN <xiaoxchen@ebay.com>
src/messages/MOSDMap.h
src/mon/OSDMonitor.cc
src/osd/OSD.cc

index beaef358c8166a3415961cca114ee90a8d121d9a..27aae15570d53de45820f6845750e21de7dd2b64 100644 (file)
@@ -27,6 +27,7 @@ class MOSDMap : public Message {
 
  public:
   uuid_d fsid;
+  uint64_t encode_features = 0;
   map<epoch_t, bufferlist> maps;
   map<epoch_t, bufferlist> incremental_maps;
   epoch_t oldest_map =0, newest_map = 0;
@@ -63,13 +64,12 @@ class MOSDMap : public Message {
 
 
   MOSDMap() : Message(CEPH_MSG_OSD_MAP, HEAD_VERSION, COMPAT_VERSION) { }
-  MOSDMap(const uuid_d &f)
+  MOSDMap(const uuid_d &f, const uint64_t features)
     : Message(CEPH_MSG_OSD_MAP, HEAD_VERSION, COMPAT_VERSION),
-      fsid(f),
+      fsid(f), encode_features(features),
       oldest_map(0), newest_map(0) { }
 private:
   ~MOSDMap() override {}
-
 public:
   // marshalling
   void decode_payload() override {
@@ -93,12 +93,8 @@ public:
     header.version = HEAD_VERSION;
     header.compat_version = COMPAT_VERSION;
     encode(fsid, payload);
-    if ((features & CEPH_FEATURE_PGID64) == 0 ||
-       (features & CEPH_FEATURE_PGPOOL3) == 0 ||
-       (features & CEPH_FEATURE_OSDENC) == 0 ||
-        (features & CEPH_FEATURE_OSDMAP_ENC) == 0 ||
-       (features & CEPH_FEATURE_MSG_ADDR2) == 0 ||
-       !HAVE_FEATURE(features, SERVER_LUMINOUS)) {
+    if (OSDMap::get_significant_features(encode_features) !=
+         OSDMap::get_significant_features(features)) {
       if ((features & CEPH_FEATURE_PGID64) == 0 ||
          (features & CEPH_FEATURE_PGPOOL3) == 0)
        header.version = 1;  // old old_client version
@@ -117,13 +113,15 @@ public:
        OSDMap::Incremental inc;
        bufferlist::iterator q = p->second.begin();
        inc.decode(q);
+       // always encode with subset of osdmaps canonical features
+       uint64_t f = inc.encode_features & features;
        p->second.clear();
        if (inc.fullmap.length()) {
          // embedded full map?
          OSDMap m;
          m.decode(inc.fullmap);
          inc.fullmap.clear();
-         m.encode(inc.fullmap, features | CEPH_FEATURE_RESERVED);
+         m.encode(inc.fullmap, f | CEPH_FEATURE_RESERVED);
        }
        if (inc.crush.length()) {
          // embedded crush map
@@ -131,17 +129,19 @@ public:
          auto p = inc.crush.begin();
          c.decode(p);
          inc.crush.clear();
-         c.encode(inc.crush, features);
+         c.encode(inc.crush, f);
        }
-       inc.encode(p->second, features | CEPH_FEATURE_RESERVED);
+       inc.encode(p->second, f | CEPH_FEATURE_RESERVED);
       }
       for (map<epoch_t,bufferlist>::iterator p = maps.begin();
           p != maps.end();
           ++p) {
        OSDMap m;
        m.decode(p->second);
+       // always encode with subset of osdmaps canonical features
+       uint64_t f = m.get_encoding_features() & features;
        p->second.clear();
-       m.encode(p->second, features | CEPH_FEATURE_RESERVED);
+       m.encode(p->second, f | CEPH_FEATURE_RESERVED);
       }
     }
     encode(incremental_maps, payload);
index ea050535cac709e50afdd222704674fe770ec998..f12815b349a71daeea951a3c855b1ee6baf5b522 100644 (file)
@@ -2055,7 +2055,7 @@ bool OSDMonitor::preprocess_get_osdmap(MonOpRequestRef op)
     features = m->get_session()->con_features;
 
   dout(10) << __func__ << " " << *m << dendl;
-  MOSDMap *reply = new MOSDMap(mon->monmap->fsid);
+  MOSDMap *reply = new MOSDMap(mon->monmap->fsid, features);
   epoch_t first = get_first_committed();
   epoch_t last = osdmap.get_epoch();
   int max = g_conf->osd_map_message_max;
@@ -3341,7 +3341,7 @@ void OSDMonitor::send_latest(MonOpRequestRef op, epoch_t start)
 
 MOSDMap *OSDMonitor::build_latest_full(uint64_t features)
 {
-  MOSDMap *r = new MOSDMap(mon->monmap->fsid);
+  MOSDMap *r = new MOSDMap(mon->monmap->fsid, features);
   get_version_full(osdmap.get_epoch(), features, r->maps[osdmap.get_epoch()]);
   r->oldest_map = get_first_committed();
   r->newest_map = osdmap.get_epoch();
@@ -3351,7 +3351,7 @@ MOSDMap *OSDMonitor::build_latest_full(uint64_t features)
 MOSDMap *OSDMonitor::build_incremental(epoch_t from, epoch_t to, uint64_t features)
 {
   dout(10) << "build_incremental [" << from << ".." << to << "] with features " << std::hex << features << dendl;
-  MOSDMap *m = new MOSDMap(mon->monmap->fsid);
+  MOSDMap *m = new MOSDMap(mon->monmap->fsid, features);
   m->oldest_map = get_first_committed();
   m->newest_map = osdmap.get_epoch();
 
@@ -3429,7 +3429,7 @@ void OSDMonitor::send_incremental(epoch_t first,
   }
 
   if (first < get_first_committed()) {
-    MOSDMap *m = new MOSDMap(osdmap.get_fsid());
+    MOSDMap *m = new MOSDMap(osdmap.get_fsid(), features);
     m->oldest_map = get_first_committed();
     m->newest_map = osdmap.get_epoch();
 
index 9b8891e96ba308eb89b7e13a2bb7c848ae55b61f..d2b7a317b8cdedfe49ecc682f04fc0ad1c531b12 100644 (file)
@@ -1299,7 +1299,8 @@ void OSDService::got_stop_ack()
 MOSDMap *OSDService::build_incremental_map_msg(epoch_t since, epoch_t to,
                                                OSDSuperblock& sblock)
 {
-  MOSDMap *m = new MOSDMap(monc->get_fsid());
+  MOSDMap *m = new MOSDMap(monc->get_fsid(),
+                          osdmap->get_encoding_features());
   m->oldest_map = max_oldest_map;
   m->newest_map = sblock.newest_map;
 
@@ -1339,7 +1340,8 @@ void OSDService::send_incremental_map(epoch_t since, Connection *con,
     OSDSuperblock sblock(get_superblock());
     if (since < sblock.oldest_map) {
       // just send latest full map
-      MOSDMap *m = new MOSDMap(monc->get_fsid());
+      MOSDMap *m = new MOSDMap(monc->get_fsid(),
+                              osdmap->get_encoding_features());
       m->oldest_map = max_oldest_map;
       m->newest_map = sblock.newest_map;
       get_map_bl(to, m->maps[to]);