From: Sage Weil Date: Tue, 16 Apr 2019 22:22:38 +0000 (-0500) Subject: osd/OSDMap: add flags for crush nodes X-Git-Tag: v14.2.2~213^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=10fc1192fc1939cb99dc5eaa6a68434663f3ad48;p=ceph.git osd/OSDMap: add flags for crush nodes Signed-off-by: Sage Weil (cherry picked from commit 2be95af8211225c43d72e439b6000a25743bdab7) # Conflicts: # src/osd/OSDMap.h - due to std:: prefix on string cluster_snapshot --- diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 0c10811a88f..d73930b66ac 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -581,7 +581,7 @@ void OSDMap::Incremental::encode(bufferlist& bl, uint64_t features) const } { - 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)) { @@ -622,6 +622,9 @@ void OSDMap::Incremental::encode(bufferlist& bl, uint64_t features) const 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 } @@ -831,7 +834,7 @@ void OSDMap::Incremental::decode(bufferlist::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); @@ -882,6 +885,9 @@ void OSDMap::Incremental::decode(bufferlist::const_iterator& bl) new_require_osd_release = -1; } } + if (struct_v >= 8) { + decode(new_crush_node_flags, bl); + } DECODE_FINISH(bl); // osd-only data } @@ -1185,6 +1191,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(); } @@ -2087,6 +2105,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; @@ -2785,7 +2811,7 @@ void OSDMap::encode(bufferlist& 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)) { @@ -2835,6 +2861,9 @@ void OSDMap::encode(bufferlist& 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 } @@ -3095,7 +3124,7 @@ void OSDMap::decode(bufferlist::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); @@ -3151,6 +3180,11 @@ void OSDMap::decode(bufferlist::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 } @@ -3395,6 +3429,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 a477d5827e4..3cfa2e65d80 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; + string cluster_snapshot; float new_nearfull_ratio = -1; @@ -511,6 +513,8 @@ private: int32_t max_osd; 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