From: Sage Weil Date: Fri, 12 May 2017 13:54:11 +0000 (-0400) Subject: osd/OSDMap: add require_osd_release numeric field, CEPH_RELEASE_* X-Git-Tag: v12.1.0~57^2~6^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3d4c4d9d9da07e1456331c43acc998d2008ca8ea;p=ceph.git osd/OSDMap: add require_osd_release numeric field, CEPH_RELEASE_* Instead of eating up a flag for each release, which is super-awkward and annoying, just keep a numeric release version min. Signed-off-by: Sage Weil --- diff --git a/src/common/ceph_strings.cc b/src/common/ceph_strings.cc index 1fec2f7b0a1e..3ed154207397 100644 --- a/src/common/ceph_strings.cc +++ b/src/common/ceph_strings.cc @@ -49,6 +49,22 @@ const char *ceph_osd_state_name(int s) } } +const char *ceph_osd_release_name(int r) +{ + switch (r) { + case CEPH_RELEASE_JEWEL: + return "jewel"; + case CEPH_RELEASE_KRAKEN: + return "kraken"; + case CEPH_RELEASE_LUMINOUS: + return "luminous"; + case CEPH_RELEASE_MIMIC: + return "mimic"; + default: + return "unknown"; + } +} + const char *ceph_osd_watch_op_name(int o) { switch (o) { diff --git a/src/include/rados.h b/src/include/rados.h index c92145f1e0de..50323943bee3 100644 --- a/src/include/rados.h +++ b/src/include/rados.h @@ -157,6 +157,16 @@ extern const char *ceph_osd_state_name(int s); CEPH_OSDMAP_REQUIRE_LUMINOUS | \ CEPH_OSDMAP_SORTBITWISE) +/* + * major ceph release numbers + */ +#define CEPH_RELEASE_JEWEL 10 +#define CEPH_RELEASE_KRAKEN 11 +#define CEPH_RELEASE_LUMINOUS 12 +#define CEPH_RELEASE_MIMIC 13 + +extern const char *ceph_osd_release_name(int r); + /* * The error code to return when an OSD can't handle a write * because it is too large. diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 3ad283414f7c..dd110e5faf6b 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -479,7 +479,7 @@ void OSDMap::Incremental::encode(bufferlist& bl, uint64_t features) const } { - uint8_t target_v = 5; + uint8_t target_v = 6; if (!HAVE_FEATURE(features, SERVER_LUMINOUS)) { target_v = 2; } @@ -500,8 +500,13 @@ void OSDMap::Incremental::encode(bufferlist& bl, uint64_t features) const ::encode(new_nearfull_ratio, bl); ::encode(new_full_ratio, bl); ::encode(new_backfillfull_ratio, bl); + } + if (target_v >= 5) { ::encode(new_require_min_compat_client, bl); } + if (target_v >= 6) { + ::encode(new_require_osd_release, bl); + } ENCODE_FINISH(bl); // osd-only data } @@ -685,7 +690,7 @@ void OSDMap::Incremental::decode(bufferlist::iterator& bl) } { - DECODE_START(5, bl); // extended, osd-only data + DECODE_START(6, bl); // extended, osd-only data ::decode(new_hb_back_up, bl); ::decode(new_up_thru, bl); ::decode(new_last_clean_interval, bl); @@ -713,8 +718,14 @@ void OSDMap::Incremental::decode(bufferlist::iterator& bl) } else { new_backfillfull_ratio = -1; } - if (struct_v >= 5) + if (struct_v >= 5) { ::decode(new_require_min_compat_client, bl); + } + if (struct_v >= 6) { + ::decode(new_require_osd_release, bl); + } else { + new_require_osd_release = -1; + } DECODE_FINISH(bl); // osd-only data } @@ -760,6 +771,7 @@ void OSDMap::Incremental::dump(Formatter *f) const f->dump_float("new_nearfull_ratio", new_nearfull_ratio); f->dump_float("new_backfillfull_ratio", new_backfillfull_ratio); f->dump_string("new_require_min_compat_client", new_require_min_compat_client); + f->dump_int("new_require_osd_release", new_require_osd_release); if (fullmap.length()) { f->open_object_section("full_map"); @@ -1670,6 +1682,9 @@ int OSDMap::apply_incremental(const Incremental &inc) if (inc.new_require_min_compat_client.length()) { require_min_compat_client = inc.new_require_min_compat_client; } + if (inc.new_require_osd_release >= 0) { + require_osd_release = inc.new_require_osd_release; + } // do new crush map last (after up/down stuff) if (inc.crush.length()) { @@ -2235,7 +2250,7 @@ void OSDMap::encode(bufferlist& bl, uint64_t features) const } { - uint8_t target_v = 4; + uint8_t target_v = 5; if (!HAVE_FEATURE(features, SERVER_LUMINOUS)) { target_v = 1; } @@ -2260,8 +2275,13 @@ void OSDMap::encode(bufferlist& bl, uint64_t features) const ::encode(nearfull_ratio, bl); ::encode(full_ratio, bl); ::encode(backfillfull_ratio, bl); + } + if (target_v >= 4) { ::encode(require_min_compat_client, bl); } + if (target_v >= 5) { + ::encode(require_osd_release, bl); + } ENCODE_FINISH(bl); // osd-only data } @@ -2478,7 +2498,7 @@ void OSDMap::decode(bufferlist::iterator& bl) } { - DECODE_START(4, bl); // extended, osd-only data + DECODE_START(5, bl); // extended, osd-only data ::decode(osd_addrs->hb_back_addr, bl); ::decode(osd_info, bl); ::decode(blacklist, bl); @@ -2500,8 +2520,14 @@ void OSDMap::decode(bufferlist::iterator& bl) } else { backfillfull_ratio = 0; } - if (struct_v >= 4) + if (struct_v >= 4) { ::decode(require_min_compat_client, bl); + } + if (struct_v >= 5) { + ::decode(require_osd_release, bl); + } else { + require_osd_release = -1; + } DECODE_FINISH(bl); // osd-only data } @@ -2580,6 +2606,9 @@ void OSDMap::dump(Formatter *f) const auto mv = get_min_compat_client(); f->dump_string("min_compat_client", mv.first); f->dump_string("min_compat_client_version", mv.second); + f->dump_int("require_osd_release", require_osd_release); + f->dump_string("require_osd_release_name", + ceph_osd_release_name(require_osd_release)); f->open_array_section("pools"); for (const auto &pool : pools) { diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index 5d1819df3327..ac5df7dd0696 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -132,6 +132,7 @@ public: utime_t modified; int64_t new_pool_max; //incremented by the OSDMonitor on each pool create int32_t new_flags; + int8_t new_require_osd_release = -1; // full (rare) bufferlist fullmap; // in lieu of below. @@ -275,6 +276,9 @@ private: /// min compat client we want to support string require_min_compat_client; + /// require osds to run at least this release + uint8_t require_osd_release = 0; + mutable uint64_t cached_up_osd_features; mutable bool crc_defined;