]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: Introduce macro to police use of significant features. 62626/head
authorAlex Ainscow <aainscow@uk.ibm.com>
Thu, 3 Apr 2025 13:10:29 +0000 (14:10 +0100)
committerAlex Ainscow <aainscow@uk.ibm.com>
Thu, 3 Apr 2025 13:10:29 +0000 (14:10 +0100)
Signed-off-by: Alex Ainscow <aainscow@uk.ibm.com>
src/osd/OSDMap.cc
src/osd/OSDMap.h
src/osd/osd_types.cc

index d365803af313e7a7eed1eea21d639d0373fcdbcf..ffdb03fec4f44702a750f95633543b3876bbd197 100644 (file)
@@ -3028,6 +3028,9 @@ bool OSDMap::primary_changed_broken(
 uint64_t OSDMap::get_encoding_features() const
 {
   uint64_t f = SIGNIFICANT_FEATURES;
+  if (require_osd_release < ceph_release_t::tentacle) {
+    f &= ~CEPH_FEATURE_SERVER_TENTACLE;
+  }
   if (require_osd_release < ceph_release_t::reef) {
     f &= ~CEPH_FEATURE_SERVER_REEF;
   }
index 025420c4e63ce45dd33c4e6269465e8ff9b5f1fd..3a4c56a46f32c89f8bc8a39da7eb6659eb53e2b9 100644 (file)
@@ -575,7 +575,8 @@ private:
     CEPH_FEATUREMASK_SERVER_MIMIC |
     CEPH_FEATUREMASK_SERVER_NAUTILUS |
     CEPH_FEATUREMASK_SERVER_OCTOPUS |
-    CEPH_FEATUREMASK_SERVER_REEF;
+    CEPH_FEATUREMASK_SERVER_REEF |
+    CEPH_FEATUREMASK_SERVER_TENTACLE;
 
   struct addrs_s {
     mempool::osdmap::vector<std::shared_ptr<entity_addrvec_t> > client_addrs;
@@ -708,6 +709,12 @@ public:
     return SIGNIFICANT_FEATURES & features;
   }
 
+  template<uint64_t feature>
+    requires ((SIGNIFICANT_FEATURES & feature) == feature)
+  static constexpr bool have_significant_feature(uint64_t x) {
+    return (x & feature) == feature;
+  }
+
   uint64_t get_encoding_features() const;
 
   void deepish_copy_from(const OSDMap& o) {
@@ -1842,6 +1849,9 @@ public:
 WRITE_CLASS_ENCODER_FEATURES(OSDMap)
 WRITE_CLASS_ENCODER_FEATURES(OSDMap::Incremental)
 
+#define HAVE_SIGNIFICANT_FEATURE(x, name) \
+(OSDMap::have_significant_feature<CEPH_FEATUREMASK_##name>(x))
+
 #ifdef WITH_CRIMSON
 #include "crimson/common/local_shared_foreign_ptr.h"
 using LocalOSDMapRef = boost::local_shared_ptr<const OSDMap>;
index ec2083d8bbd4f790a649c185a71319a5a823c33d..605af0aec30888a63027e0a7ab935e86dc526f4d 100644 (file)
@@ -1860,7 +1860,7 @@ uint32_t pg_pool_t::get_random_pg_position(pg_t pg, uint32_t seed) const
 void pg_pool_t::encode(ceph::buffer::list& bl, uint64_t features) const
 {
   using ceph::encode;
-  if ((features & CEPH_FEATURE_PGPOOL3) == 0) {
+  if (!HAVE_SIGNIFICANT_FEATURE(features, PGPOOL3)) {
     // this encoding matches the old struct ceph_pg_pool
     __u8 struct_v = 2;
     encode(struct_v, bl);
@@ -1889,7 +1889,7 @@ void pg_pool_t::encode(ceph::buffer::list& bl, uint64_t features) const
     return;
   }
 
-  if ((features & CEPH_FEATURE_OSDENC) == 0) {
+  if (!HAVE_SIGNIFICANT_FEATURE(features, OSDENC)) {
     __u8 struct_v = 4;
     encode(struct_v, bl);
     encode(type, bl);
@@ -1912,7 +1912,7 @@ void pg_pool_t::encode(ceph::buffer::list& bl, uint64_t features) const
     return;
   }
 
-  if ((features & CEPH_FEATURE_OSD_POOLRESEND) == 0) {
+  if (!HAVE_SIGNIFICANT_FEATURE(features, OSD_POOLRESEND)) {
     // we simply added last_force_op_resend here, which is a fully
     // backward compatible change.  however, encoding the same map
     // differently between monitors triggers scrub noise (even though
@@ -1964,16 +1964,16 @@ void pg_pool_t::encode(ceph::buffer::list& bl, uint64_t features) const
   uint8_t v = 31;
   // NOTE: any new encoding dependencies must be reflected by
   // SIGNIFICANT_FEATURES
-  if (!HAVE_FEATURE(features, SERVER_TENTACLE)) {
-    if (!(features & CEPH_FEATURE_NEW_OSDOP_ENCODING)) {
+  if (!HAVE_SIGNIFICANT_FEATURE(features, SERVER_TENTACLE)) {
+    if (!HAVE_SIGNIFICANT_FEATURE(features, NEW_OSDOP_ENCODING)) {
       // this was the first post-hammer thing we added; if it's missing, encode
       // like hammer.
       v = 21;
-    } else if (!HAVE_FEATURE(features, SERVER_LUMINOUS)) {
+    } else if (!HAVE_SIGNIFICANT_FEATURE(features, SERVER_LUMINOUS)) {
       v = 24;
-    } else if (!HAVE_FEATURE(features, SERVER_MIMIC)) {
+    } else if (!HAVE_SIGNIFICANT_FEATURE(features, SERVER_MIMIC)) {
       v = 26;
-    } else if (!HAVE_FEATURE(features, SERVER_NAUTILUS)) {
+    } else if (!HAVE_SIGNIFICANT_FEATURE(features, SERVER_NAUTILUS)) {
       v = 27;
     } else if (!is_stretch_pool()) {
       v = 29;