From: Alex Ainscow Date: Thu, 3 Apr 2025 13:10:29 +0000 (+0100) Subject: osd: Introduce macro to police use of significant features. X-Git-Tag: v20.3.0~121^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f3fea0ef0c9b09b6fb41ac74f54077fe10f7123a;p=ceph.git osd: Introduce macro to police use of significant features. Signed-off-by: Alex Ainscow --- diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index d365803af31..ffdb03fec4f 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -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; } diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index 025420c4e63..3a4c56a46f3 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -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 > client_addrs; @@ -708,6 +709,12 @@ public: return SIGNIFICANT_FEATURES & features; } + template + 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(x)) + #ifdef WITH_CRIMSON #include "crimson/common/local_shared_foreign_ptr.h" using LocalOSDMapRef = boost::local_shared_ptr; diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index ec2083d8bbd..605af0aec30 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -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;