From: Sage Weil Date: Fri, 12 Apr 2019 15:54:20 +0000 (-0500) Subject: osd/OSDMap: add flags for crush nodes X-Git-Tag: v15.1.0~2919^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2be95af8211225c43d72e439b6000a25743bdab7;p=ceph.git osd/OSDMap: add flags for crush nodes Signed-off-by: Sage Weil --- diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 1fd46a7be427..78ac425e1bfe 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -598,7 +598,7 @@ void OSDMap::Incremental::encode(ceph::buffer::list& bl, uint64_t features) cons } { - uint8_t target_v = 7; + uint8_t target_v = 8; if (!HAVE_FEATURE(features, SERVER_LUMINOUS)) { target_v = 2; } else if (!HAVE_FEATURE(features, SERVER_NAUTILUS)) { @@ -639,6 +639,9 @@ void OSDMap::Incremental::encode(ceph::buffer::list& bl, uint64_t features) cons encode(new_require_min_compat_client, bl); encode(new_require_osd_release, bl); } + if (target_v >= 8) { + encode(new_crush_node_flags, bl); + } ENCODE_FINISH(bl); // osd-only data } @@ -848,7 +851,7 @@ void OSDMap::Incremental::decode(ceph::buffer::list::const_iterator& bl) } { - DECODE_START(7, bl); // extended, osd-only data + DECODE_START(8, bl); // extended, osd-only data decode(new_hb_back_up, bl); decode(new_up_thru, bl); decode(new_last_clean_interval, bl); @@ -899,6 +902,9 @@ void OSDMap::Incremental::decode(ceph::buffer::list::const_iterator& bl) new_require_osd_release = -1; } } + if (struct_v >= 8) { + decode(new_crush_node_flags, bl); + } DECODE_FINISH(bl); // osd-only data } @@ -1202,6 +1208,18 @@ void OSDMap::Incremental::dump(Formatter *f) const f->close_section(); f->close_section(); } + f->open_array_section("new_crush_node_flags"); + for (auto& i : new_crush_node_flags) { + f->open_object_section("node"); + f->dump_int("id", i.first); + set st; + calc_state_set(i.second, st); + for (auto& j : st) { + f->dump_string("flag", j); + } + f->close_section(); + } + f->close_section(); f->close_section(); } @@ -2104,6 +2122,14 @@ int OSDMap::apply_incremental(const Incremental &inc) for (const auto &addr : inc.old_blacklist) blacklist.erase(addr); + for (auto& i : inc.new_crush_node_flags) { + if (i.second) { + crush_node_flags[i.first] = i.second; + } else { + crush_node_flags.erase(i.first); + } + } + // cluster snapshot? if (inc.cluster_snapshot.length()) { cluster_snapshot = inc.cluster_snapshot; @@ -2805,7 +2831,7 @@ void OSDMap::encode(ceph::buffer::list& bl, uint64_t features) const { // NOTE: any new encoding dependencies must be reflected by // SIGNIFICANT_FEATURES - uint8_t target_v = 7; + uint8_t target_v = 8; if (!HAVE_FEATURE(features, SERVER_LUMINOUS)) { target_v = 1; } else if (!HAVE_FEATURE(features, SERVER_MIMIC)) { @@ -2855,6 +2881,9 @@ void OSDMap::encode(ceph::buffer::list& bl, uint64_t features) const if (target_v >= 6) { encode(removed_snaps_queue, bl); } + if (target_v >= 8) { + encode(crush_node_flags, bl); + } ENCODE_FINISH(bl); // osd-only data } @@ -3115,7 +3144,7 @@ void OSDMap::decode(ceph::buffer::list::const_iterator& bl) } { - DECODE_START(7, bl); // extended, osd-only data + DECODE_START(8, bl); // extended, osd-only data decode(osd_addrs->hb_back_addrs, bl); decode(osd_info, bl); decode(blacklist, bl); @@ -3171,6 +3200,11 @@ void OSDMap::decode(ceph::buffer::list::const_iterator& bl) if (struct_v >= 6) { decode(removed_snaps_queue, bl); } + if (struct_v >= 8) { + decode(crush_node_flags, bl); + } else { + crush_node_flags.clear(); + } DECODE_FINISH(bl); // osd-only data } @@ -3415,6 +3449,19 @@ void OSDMap::dump(Formatter *f) const f->close_section(); } f->close_section(); + f->open_object_section("crush_node_flags"); + for (auto& i : crush_node_flags) { + string s = crush->item_exists(i.first) ? crush->get_item_name(i.first) + : stringify(i.first); + f->open_array_section(s.c_str()); + set st; + calc_state_set(i.second, st); + for (auto& j : st) { + f->dump_string("flag", j); + } + f->close_section(); + } + f->close_section(); } void OSDMap::generate_test_instances(list& o) diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index 83b0037ad9e4..e2c9d5a70c5f 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -399,6 +399,8 @@ public: mempool::osdmap::map new_removed_snaps; mempool::osdmap::map new_purged_snaps; + mempool::osdmap::map new_crush_node_flags; + std::string cluster_snapshot; float new_nearfull_ratio = -1; @@ -511,6 +513,8 @@ private: int32_t max_osd; std::vector osd_state; + mempool::osdmap::map crush_node_flags; // crush node -> CEPH_OSD_* flags + utime_t last_up_change, last_in_change; // These features affect OSDMap[::Incremental] encoding, or the