Skip to content

Commit 563ff04

Browse files
authored
Merge pull request ceph#62626 from aainscow/have_significant_feature
osd: Introduce macro to police use of significant features.
2 parents 95b9478 + f3fea0e commit 563ff04

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
@@ -1861,7 +1861,7 @@ uint32_t pg_pool_t::get_random_pg_position(pg_t pg, uint32_t seed) const
18611861
void pg_pool_t::encode(ceph::buffer::list& bl, uint64_t features) const
18621862
{
18631863
using ceph::encode;
1864-
if ((features & CEPH_FEATURE_PGPOOL3) == 0) {
1864+
if (!HAVE_SIGNIFICANT_FEATURE(features, PGPOOL3)) {
18651865
// this encoding matches the old struct ceph_pg_pool
18661866
__u8 struct_v = 2;
18671867
encode(struct_v, bl);
@@ -1890,7 +1890,7 @@ void pg_pool_t::encode(ceph::buffer::list& bl, uint64_t features) const
18901890
return;
18911891
}
18921892

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

1916-
if ((features & CEPH_FEATURE_OSD_POOLRESEND) == 0) {
1916+
if (!HAVE_SIGNIFICANT_FEATURE(features, OSD_POOLRESEND)) {
19171917
// we simply added last_force_op_resend here, which is a fully
19181918
// backward compatible change. however, encoding the same map
19191919
// differently between monitors triggers scrub noise (even though
@@ -1965,16 +1965,16 @@ void pg_pool_t::encode(ceph::buffer::list& bl, uint64_t features) const
19651965
uint8_t v = 32;
19661966
// NOTE: any new encoding dependencies must be reflected by
19671967
// SIGNIFICANT_FEATURES
1968-
if (!HAVE_FEATURE(features, SERVER_TENTACLE)) {
1969-
if (!(features & CEPH_FEATURE_NEW_OSDOP_ENCODING)) {
1968+
if (!HAVE_SIGNIFICANT_FEATURE(features, SERVER_TENTACLE)) {
1969+
if (!HAVE_SIGNIFICANT_FEATURE(features, NEW_OSDOP_ENCODING)) {
19701970
// this was the first post-hammer thing we added; if it's missing, encode
19711971
// like hammer.
19721972
v = 21;
1973-
} else if (!HAVE_FEATURE(features, SERVER_LUMINOUS)) {
1973+
} else if (!HAVE_SIGNIFICANT_FEATURE(features, SERVER_LUMINOUS)) {
19741974
v = 24;
1975-
} else if (!HAVE_FEATURE(features, SERVER_MIMIC)) {
1975+
} else if (!HAVE_SIGNIFICANT_FEATURE(features, SERVER_MIMIC)) {
19761976
v = 26;
1977-
} else if (!HAVE_FEATURE(features, SERVER_NAUTILUS)) {
1977+
} else if (!HAVE_SIGNIFICANT_FEATURE(features, SERVER_NAUTILUS)) {
19781978
v = 27;
19791979
} else if (!is_stretch_pool()) {
19801980
v = 29;

0 commit comments

Comments
 (0)