]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: move OSDMap feature calculation into OSDMap helper
authorSage Weil <sage@redhat.com>
Mon, 23 Apr 2018 17:42:15 +0000 (12:42 -0500)
committerSage Weil <sage@redhat.com>
Tue, 24 Apr 2018 14:16:05 +0000 (09:16 -0500)
The OSDMap knows what features it needs to encode itself "properly"; move
that into a helper.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/OSDMonitor.cc
src/osd/OSDMap.cc
src/osd/OSDMap.h

index 2989e7b4c199d6f3e2db3d520ce2cff4d98010d7..dff2831f07fb006daa101ccd11201fec50df8283 100644 (file)
@@ -1252,7 +1252,7 @@ void OSDMonitor::encode_pending(MonitorDBStore::TransactionRef t)
   osdmap.maybe_remove_pg_upmaps(cct, osdmap, &pending_inc);
 
   // features for osdmap and its incremental
-  uint64_t features = mon->get_quorum_con_features();
+  uint64_t features;
 
   // encode full map and determine its crc
   OSDMap tmp;
@@ -1261,27 +1261,12 @@ void OSDMonitor::encode_pending(MonitorDBStore::TransactionRef t)
     tmp.apply_incremental(pending_inc);
 
     // determine appropriate features
-    if (tmp.require_osd_release < CEPH_RELEASE_LUMINOUS) {
-      dout(10) << __func__ << " encoding without feature SERVER_LUMINOUS"
-              << dendl;
-      features &= ~CEPH_FEATURE_SERVER_LUMINOUS;
-    }
-    if (tmp.require_osd_release < CEPH_RELEASE_KRAKEN) {
-      dout(10) << __func__ << " encoding without feature SERVER_KRAKEN | "
-              << "MSG_ADDR2" << dendl;
-      features &= ~(CEPH_FEATURE_SERVER_KRAKEN |
-                   CEPH_FEATURE_MSG_ADDR2);
-    }
-    if (tmp.require_osd_release < CEPH_RELEASE_JEWEL) {
-      dout(10) << __func__ << " encoding without feature SERVER_JEWEL" << dendl;
-      features &= ~CEPH_FEATURE_SERVER_JEWEL;
-    }
-    if (tmp.require_osd_release < CEPH_RELEASE_MIMIC) {
-      dout(10) << __func__ << " encoding without feature SERVER_MIMIC" << dendl;
-      features &= ~(CEPH_FEATURE_SERVER_MIMIC);
-    }
+    features = tmp.get_encoding_features();
     dout(10) << __func__ << " encoding full map with " << features << dendl;
 
+    // the features should be a subset of the mon quorum's features!
+    assert((features & ~mon->get_quorum_con_features()) == 0);
+
     bufferlist fullbl;
     encode(tmp, fullbl, features | CEPH_FEATURE_RESERVED);
     pending_inc.full_crc = tmp.get_crc();
index e5d9bad080b8f77a3f07ec91b4a46d25f11631e0..438e13f14f07b9d313a3b05e53c0ba7230967535 100644 (file)
@@ -246,6 +246,8 @@ int OSDMap::Incremental::propagate_snaps_to_tiers(CephContext *cct,
   return 0;
 }
 
+// ----------------------------------
+// OSDMap
 
 bool OSDMap::subtree_is_down(int id, set<int> *down_cache) const
 {
@@ -2380,6 +2382,27 @@ bool OSDMap::primary_changed(
   return false;      // same primary (tho replicas may have changed)
 }
 
+uint64_t OSDMap::get_encoding_features() const
+{
+  uint64_t f = SIGNIFICANT_FEATURES;
+  if (require_osd_release < CEPH_RELEASE_MIMIC) {
+    f &= ~CEPH_FEATURE_SERVER_MIMIC;
+  }
+  if (require_osd_release < CEPH_RELEASE_LUMINOUS) {
+    f &= ~(CEPH_FEATURE_SERVER_LUMINOUS |
+          CEPH_FEATURE_CRUSH_CHOOSE_ARGS);
+  }
+  if (require_osd_release < CEPH_RELEASE_KRAKEN) {
+    f &= ~(CEPH_FEATURE_SERVER_KRAKEN |
+          CEPH_FEATURE_MSG_ADDR2 |
+          CEPH_FEATURE_CRUSH_TUNABLES5);
+  }
+  if (require_osd_release < CEPH_RELEASE_JEWEL) {
+    f &= ~(CEPH_FEATURE_SERVER_JEWEL |
+          CEPH_FEATURE_NEW_OSDOP_ENCODING);
+  }
+  return f;
+}
 
 // serialize, unserialize
 void OSDMap::encode_client_old(bufferlist& bl) const
index c17a36f3bdc8640fa6e47691e4110aa6be515176..5452dcf4b7e200f1e20930c70c7c953187c6c947 100644 (file)
@@ -620,6 +620,8 @@ public:
     return SIGNIFICANT_FEATURES & features;
   }
 
+  uint64_t get_encoding_features() const;
+
   void deepish_copy_from(const OSDMap& o) {
     *this = o;
     primary_temp.reset(new mempool::osdmap::map<pg_t,int32_t>(*o.primary_temp));