From 84f12809919fe93ff43e7e8b7c22fb5ffeb35990 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Thu, 5 Oct 2023 00:22:51 +0530 Subject: [PATCH] src/MDSMonitor: make use of imported namespace symbols Symbols imported into current namespace should be used directly; there is no need to mention their parent namespace while using them. IOW, to use "std::string" after it has been imported, just write "string" instead of "std::string". Signed-off-by: Rishabh Dave --- src/mon/MDSMonitor.cc | 61 ++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 163cb59505998..fb17458d2e3b2 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -62,7 +62,8 @@ using ceph::mono_time; #define dout_subsys ceph_subsys_mon #undef dout_prefix #define dout_prefix _prefix(_dout, mon, get_fsmap()) -static ostream& _prefix(std::ostream *_dout, Monitor &mon, const FSMap& fsmap) { + +static ostream& _prefix(ostream *_dout, Monitor &mon, const FSMap& fsmap) { return *_dout << "mon." << mon.name << "@" << mon.rank << "(" << mon.get_state_name() << ").mds e" << fsmap.get_epoch() << " "; @@ -78,19 +79,19 @@ static const string MDS_HEALTH_PREFIX("mds_health"); */ namespace TOPNSPC::common { template<> bool cmd_getval(const cmdmap_t& cmdmap, - std::string_view k, mds_gid_t &val) + string_view k, mds_gid_t &val) { return cmd_getval(cmdmap, k, (int64_t&)val); } template<> bool cmd_getval(const cmdmap_t& cmdmap, - std::string_view k, mds_rank_t &val) + string_view k, mds_rank_t &val) { return cmd_getval(cmdmap, k, (int64_t&)val); } template<> bool cmd_getval(const cmdmap_t& cmdmap, - std::string_view k, MDSMap::DaemonState &val) + string_view k, MDSMap::DaemonState &val) { return cmd_getval(cmdmap, k, (int64_t&)val); } @@ -195,14 +196,14 @@ void MDSMonitor::encode_pending(MonitorDBStore::TransactionRef t) put_last_committed(t, pending.get_epoch()); // Encode MDSHealth data - for (std::map::iterator i = pending_daemon_health.begin(); + for (map::iterator i = pending_daemon_health.begin(); i != pending_daemon_health.end(); ++i) { bufferlist bl; i->second.encode(bl); t->put(MDS_HEALTH_PREFIX, stringify(i->first), bl); } - for (std::set::iterator i = pending_daemon_health_rm.begin(); + for (set::iterator i = pending_daemon_health_rm.begin(); i != pending_daemon_health_rm.end(); ++i) { t->erase(MDS_HEALTH_PREFIX, stringify(*i)); } @@ -588,12 +589,12 @@ bool MDSMonitor::prepare_beacon(MonOpRequestRef op) const auto &old_health = pending_daemon_health[gid].metrics; const auto &new_health = m->get_health().metrics; - std::set old_types; + set old_types; for (const auto &i : old_health) { old_types.insert(i.type); } - std::set new_types; + set new_types; for (const auto &i : new_health) { if (i.type == MDS_HEALTH_DUMMY) { continue; @@ -1073,7 +1074,7 @@ bool MDSMonitor::preprocess_command(MonOpRequestRef op) f->open_object_section("mds"); f->dump_string("name", info.name); - std::ostringstream get_err; + ostringstream get_err; r = dump_metadata(fsmap, info.name, f.get(), get_err); if (r == -EINVAL || r == -ENOENT) { // Drop error, list what metadata we do have @@ -1282,11 +1283,11 @@ bool MDSMonitor::fail_mds_gid(FSMap &fsmap, mds_gid_t gid) return blocklist_epoch != 0; } -mds_gid_t MDSMonitor::gid_from_arg(const FSMap &fsmap, const std::string &arg, std::ostream &ss) +mds_gid_t MDSMonitor::gid_from_arg(const FSMap &fsmap, const string &arg, ostream &ss) { // Try parsing as a role mds_role_t role; - std::ostringstream ignore_err; // Don't spam 'ss' with parse_role errors + ostringstream ignore_err; // Don't spam 'ss' with parse_role errors int r = fsmap.parse_role(arg, &role, ignore_err); if (r == 0) { // See if a GID is assigned to this role @@ -1300,7 +1301,7 @@ mds_gid_t MDSMonitor::gid_from_arg(const FSMap &fsmap, const std::string &arg, s } // Try parsing as a gid - std::string err; + string err; unsigned long long maybe_gid = strict_strtoll(arg.c_str(), 10, &err); if (!err.empty()) { // Not a role or a GID, try as a daemon name @@ -1328,8 +1329,8 @@ mds_gid_t MDSMonitor::gid_from_arg(const FSMap &fsmap, const std::string &arg, s return MDS_GID_NONE; } -int MDSMonitor::fail_mds(FSMap &fsmap, std::ostream &ss, - const std::string &arg, MDSMap::mds_info_t *failed_info) +int MDSMonitor::fail_mds(FSMap &fsmap, ostream &ss, + const string &arg, MDSMap::mds_info_t *failed_info) { ceph_assert(failed_info != nullptr); @@ -1440,9 +1441,9 @@ out: int MDSMonitor::filesystem_command( FSMap &fsmap, MonOpRequestRef op, - std::string const &prefix, + string const &prefix, const cmdmap_t& cmdmap, - std::stringstream &ss) + stringstream &ss) { dout(4) << __func__ << " prefix='" << prefix << "'" << dendl; op->mark_mdsmon_event(__func__); @@ -1540,7 +1541,7 @@ int MDSMonitor::filesystem_command( return -EPERM; } - std::string role_str; + string role_str; cmd_getval(cmdmap, "role", role_str); mds_role_t role; const auto fs_names = op->get_session()->get_allowed_fs_names(); @@ -1596,7 +1597,7 @@ int MDSMonitor::filesystem_command( } r = 0; } else if (prefix == "mds repaired") { - std::string role_str; + string role_str; cmd_getval(cmdmap, "role", role_str); mds_role_t role; const auto fs_names = op->get_session()->get_allowed_fs_names(); @@ -1619,7 +1620,7 @@ int MDSMonitor::filesystem_command( r = 0; } else if (prefix == "mds freeze") { - std::string who; + string who; cmd_getval(cmdmap, "role_or_gid", who); mds_gid_t gid = gid_from_arg(fsmap, who, ss); if (gid == MDS_GID_NONE) { @@ -1634,7 +1635,7 @@ int MDSMonitor::filesystem_command( bool freeze = false; { - std::string str; + string str; cmd_getval(cmdmap, "val", str); if ((r = parse_bool(str, &freeze, ss)) != 0) { return r; @@ -1666,7 +1667,7 @@ void MDSMonitor::check_subs() // filesystems. Build a list of all the types we service // subscriptions for. - std::vector types = { + vector types = { "fsmap", "fsmap.user", "mdsmap", @@ -1675,7 +1676,7 @@ void MDSMonitor::check_subs() for (const auto& [fscid, fs] : get_fsmap()) { CachedStackStringStream cos; *cos << "mdsmap." << fscid; - types.push_back(std::string(cos->strv())); + types.push_back(string(cos->strv())); } for (const auto &type : types) { @@ -1744,9 +1745,9 @@ void MDSMonitor::check_sub(Subscription *sub) // You're a client. Did you request a particular // namespace? if (sub->type.compare(0, 7, "mdsmap.") == 0) { - auto namespace_id_str = sub->type.substr(std::string("mdsmap.").size()); + auto namespace_id_str = sub->type.substr(string("mdsmap.").size()); dout(10) << __func__ << ": namespace_id " << namespace_id_str << dendl; - std::string err; + string err; fscid = strict_strtoll(namespace_id_str.c_str(), 10, &err); if (!err.empty()) { // Client asked for a non-existent namespace, send them nothing @@ -1868,7 +1869,7 @@ int MDSMonitor::load_metadata(map& m) return 0; } -void MDSMonitor::count_metadata(const std::string &field, map *out) +void MDSMonitor::count_metadata(const string &field, map *out) { map meta; load_metadata(meta); @@ -1882,7 +1883,7 @@ void MDSMonitor::count_metadata(const std::string &field, map *out) } } -void MDSMonitor::count_metadata(const std::string &field, Formatter *f) +void MDSMonitor::count_metadata(const string &field, Formatter *f) { map by_val; count_metadata(field, &by_val); @@ -1893,12 +1894,12 @@ void MDSMonitor::count_metadata(const std::string &field, Formatter *f) f->close_section(); } -void MDSMonitor::get_versions(std::map > &versions) +void MDSMonitor::get_versions(map > &versions) { map meta; load_metadata(meta); const auto &fsmap = get_fsmap(); - std::map map = fsmap.get_mds_info(); + map map = fsmap.get_mds_info(); dout(10) << __func__ << " mds meta=" << meta << dendl; for (auto& p : meta) { auto q = p.second.find("ceph_version_short"); @@ -1907,7 +1908,7 @@ void MDSMonitor::get_versions(std::map > &versions) } } -int MDSMonitor::dump_metadata(const FSMap& fsmap, const std::string &who, +int MDSMonitor::dump_metadata(const FSMap& fsmap, const string &who, Formatter *f, ostream& err) { ceph_assert(f); @@ -2126,7 +2127,7 @@ bool MDSMonitor::check_health(FSMap& fsmap, bool* propose_osdmap) std::max(g_conf()->mds_beacon_interval, g_conf()->mds_beacon_grace * 0.5); // check beacon timestamps - std::vector to_remove; + vector to_remove; const bool mon_down = mon.is_mon_down(); const auto mds_beacon_mon_down_grace = g_conf().get_val("mds_beacon_mon_down_grace"); -- 2.39.5