Skip to content

Commit f3fea0e

Browse files
committed
osd: Introduce macro to police use of significant features.
Signed-off-by: Alex Ainscow <[email protected]>
1 parent 33a9dc1 commit f3fea0e

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

src/osd/OSDMap.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3028,6 +3028,9 @@ bool OSDMap::primary_changed_broken(
30283028
uint64_t OSDMap::get_encoding_features() const
30293029
{
30303030
uint64_t f = SIGNIFICANT_FEATURES;
3031+
if (require_osd_release < ceph_release_t::tentacle) {
3032+
f &= ~CEPH_FEATURE_SERVER_TENTACLE;
3033+
}
30313034
if (require_osd_release < ceph_release_t::reef) {
30323035
f &= ~CEPH_FEATURE_SERVER_REEF;
30333036
}

src/osd/OSDMap.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,8 @@ class OSDMap {
575575
CEPH_FEATUREMASK_SERVER_MIMIC |
576576
CEPH_FEATUREMASK_SERVER_NAUTILUS |
577577
CEPH_FEATUREMASK_SERVER_OCTOPUS |
578-
CEPH_FEATUREMASK_SERVER_REEF;
578+
CEPH_FEATUREMASK_SERVER_REEF |
579+
CEPH_FEATUREMASK_SERVER_TENTACLE;
579580

580581
struct addrs_s {
581582
mempool::osdmap::vector<std::shared_ptr<entity_addrvec_t> > client_addrs;
@@ -708,6 +709,12 @@ class OSDMap {
708709
return SIGNIFICANT_FEATURES & features;
709710
}
710711

712+
template<uint64_t feature>
713+
requires ((SIGNIFICANT_FEATURES & feature) == feature)
714+
static constexpr bool have_significant_feature(uint64_t x) {
715+
return (x & feature) == feature;
716+
}
717+
711718
uint64_t get_encoding_features() const;
712719

713720
void deepish_copy_from(const OSDMap& o) {
@@ -1842,6 +1849,9 @@ bool try_drop_remap_underfull(
18421849
WRITE_CLASS_ENCODER_FEATURES(OSDMap)
18431850
WRITE_CLASS_ENCODER_FEATURES(OSDMap::Incremental)
18441851

1852+
#define HAVE_SIGNIFICANT_FEATURE(x, name) \
1853+
(OSDMap::have_significant_feature<CEPH_FEATUREMASK_##name>(x))
1854+
18451855
#ifdef WITH_CRIMSON
18461856
#include "crimson/common/local_shared_foreign_ptr.h"
18471857
using LocalOSDMapRef = boost::local_shared_ptr<const OSDMap>;

src/osd/osd_types.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,7 +1860,7 @@ uint32_t pg_pool_t::get_random_pg_position(pg_t pg, uint32_t seed) const
18601860
void pg_pool_t::encode(ceph::buffer::list& bl, uint64_t features) const
18611861
{
18621862
using ceph::encode;
1863-
if ((features & CEPH_FEATURE_PGPOOL3) == 0) {
1863+
if (!HAVE_SIGNIFICANT_FEATURE(features, PGPOOL3)) {
18641864
// this encoding matches the old struct ceph_pg_pool
18651865
__u8 struct_v = 2;
18661866
encode(struct_v, bl);
@@ -1889,7 +1889,7 @@ void pg_pool_t::encode(ceph::buffer::list& bl, uint64_t features) const
18891889
return;
18901890
}
18911891

1892-
if ((features & CEPH_FEATURE_OSDENC) == 0) {
1892+
if (!HAVE_SIGNIFICANT_FEATURE(features, OSDENC)) {
18931893
__u8 struct_v = 4;
18941894
encode(struct_v, bl);
18951895
encode(type, bl);
@@ -1912,7 +1912,7 @@ void pg_pool_t::encode(ceph::buffer::list& bl, uint64_t features) const
19121912
return;
19131913
}
19141914

1915-
if ((features & CEPH_FEATURE_OSD_POOLRESEND) == 0) {
1915+
if (!HAVE_SIGNIFICANT_FEATURE(features, OSD_POOLRESEND)) {
19161916
// we simply added last_force_op_resend here, which is a fully
19171917
// backward compatible change. however, encoding the same map
19181918
// 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
19641964
uint8_t v = 31;
19651965
// NOTE: any new encoding dependencies must be reflected by
19661966
// SIGNIFICANT_FEATURES
1967-
if (!HAVE_FEATURE(features, SERVER_TENTACLE)) {
1968-
if (!(features & CEPH_FEATURE_NEW_OSDOP_ENCODING)) {
1967+
if (!HAVE_SIGNIFICANT_FEATURE(features, SERVER_TENTACLE)) {
1968+
if (!HAVE_SIGNIFICANT_FEATURE(features, NEW_OSDOP_ENCODING)) {
19691969
// this was the first post-hammer thing we added; if it's missing, encode
19701970
// like hammer.
19711971
v = 21;
1972-
} else if (!HAVE_FEATURE(features, SERVER_LUMINOUS)) {
1972+
} else if (!HAVE_SIGNIFICANT_FEATURE(features, SERVER_LUMINOUS)) {
19731973
v = 24;
1974-
} else if (!HAVE_FEATURE(features, SERVER_MIMIC)) {
1974+
} else if (!HAVE_SIGNIFICANT_FEATURE(features, SERVER_MIMIC)) {
19751975
v = 26;
1976-
} else if (!HAVE_FEATURE(features, SERVER_NAUTILUS)) {
1976+
} else if (!HAVE_SIGNIFICANT_FEATURE(features, SERVER_NAUTILUS)) {
19771977
v = 27;
19781978
} else if (!is_stretch_pool()) {
19791979
v = 29;

0 commit comments

Comments
 (0)