From a192c1a525c3a4f0aa50e1ff282b028fbbb0b14c Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Thu, 28 Mar 2019 20:33:28 -0400 Subject: [PATCH] osd: Update OSDMap to work without using namespace Signed-off-by: Adam C. Emerson --- src/osd/OSDMap.cc | 103 ++++++++------ src/osd/OSDMap.h | 336 +++++++++++++++++++++++----------------------- 2 files changed, 227 insertions(+), 212 deletions(-) diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 5affd814f4b..6567afdef94 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -37,6 +37,23 @@ #include "common/Clock.h" #include "mon/PGMap.h" +using std::list; +using std::make_pair; +using std::map; +using std::multimap; +using std::ostream; +using std::ostringstream; +using std::pair; +using std::set; +using std::string; +using std::stringstream; +using std::unordered_map; +using std::vector; + +using ceph::decode; +using ceph::encode; +using ceph::Formatter; + #define dout_subsys ceph_subsys_osd MEMPOOL_DEFINE_OBJECT_FACTORY(OSDMap, osdmap, osdmap); @@ -56,7 +73,7 @@ void osd_info_t::dump(Formatter *f) const f->dump_int("lost_at", lost_at); } -void osd_info_t::encode(bufferlist& bl) const +void osd_info_t::encode(ceph::buffer::list& bl) const { using ceph::encode; __u8 struct_v = 1; @@ -69,7 +86,7 @@ void osd_info_t::encode(bufferlist& bl) const encode(lost_at, bl); } -void osd_info_t::decode(bufferlist::const_iterator& bl) +void osd_info_t::decode(ceph::buffer::list::const_iterator& bl) { using ceph::decode; __u8 struct_v; @@ -117,7 +134,7 @@ void osd_xinfo_t::dump(Formatter *f) const f->dump_unsigned("old_weight", old_weight); } -void osd_xinfo_t::encode(bufferlist& bl) const +void osd_xinfo_t::encode(ceph::buffer::list& bl) const { ENCODE_START(3, 1, bl); encode(down_stamp, bl); @@ -129,7 +146,7 @@ void osd_xinfo_t::encode(bufferlist& bl) const ENCODE_FINISH(bl); } -void osd_xinfo_t::decode(bufferlist::const_iterator& bl) +void osd_xinfo_t::decode(ceph::buffer::list::const_iterator& bl) { DECODE_START(3, bl); decode(down_stamp, bl); @@ -356,7 +373,7 @@ bool OSDMap::subtree_type_is_down( return true; } -void OSDMap::Incremental::encode_client_old(bufferlist& bl) const +void OSDMap::Incremental::encode_client_old(ceph::buffer::list& bl) const { using ceph::encode; __u16 v = 5; @@ -417,7 +434,7 @@ void OSDMap::Incremental::encode_client_old(bufferlist& bl) const } } -void OSDMap::Incremental::encode_classic(bufferlist& bl, uint64_t features) const +void OSDMap::Incremental::encode_classic(ceph::buffer::list& bl, uint64_t features) const { using ceph::encode; if ((features & CEPH_FEATURE_PGID64) == 0) { @@ -469,7 +486,7 @@ void OSDMap::Incremental::encode_classic(bufferlist& bl, uint64_t features) cons } template -static void encode_addrvec_map_as_addr(const T& m, bufferlist& bl, uint64_t f) +static void encode_addrvec_map_as_addr(const T& m, ceph::buffer::list& bl, uint64_t f) { uint32_t n = m.size(); encode(n, bl); @@ -480,7 +497,7 @@ static void encode_addrvec_map_as_addr(const T& m, bufferlist& bl, uint64_t f) } template -static void encode_addrvec_pvec_as_addr(const T& m, bufferlist& bl, uint64_t f) +static void encode_addrvec_pvec_as_addr(const T& m, ceph::buffer::list& bl, uint64_t f) { uint32_t n = m.size(); encode(n, bl); @@ -497,7 +514,7 @@ static void encode_addrvec_pvec_as_addr(const T& m, bufferlist& bl, uint64_t f) * introduced, please refer to * doc/dev/osd_internals/osdmap_versions.txt */ -void OSDMap::Incremental::encode(bufferlist& bl, uint64_t features) const +void OSDMap::Incremental::encode(ceph::buffer::list& bl, uint64_t features) const { using ceph::encode; if ((features & CEPH_FEATURE_OSDMAP_ENC) == 0) { @@ -515,7 +532,7 @@ void OSDMap::Incremental::encode(bufferlist& bl, uint64_t features) const size_t start_offset = bl.length(); size_t tail_offset; size_t crc_offset; - std::optional crc_filler; + std::optional crc_filler; // meta-encoding: how we include client-used and osd-specific data ENCODE_START(8, 7, bl); @@ -634,10 +651,10 @@ void OSDMap::Incremental::encode(bufferlist& bl, uint64_t features) const ENCODE_FINISH(bl); // meta-encoding wrapper // fill in crc - bufferlist front; + ceph::buffer::list front; front.substr_of(bl, start_offset, crc_offset - start_offset); inc_crc = front.crc32c(-1); - bufferlist tail; + ceph::buffer::list tail; tail.substr_of(bl, tail_offset, bl.length() - tail_offset); inc_crc = tail.crc32c(inc_crc); ceph_le32 crc_le; @@ -646,7 +663,7 @@ void OSDMap::Incremental::encode(bufferlist& bl, uint64_t features) const have_crc = true; } -void OSDMap::Incremental::decode_classic(bufferlist::const_iterator &p) +void OSDMap::Incremental::decode_classic(ceph::buffer::list::const_iterator &p) { using ceph::decode; __u32 n, t; @@ -711,7 +728,7 @@ void OSDMap::Incremental::decode_classic(bufferlist::const_iterator &p) decode(n, p); while (n--) { old_pg_t opg; - ::decode_raw(opg, p); + ceph::decode_raw(opg, p); decode(new_pg_temp[pg_t(opg)], p); } } else { @@ -750,7 +767,7 @@ void OSDMap::Incremental::decode_classic(bufferlist::const_iterator &p) * introduced, please refer to * doc/dev/osd_internals/osdmap_versions.txt */ -void OSDMap::Incremental::decode(bufferlist::const_iterator& bl) +void OSDMap::Incremental::decode(ceph::buffer::list::const_iterator& bl) { using ceph::decode; /** @@ -762,7 +779,7 @@ void OSDMap::Incremental::decode(bufferlist::const_iterator& bl) */ size_t start_offset = bl.get_off(); size_t tail_offset = 0; - bufferlist crc_front, crc_tail; + ceph::buffer::list crc_front, crc_tail; DECODE_START_LEGACY_COMPAT_LEN(8, 7, 7, bl); // wrapper if (struct_v < 7) { @@ -903,7 +920,7 @@ void OSDMap::Incremental::decode(bufferlist::const_iterator& bl) // verify crc uint32_t actual = crc_front.crc32c(-1); if (tail_offset < bl.get_off()) { - bufferlist tail; + ceph::buffer::list tail; tail.substr_of(bl.get_bl(), tail_offset, bl.get_off() - tail_offset); actual = tail.crc32c(actual); } @@ -911,7 +928,7 @@ void OSDMap::Incremental::decode(bufferlist::const_iterator& bl) ostringstream ss; ss << "bad crc, actual " << actual << " != expected " << inc_crc; string s = ss.str(); - throw buffer::malformed_input(s.c_str()); + throw ceph::buffer::malformed_input(s.c_str()); } } } @@ -934,7 +951,7 @@ void OSDMap::Incremental::dump(Formatter *f) const if (fullmap.length()) { f->open_object_section("full_map"); OSDMap full; - bufferlist fbl = fullmap; // kludge around constness. + ceph::buffer::list fbl = fullmap; // kludge around constness. auto p = fbl.cbegin(); full.decode(p); full.dump(f); @@ -943,7 +960,7 @@ void OSDMap::Incremental::dump(Formatter *f) const if (crush.length()) { f->open_object_section("crush"); CrushWrapper c; - bufferlist tbl = crush; // kludge around constness. + ceph::buffer::list tbl = crush; // kludge around constness. auto p = tbl.cbegin(); c.decode(p); c.dump(f); @@ -1636,7 +1653,7 @@ void OSDMap::dedup(const OSDMap *o, OSDMap *n) } // does crush match? - bufferlist oc, nc; + ceph::buffer::list oc, nc; encode(*o->crush, oc, CEPH_FEATURES_SUPPORTED_DEFAULT); encode(*n->crush, nc, CEPH_FEATURES_SUPPORTED_DEFAULT); if (oc.contents_equal(nc)) { @@ -1886,7 +1903,7 @@ int OSDMap::apply_incremental(const Incremental &inc) // full map? if (inc.fullmap.length()) { - bufferlist bl(inc.fullmap); + ceph::buffer::list bl(inc.fullmap); decode(bl); return 0; } @@ -2124,7 +2141,7 @@ int OSDMap::apply_incremental(const Incremental &inc) } // do new crush map last (after up/down stuff) if (inc.crush.length()) { - bufferlist bl(inc.crush); + ceph::buffer::list bl(inc.crush); auto blp = bl.cbegin(); crush.reset(new CrushWrapper); crush->decode(blp); @@ -2551,7 +2568,7 @@ uint64_t OSDMap::get_encoding_features() const } // serialize, unserialize -void OSDMap::encode_client_old(bufferlist& bl) const +void OSDMap::encode_client_old(ceph::buffer::list& bl) const { using ceph::encode; __u16 v = 5; @@ -2607,12 +2624,12 @@ void OSDMap::encode_client_old(bufferlist& bl) const } // crush - bufferlist cbl; + ceph::buffer::list cbl; crush->encode(cbl, 0 /* legacy (no) features */); encode(cbl, bl); } -void OSDMap::encode_classic(bufferlist& bl, uint64_t features) const +void OSDMap::encode_classic(ceph::buffer::list& bl, uint64_t features) const { using ceph::encode; if ((features & CEPH_FEATURE_PGID64) == 0) { @@ -2649,7 +2666,7 @@ void OSDMap::encode_classic(bufferlist& bl, uint64_t features) const encode(*pg_temp, bl); // crush - bufferlist cbl; + ceph::buffer::list cbl; crush->encode(cbl, 0 /* legacy (no) features */); encode(cbl, bl); @@ -2671,7 +2688,7 @@ void OSDMap::encode_classic(bufferlist& bl, uint64_t features) const * refer to * doc/dev/osd_internals/osdmap_versions.txt */ -void OSDMap::encode(bufferlist& bl, uint64_t features) const +void OSDMap::encode(ceph::buffer::list& bl, uint64_t features) const { using ceph::encode; if ((features & CEPH_FEATURE_OSDMAP_ENC) == 0) { @@ -2689,7 +2706,7 @@ void OSDMap::encode(bufferlist& bl, uint64_t features) const size_t start_offset = bl.length(); size_t tail_offset; size_t crc_offset; - std::optional crc_filler; + std::optional crc_filler; // meta-encoding: how we include client-used and osd-specific data ENCODE_START(8, 7, bl); @@ -2756,7 +2773,7 @@ void OSDMap::encode(bufferlist& bl, uint64_t features) const } // crush - bufferlist cbl; + ceph::buffer::list cbl; crush->encode(cbl, features); encode(cbl, bl); encode(erasure_code_profiles, bl); @@ -2845,11 +2862,11 @@ void OSDMap::encode(bufferlist& bl, uint64_t features) const ENCODE_FINISH(bl); // meta-encoding wrapper // fill in crc - bufferlist front; + ceph::buffer::list front; front.substr_of(bl, start_offset, crc_offset - start_offset); crc = front.crc32c(-1); if (tail_offset < bl.length()) { - bufferlist tail; + ceph::buffer::list tail; tail.substr_of(bl, tail_offset, bl.length() - tail_offset); crc = tail.crc32c(crc); } @@ -2863,13 +2880,13 @@ void OSDMap::encode(bufferlist& bl, uint64_t features) const * refer to * doc/dev/osd_internals/osdmap_versions.txt */ -void OSDMap::decode(bufferlist& bl) +void OSDMap::decode(ceph::buffer::list& bl) { auto p = bl.cbegin(); decode(p); } -void OSDMap::decode_classic(bufferlist::const_iterator& p) +void OSDMap::decode_classic(ceph::buffer::list::const_iterator& p) { using ceph::decode; __u32 n, t; @@ -2935,7 +2952,7 @@ void OSDMap::decode_classic(bufferlist::const_iterator& p) decode(n, p); while (n--) { old_pg_t opg; - ::decode_raw(opg, p); + ceph::decode_raw(opg, p); mempool::osdmap::vector v; decode(v, p); pg_temp->set(pg_t(opg), v); @@ -2945,7 +2962,7 @@ void OSDMap::decode_classic(bufferlist::const_iterator& p) } // crush - bufferlist cbl; + ceph::buffer::list cbl; decode(cbl, p); auto cblp = cbl.cbegin(); crush->decode(cblp); @@ -2990,7 +3007,7 @@ void OSDMap::decode_classic(bufferlist::const_iterator& p) post_decode(); } -void OSDMap::decode(bufferlist::const_iterator& bl) +void OSDMap::decode(ceph::buffer::list::const_iterator& bl) { using ceph::decode; /** @@ -3002,7 +3019,7 @@ void OSDMap::decode(bufferlist::const_iterator& bl) */ size_t start_offset = bl.get_off(); size_t tail_offset = 0; - bufferlist crc_front, crc_tail; + ceph::buffer::list crc_front, crc_tail; DECODE_START_LEGACY_COMPAT_LEN(8, 7, 7, bl); // wrapper if (struct_v < 7) { @@ -3055,7 +3072,7 @@ void OSDMap::decode(bufferlist::const_iterator& bl) } // crush - bufferlist cbl; + ceph::buffer::list cbl; decode(cbl, bl); auto cblp = cbl.cbegin(); crush->decode(cblp); @@ -3170,7 +3187,7 @@ void OSDMap::decode(bufferlist::const_iterator& bl) // verify crc uint32_t actual = crc_front.crc32c(-1); if (tail_offset < bl.get_off()) { - bufferlist tail; + ceph::buffer::list tail; tail.substr_of(bl.get_bl(), tail_offset, bl.get_off() - tail_offset); actual = tail.crc32c(actual); } @@ -3178,7 +3195,7 @@ void OSDMap::decode(bufferlist::const_iterator& bl) ostringstream ss; ss << "bad crc, actual " << actual << " != expected " << crc; string s = ss.str(); - throw buffer::malformed_input(s.c_str()); + throw ceph::buffer::malformed_input(s.c_str()); } } @@ -5593,9 +5610,7 @@ void OSDMap::check_health(health_check_map_t *checks) const // CACHE_POOL_NO_HIT_SET if (g_conf()->mon_warn_on_cache_pools_without_hit_sets) { list detail; - for (map::const_iterator p = pools.begin(); - p != pools.end(); - ++p) { + for (auto p = pools.cbegin(); p != pools.cend(); ++p) { const pg_pool_t& info = p->second; if (info.cache_mode_requires_hit_set() && info.hit_set_params.get_type() == HitSet::TYPE_NONE) { diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index a477d5827e4..83b0037ad9e 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -74,14 +74,14 @@ struct osd_info_t { osd_info_t() : last_clean_begin(0), last_clean_end(0), up_from(0), up_thru(0), down_at(0), lost_at(0) {} - void dump(Formatter *f) const; - void encode(bufferlist& bl) const; - void decode(bufferlist::const_iterator& bl); - static void generate_test_instances(list& o); + void dump(ceph::Formatter *f) const; + void encode(ceph::buffer::list& bl) const; + void decode(ceph::buffer::list::const_iterator& bl); + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(osd_info_t) -ostream& operator<<(ostream& out, const osd_info_t& info); +std::ostream& operator<<(std::ostream& out, const osd_info_t& info); struct osd_xinfo_t { utime_t down_stamp; ///< timestamp when we were last marked down @@ -93,23 +93,23 @@ struct osd_xinfo_t { osd_xinfo_t() : laggy_probability(0), laggy_interval(0), features(0), old_weight(0) {} - void dump(Formatter *f) const; - void encode(bufferlist& bl) const; - void decode(bufferlist::const_iterator& bl); - static void generate_test_instances(list& o); + void dump(ceph::Formatter *f) const; + void encode(ceph::buffer::list& bl) const; + void decode(ceph::buffer::list::const_iterator& bl); + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(osd_xinfo_t) -ostream& operator<<(ostream& out, const osd_xinfo_t& xi); +std::ostream& operator<<(std::ostream& out, const osd_xinfo_t& xi); struct PGTempMap { #if 1 - bufferlist data; + ceph::buffer::list data; typedef btree::btree_map map_t; map_t map; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { using ceph::encode; uint32_t n = map.size(); encode(n, bl); @@ -118,7 +118,7 @@ struct PGTempMap { bl.append((char*)p.second, (*p.second + 1) * sizeof(int32_t)); } } - void decode(bufferlist::const_iterator& p) { + void decode(ceph::buffer::list::const_iterator& p) { using ceph::decode; data.clear(); map.clear(); @@ -128,7 +128,7 @@ struct PGTempMap { return; auto pstart = p; size_t start_off = pstart.get_off(); - vector> offsets; + std::vector> offsets; offsets.resize(n); for (unsigned i=0; i> current; + std::pair> current; void init_current() { if (it != end) { current.first = it->first; @@ -184,10 +184,10 @@ struct PGTempMap { init_current(); } - const pair>& operator*() const { + const std::pair>& operator*() const { return current; } - const pair>* operator->() const { + const std::pair>* operator->() const { return ¤t; } friend bool operator==(const iterator& l, const iterator& r) { @@ -236,7 +236,7 @@ struct PGTempMap { using ceph::encode; size_t need = sizeof(int32_t) * (1 + v.size()); if (need < data.get_append_buffer_unused_tail_length()) { - bufferptr z(data.get_append_buffer_unused_tail_length()); + ceph::buffer::ptr z(data.get_append_buffer_unused_tail_length()); z.zero(); data.append(z.c_str(), z.length()); } @@ -257,10 +257,10 @@ struct PGTempMap { // trivial implementation mempool::osdmap::map > pg_temp; - void encode(bufferlist& bl) const { + void encode(ceph::buffer::list& bl) const { encode(pg_temp, bl); } - void decode(bufferlist::const_iterator& p) { + void decode(ceph::buffer::list::const_iterator& p) { decode(pg_temp, p); } friend bool operator==(const PGTempMap& l, const PGTempMap& r) { @@ -276,10 +276,10 @@ struct PGTempMap { mempool::osdmap::vector >::const_iterator p) : it(p) {} - pair&> operator*() const { + std::pair&> operator*() const { return *it; } - const pair>* operator->() const { + const std::pair>* operator->() const { return &*it; } friend bool operator==(const iterator& l, const iterator& r) { @@ -326,7 +326,7 @@ struct PGTempMap { return pg_temp.at(pgid); } #endif - void dump(Formatter *f) const { + void dump(ceph::Formatter *f) const { for (const auto &pg : *this) { f->open_object_section("osds"); f->dump_stream("pgid") << pg.first; @@ -365,16 +365,16 @@ public: int8_t new_require_osd_release = -1; // full (rare) - bufferlist fullmap; // in lieu of below. - bufferlist crush; + ceph::buffer::list fullmap; // in lieu of below. + ceph::buffer::list crush; // incremental int32_t new_max_osd; mempool::osdmap::map new_pools; - mempool::osdmap::map new_pool_names; + mempool::osdmap::map new_pool_names; mempool::osdmap::set old_pools; - mempool::osdmap::map > new_erasure_code_profiles; - mempool::osdmap::vector old_erasure_code_profiles; + mempool::osdmap::map > new_erasure_code_profiles; + mempool::osdmap::vector old_erasure_code_profiles; mempool::osdmap::map new_up_client; mempool::osdmap::map new_up_cluster; mempool::osdmap::map new_state; // XORed onto previous state. @@ -383,7 +383,7 @@ public: mempool::osdmap::map new_primary_temp; // [-1] to remove mempool::osdmap::map new_primary_affinity; mempool::osdmap::map new_up_thru; - mempool::osdmap::map > new_last_clean_interval; + mempool::osdmap::map > new_last_clean_interval; mempool::osdmap::map new_lost; mempool::osdmap::map new_uuid; mempool::osdmap::map new_xinfo; @@ -394,12 +394,12 @@ public: mempool::osdmap::map new_hb_front_up; mempool::osdmap::map> new_pg_upmap; - mempool::osdmap::map>> new_pg_upmap_items; + mempool::osdmap::map>> new_pg_upmap_items; mempool::osdmap::set old_pg_upmap, old_pg_upmap_items; mempool::osdmap::map new_removed_snaps; mempool::osdmap::map new_purged_snaps; - string cluster_snapshot; + std::string cluster_snapshot; float new_nearfull_ratio = -1; float new_backfillfull_ratio = -1; @@ -417,24 +417,24 @@ public: int get_net_marked_down(const OSDMap *previous) const; int identify_osd(uuid_d u) const; - void encode_client_old(bufferlist& bl) const; - void encode_classic(bufferlist& bl, uint64_t features) const; - void encode(bufferlist& bl, uint64_t features=CEPH_FEATURES_ALL) const; - void decode_classic(bufferlist::const_iterator &p); - void decode(bufferlist::const_iterator &bl); - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + void encode_client_old(ceph::buffer::list& bl) const; + void encode_classic(ceph::buffer::list& bl, uint64_t features) const; + void encode(ceph::buffer::list& bl, uint64_t features=CEPH_FEATURES_ALL) const; + void decode_classic(ceph::buffer::list::const_iterator &p); + void decode(ceph::buffer::list::const_iterator &bl); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); explicit Incremental(epoch_t e=0) : encode_features(0), epoch(e), new_pool_max(-1), new_flags(-1), new_max_osd(-1), have_crc(false), full_crc(0), inc_crc(0) { } - explicit Incremental(bufferlist &bl) { + explicit Incremental(ceph::buffer::list &bl) { auto p = std::cbegin(bl); decode(p); } - explicit Incremental(bufferlist::const_iterator &p) { + explicit Incremental(ceph::buffer::list::const_iterator &p) { decode(p); } @@ -443,15 +443,15 @@ public: new_pools[pool] = *orig; return &new_pools[pool]; } - bool has_erasure_code_profile(const string &name) const { + bool has_erasure_code_profile(const std::string &name) const { auto i = new_erasure_code_profiles.find(name); return i != new_erasure_code_profiles.end(); } - void set_erasure_code_profile(const string &name, - const map& profile) { + void set_erasure_code_profile(const std::string &name, + const std::map& profile) { new_erasure_code_profiles[name] = profile; } - mempool::osdmap::map> get_erasure_code_profiles() const { + mempool::osdmap::map> get_erasure_code_profiles() const { return new_erasure_code_profiles; } @@ -459,7 +459,7 @@ public: int propagate_snaps_to_tiers(CephContext *cct, const OSDMap &base); /// filter out osds with any pending state changing - size_t get_pending_state_osds(vector *osds) { + size_t get_pending_state_osds(std::vector *osds) { ceph_assert(osds); osds->clear(); @@ -509,7 +509,7 @@ private: int num_in_osd; // not saved; see calc_num_osds int32_t max_osd; - vector osd_state; + std::vector osd_state; utime_t last_up_change, last_in_change; @@ -548,12 +548,12 @@ private: // remap (post-CRUSH, pre-up) mempool::osdmap::map> pg_upmap; ///< remap pg - mempool::osdmap::map>> pg_upmap_items; ///< remap osds in up set + mempool::osdmap::map>> pg_upmap_items; ///< remap osds in up set mempool::osdmap::map pools; - mempool::osdmap::map pool_name; - mempool::osdmap::map > erasure_code_profiles; - mempool::osdmap::map name_pool; + mempool::osdmap::map pool_name; + mempool::osdmap::map> erasure_code_profiles; + mempool::osdmap::map name_pool; std::shared_ptr< mempool::osdmap::vector > osd_uuid; mempool::osdmap::vector osd_xinfo; @@ -570,7 +570,7 @@ private: mempool::osdmap::map new_purged_snaps; epoch_t cluster_snapshot_epoch; - string cluster_snapshot; + std::string cluster_snapshot; bool new_blacklist_entries; float full_ratio = 0, backfillfull_ratio = 0, nearfull_ratio = 0; @@ -664,13 +664,13 @@ public: bool is_blacklisted(const entity_addr_t& a) const; bool is_blacklisted(const entity_addrvec_t& a) const; - void get_blacklist(list > *bl) const; + void get_blacklist(std::list > *bl) const; void get_blacklist(std::set *bl) const; - string get_cluster_snapshot() const { + std::string get_cluster_snapshot() const { if (cluster_snapshot_epoch == epoch) return cluster_snapshot; - return string(); + return std::string(); } float get_full_ratio() const { @@ -683,11 +683,11 @@ public: return nearfull_ratio; } void get_full_pools(CephContext *cct, - set *full, - set *backfillfull, - set *nearfull) const; - void get_full_osd_counts(set *full, set *backfill, - set *nearfull) const; + std::set *full, + std::set *backfillfull, + std::set *nearfull) const; + void get_full_osd_counts(std::set *full, std::set *backfill, + std::set *nearfull) const; /***** cluster state *****/ @@ -707,9 +707,9 @@ public: /// recalculate cached values for get_num{,_up,_in}_osds int calc_num_osds(); - void get_all_osds(set& ls) const; - void get_up_osds(set& ls) const; - void get_out_osds(set& ls) const; + void get_all_osds(std::set& ls) const; + void get_up_osds(std::set& ls) const; + void get_out_osds(std::set& ls) const; unsigned get_num_pg_temp() const { return pg_temp->size(); } @@ -719,15 +719,15 @@ public: void set_flag(int f) { flags |= f; } void clear_flag(int f) { flags &= ~f; } - void get_flag_set(set *flagset) const; + void get_flag_set(std::set *flagset) const; - static void calc_state_set(int state, set& st); + static void calc_state_set(int state, std::set& st); int get_state(int o) const { ceph_assert(o < max_osd); return osd_state[o]; } - int get_state(int o, set& st) const { + int get_state(int o, std::set& st) const { ceph_assert(o < max_osd); unsigned t = osd_state[o]; calc_state_set(t, st); @@ -750,7 +750,7 @@ public: float get_weightf(int o) const { return (float)get_weight(o) / (float)CEPH_OSD_IN; } - void adjust_osd_weights(const map& weights, Incremental& inc) const; + void adjust_osd_weights(const std::map& weights, Incremental& inc) const; void set_primary_affinity(int o, int w) { ceph_assert(o < max_osd); @@ -770,27 +770,27 @@ public: return (float)get_primary_affinity(o) / (float)CEPH_OSD_MAX_PRIMARY_AFFINITY; } - bool has_erasure_code_profile(const string &name) const { + bool has_erasure_code_profile(const std::string &name) const { auto i = erasure_code_profiles.find(name); return i != erasure_code_profiles.end(); } int get_erasure_code_profile_default(CephContext *cct, - map &profile_map, - ostream *ss); - void set_erasure_code_profile(const string &name, - const map& profile) { + std::map &profile_map, + std::ostream *ss); + void set_erasure_code_profile(const std::string &name, + const std::map& profile) { erasure_code_profiles[name] = profile; } - const map &get_erasure_code_profile( - const string &name) const { - static map empty; + const std::map &get_erasure_code_profile( + const std::string &name) const { + static std::map empty; auto i = erasure_code_profiles.find(name); if (i == erasure_code_profiles.end()) return empty; else return i->second; } - const mempool::osdmap::map > &get_erasure_code_profiles() const { + const mempool::osdmap::map> &get_erasure_code_profiles() const { return erasure_code_profiles; } @@ -839,7 +839,7 @@ public: return exists(osd) && (osd_state[osd] & CEPH_OSD_NOOUT); } - void get_noup_osds(vector *osds) const { + void get_noup_osds(std::vector *osds) const { ceph_assert(osds); osds->clear(); @@ -850,7 +850,7 @@ public: } } - void get_nodown_osds(vector *osds) const { + void get_nodown_osds(std::vector *osds) const { ceph_assert(osds); osds->clear(); @@ -861,7 +861,7 @@ public: } } - void get_noin_osds(vector *osds) const { + void get_noin_osds(std::vector *osds) const { ceph_assert(osds); osds->clear(); @@ -872,7 +872,7 @@ public: } } - void get_noout_osds(vector *osds) const { + void get_noout_osds(std::vector *osds) const { ceph_assert(osds); osds->clear(); @@ -886,11 +886,11 @@ public: /** * check if an entire crush subtree is down */ - bool subtree_is_down(int id, set *down_cache) const; - bool containing_subtree_is_down(CephContext *cct, int osd, int subtree_type, set *down_cache) const; - - bool subtree_type_is_down(CephContext *cct, int id, int subtree_type, set *down_in_osds, set *up_in_osds, - set *subtree_up, unordered_map > *subtree_type_down) const; + bool subtree_is_down(int id, std::set *down_cache) const; + bool containing_subtree_is_down(CephContext *cct, int osd, int subtree_type, std::set *down_cache) const; + + bool subtree_type_is_down(CephContext *cct, int id, int subtree_type, std::set *down_in_osds, std::set *up_in_osds, + std::set *subtree_up, std::unordered_map > *subtree_type_down) const; int identify_osd(const entity_addr_t& addr) const; int identify_osd(const uuid_d& u) const; @@ -982,16 +982,16 @@ public: void get_random_up_osds_by_subtree(int n, // whoami - string &subtree, + std::string &subtree, int limit, // how many - set skip, - set *want) const; + std::set skip, + std::set *want) const; /** * get feature bits required by the current structure * * @param entity_type [in] what entity type we are asking about - * @param mask [out] set of all possible map-related features we could set + * @param mask [out] std::set of all possible map-related features we could std::set * @return feature bits used by this map */ uint64_t get_features(int entity_type, uint64_t *mask) const; @@ -1029,22 +1029,22 @@ public: // serialize, unserialize private: - void encode_client_old(bufferlist& bl) const; - void encode_classic(bufferlist& bl, uint64_t features) const; - void decode_classic(bufferlist::const_iterator& p); + void encode_client_old(ceph::buffer::list& bl) const; + void encode_classic(ceph::buffer::list& bl, uint64_t features) const; + void decode_classic(ceph::buffer::list::const_iterator& p); void post_decode(); public: - void encode(bufferlist& bl, uint64_t features=CEPH_FEATURES_ALL) const; - void decode(bufferlist& bl); - void decode(bufferlist::const_iterator& bl); + void encode(ceph::buffer::list& bl, uint64_t features=CEPH_FEATURES_ALL) const; + void decode(ceph::buffer::list& bl); + void decode(ceph::buffer::list::const_iterator& bl); /**** mapping facilities ****/ int map_to_pg( int64_t pool, - const string& name, - const string& key, - const string& nspace, + const std::string& name, + const std::string& key, + const std::string& nspace, pg_t *pg) const; int object_locator_to_pg(const object_t& oid, const object_locator_t& loc, pg_t &pg) const; @@ -1067,7 +1067,7 @@ public: } ceph_object_layout make_object_layout(object_t oid, int pg_pool, - string nspace) const; + std::string nspace) const; int get_pg_num(int pg_pool) const { @@ -1109,23 +1109,23 @@ public: } private: - /// pg -> (raw osd list) + /// pg -> (raw osd std::list) void _pg_to_raw_osds( const pg_pool_t& pool, pg_t pg, - vector *osds, + std::vector *osds, ps_t *ppps) const; - int _pick_primary(const vector& osds) const; - void _remove_nonexistent_osds(const pg_pool_t& pool, vector& osds) const; + int _pick_primary(const std::vector& osds) const; + void _remove_nonexistent_osds(const pg_pool_t& pool, std::vector& osds) const; void _apply_primary_affinity(ps_t seed, const pg_pool_t& pool, - vector *osds, int *primary) const; + std::vector *osds, int *primary) const; /// apply pg_upmap[_items] mappings - void _apply_upmap(const pg_pool_t& pi, pg_t pg, vector *raw) const; + void _apply_upmap(const pg_pool_t& pi, pg_t pg, std::vector *raw) const; - /// pg -> (up osd list) - void _raw_to_up_osds(const pg_pool_t& pool, const vector& raw, - vector *up) const; + /// pg -> (up osd std::list) + void _raw_to_up_osds(const pg_pool_t& pool, const std::vector& raw, + std::vector *up) const; /** @@ -1135,13 +1135,13 @@ private: * from the pg_temp (if specified), or -1 if you should use the calculated (up_)primary. */ void _get_temp_osds(const pg_pool_t& pool, pg_t pg, - vector *temp_pg, int *temp_primary) const; + std::vector *temp_pg, int *temp_primary) const; /** * map to up and acting. Fills in whatever fields are non-NULL. */ - void _pg_to_up_acting_osds(const pg_t& pg, vector *up, int *up_primary, - vector *acting, int *acting_primary, + void _pg_to_up_acting_osds(const pg_t& pg, std::vector *up, int *up_primary, + std::vector *acting, int *acting_primary, bool raw_pg_to_pg = true) const; public: @@ -1151,21 +1151,21 @@ public: * by anybody for data mapping purposes. * raw and primary must be non-NULL */ - void pg_to_raw_osds(pg_t pg, vector *raw, int *primary) const; - void pg_to_raw_upmap(pg_t pg, vector *raw_upmap) const; + void pg_to_raw_osds(pg_t pg, std::vector *raw, int *primary) const; + void pg_to_raw_upmap(pg_t pg, std::vector *raw_upmap) const; /// map a pg to its acting set. @return acting set size - void pg_to_acting_osds(const pg_t& pg, vector *acting, + void pg_to_acting_osds(const pg_t& pg, std::vector *acting, int *acting_primary) const { _pg_to_up_acting_osds(pg, NULL, NULL, acting, acting_primary); } - void pg_to_acting_osds(pg_t pg, vector& acting) const { + void pg_to_acting_osds(pg_t pg, std::vector& acting) const { return pg_to_acting_osds(pg, &acting, NULL); } /** * This does not apply temp overrides and should not be used * by anybody for data mapping purposes. Specify both pointers. */ - void pg_to_raw_up(pg_t pg, vector *up, int *primary) const; + void pg_to_raw_up(pg_t pg, std::vector *up, int *primary) const; /** * map a pg to its acting set as well as its up set. You must use * the acting set for data mapping purposes, but some users will @@ -1173,11 +1173,11 @@ public: * set as pg_temp. * Each of these pointers must be non-NULL. */ - void pg_to_up_acting_osds(pg_t pg, vector *up, int *up_primary, - vector *acting, int *acting_primary) const { + void pg_to_up_acting_osds(pg_t pg, std::vector *up, int *up_primary, + std::vector *acting, int *acting_primary) const { _pg_to_up_acting_osds(pg, up, up_primary, acting, acting_primary); } - void pg_to_up_acting_osds(pg_t pg, vector& up, vector& acting) const { + void pg_to_up_acting_osds(pg_t pg, std::vector& up, std::vector& acting) const { int up_primary, acting_primary; pg_to_up_acting_osds(pg, &up, &up_primary, &acting, &acting_primary); } @@ -1196,7 +1196,7 @@ public: return true; } int primary; - vector acting; + std::vector acting; pg_to_acting_osds(pgid, &acting, &primary); for (uint8_t i = 0; i < acting.size(); ++i) { if (acting[i] == primary) { @@ -1211,7 +1211,7 @@ public: if (i == get_pools().end()) { return false; } - vector acting; + std::vector acting; pg_to_acting_osds(pgid, &acting, primary); if (i->second.is_erasure()) { for (uint8_t i = 0; i < acting.size(); ++i) { @@ -1240,7 +1240,7 @@ public: return new_purged_snaps; } - int64_t lookup_pg_pool_name(const string& name) const { + int64_t lookup_pg_pool_name(const std::string& name) const { auto p = name_pool.find(name); if (p == name_pool.end()) return -ENOENT; @@ -1256,7 +1256,7 @@ public: mempool::osdmap::map& get_pools() { return pools; } - void get_pool_ids_by_rule(int rule_id, set *pool_ids) const { + void get_pool_ids_by_rule(int rule_id, std::set *pool_ids) const { ceph_assert(pool_ids); for (auto &p: pools) { if (p.second.get_crush_rule() == rule_id) { @@ -1266,13 +1266,13 @@ public: } void get_pool_ids_by_osd(CephContext *cct, int osd, - set *pool_ids) const; - const string& get_pool_name(int64_t p) const { + std::set *pool_ids) const; + const std::string& get_pool_name(int64_t p) const { auto i = pool_name.find(p); ceph_assert(i != pool_name.end()); return i->second; } - const mempool::osdmap::map& get_pool_names() const { + const mempool::osdmap::map& get_pool_names() const { return pool_name; } bool have_pg_pool(int64_t p) const { @@ -1313,7 +1313,7 @@ public: * check whether an spg_t maps to a particular osd */ bool is_up_acting_osd_shard(spg_t pg, int osd) const { - vector up, acting; + std::vector up, acting; _pg_to_up_acting_osds(pg.pgid, &up, NULL, &acting, NULL, false); if (pg.shard == shard_id_t::NO_SHARD) { if (calc_pg_role(osd, acting, acting.size()) >= 0 || @@ -1330,30 +1330,30 @@ public: /* what replica # is a given osd? 0 primary, -1 for none. */ - static int calc_pg_rank(int osd, const vector& acting, int nrep=0); - static int calc_pg_role(int osd, const vector& acting, int nrep=0); + static int calc_pg_rank(int osd, const std::vector& acting, int nrep=0); + static int calc_pg_role(int osd, const std::vector& acting, int nrep=0); static bool primary_changed( int oldprimary, - const vector &oldacting, + const std::vector &oldacting, int newprimary, - const vector &newacting); + const std::vector &newacting); /* rank is -1 (stray), 0 (primary), 1,2,3,... (replica) */ int get_pg_acting_rank(pg_t pg, int osd) const { - vector group; + std::vector group; pg_to_acting_osds(pg, group); return calc_pg_rank(osd, group, group.size()); } /* role is -1 (stray), 0 (primary), 1 (replica) */ int get_pg_acting_role(const pg_t& pg, int osd) const { - vector group; + std::vector group; pg_to_acting_osds(pg, group); return calc_pg_role(osd, group, group.size()); } bool osd_is_valid_op_target(pg_t pg, int osd) const { int primary; - vector group; + std::vector group; pg_to_acting_osds(pg, &group, &primary); if (osd == primary) return true; @@ -1370,20 +1370,20 @@ public: bool try_pg_upmap( CephContext *cct, pg_t pg, ///< pg to potentially remap - const set& overfull, ///< osds we'd want to evacuate - const vector& underfull, ///< osds to move to, in order of preference - vector *orig, - vector *out); ///< resulting alternative mapping + const std::set& overfull, ///< osds we'd want to evacuate + const std::vector& underfull, ///< osds to move to, in order of preference + std::vector *orig, + std::vector *out); ///< resulting alternative mapping int calc_pg_upmaps( CephContext *cct, float max_deviation, ///< max deviation from target (value < 1.0) int max_iterations, ///< max iterations to run - const set& pools, ///< [optional] restrict to pool + const std::set& pools, ///< [optional] restrict to pool Incremental *pending_inc ); - int get_osds_by_bucket_name(const string &name, set *osds) const; + int get_osds_by_bucket_name(const std::string &name, std::set *osds) const; bool have_pg_upmaps(pg_t pg) const { return pg_upmap.count(pg) || @@ -1421,18 +1421,18 @@ public: } static int _build_crush_types(CrushWrapper& crush); static int build_simple_crush_map(CephContext *cct, CrushWrapper& crush, - int num_osd, ostream *ss); + int num_osd, std::ostream *ss); static int build_simple_crush_map_from_conf(CephContext *cct, CrushWrapper& crush, - ostream *ss); + std::ostream *ss); static int build_simple_crush_rules( CephContext *cct, CrushWrapper& crush, - const string& root, - ostream *ss); + const std::string& root, + std::ostream *ss); bool crush_rule_in_use(int rule_id) const; - int validate_crush_rules(CrushWrapper *crush, ostream *ss) const; + int validate_crush_rules(CrushWrapper *crush, std::ostream *ss) const; void clear_temp() { pg_temp->clear(); @@ -1440,12 +1440,12 @@ public: } private: - void print_osd_line(int cur, ostream *out, Formatter *f) const; + void print_osd_line(int cur, std::ostream *out, ceph::Formatter *f) const; public: - void print(ostream& out) const; - void print_pools(ostream& out) const; - void print_summary(Formatter *f, ostream& out, const string& prefix, bool extra=false) const; - void print_oneline_summary(ostream& out) const; + void print(std::ostream& out) const; + void print_pools(std::ostream& out) const; + void print_summary(ceph::Formatter *f, std::ostream& out, const std::string& prefix, bool extra=false) const; + void print_oneline_summary(std::ostream& out) const; enum { DUMP_IN = 1, // only 'in' osds @@ -1454,28 +1454,28 @@ public: DUMP_DOWN = 8, // only 'down' osds DUMP_DESTROYED = 16, // only 'destroyed' osds }; - void print_tree(Formatter *f, ostream *out, unsigned dump_flags=0, string bucket="") const; + void print_tree(ceph::Formatter *f, std::ostream *out, unsigned dump_flags=0, std::string bucket="") const; int summarize_mapping_stats( OSDMap *newmap, - const set *pools, + const std::set *pools, std::string *out, - Formatter *f) const; + ceph::Formatter *f) const; - string get_flag_string() const; - static string get_flag_string(unsigned flags); + std::string get_flag_string() const; + static std::string get_flag_string(unsigned flags); static void dump_erasure_code_profiles( - const mempool::osdmap::map > &profiles, - Formatter *f); - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + const mempool::osdmap::map > &profiles, + ceph::Formatter *f); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); bool check_new_blacklist_entries() const { return new_blacklist_entries; } void check_health(health_check_map_t *checks) const; - int parse_osd_id_list(const vector& ls, - set *out, - ostream *ss) const; + int parse_osd_id_list(const std::vector& ls, + std::set *out, + std::ostream *ss) const; float pool_raw_used_rate(int64_t poolid) const; @@ -1485,7 +1485,7 @@ WRITE_CLASS_ENCODER_FEATURES(OSDMap::Incremental) typedef std::shared_ptr OSDMapRef; -inline ostream& operator<<(ostream& out, const OSDMap& m) { +inline std::ostream& operator<<(std::ostream& out, const OSDMap& m) { m.print_oneline_summary(out); return out; } @@ -1494,10 +1494,10 @@ class PGMap; void print_osd_utilization(const OSDMap& osdmap, const PGMap& pgmap, - ostream& out, - Formatter *f, + std::ostream& out, + ceph::Formatter *f, bool tree, - const string& class_name, - const string& item_name); + const std::string& class_name, + const std::string& item_name); #endif -- 2.39.5