From 79f7576401cc9d857f84396314d7476336c0e271 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Tue, 2 Nov 2021 00:34:34 +0000 Subject: [PATCH] mds: Server: Simplify apply_blocklist and usage of the OSDMap's blocklist This previoulsly re-implemented a bunch of the OSDMap::is_blocklisted() function, and wasn't actually any faster to run -- the list of new blocklists may be smaller than the full set, but OSDMap::blocklist is an unordered_map of constant lookup time so it shouldn't slow things down. More importantly, this is much simpler, less likely to be buggy from duplicate code, and lets the MDS off the hook for dealing with range blocklisting. Signed-off-by: Greg Farnum --- src/mds/MDSRank.cc | 4 ++-- src/mds/Server.cc | 41 +++++++++++++---------------------------- src/mds/Server.h | 2 +- 3 files changed, 16 insertions(+), 31 deletions(-) diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index 053799c0df0..5bfafacc34f 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -1948,8 +1948,8 @@ void MDSRank::resolve_done() } void MDSRank::apply_blocklist(const std::set &addrs, epoch_t epoch) { - auto victims = server->apply_blocklist(addrs); - dout(4) << __func__ << ": killed " << victims << " blocklisted sessions (" + auto victims = server->apply_blocklist(); + dout(4) << __func__ << ": killed " << victims << ", blocklisted sessions (" << addrs.size() << " blocklist entries, " << sessionmap.get_sessions().size() << ")" << dendl; if (victims) { diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 5b54e8112a4..444e7b8e8c8 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -1306,38 +1306,23 @@ void Server::kill_session(Session *session, Context *on_safe) } } -size_t Server::apply_blocklist(const std::set &blocklist) +size_t Server::apply_blocklist() { - bool prenautilus = mds->objecter->with_osdmap( - [&](const OSDMap& o) { - return o.require_osd_release < ceph_release_t::nautilus; - }); - std::vector victims; const auto& sessions = mds->sessionmap.get_sessions(); - for (const auto& p : sessions) { - if (!p.first.is_client()) { - // Do not apply OSDMap blocklist to MDS daemons, we find out - // about their death via MDSMap. - continue; - } - - Session *s = p.second; - auto inst_addr = s->info.inst.addr; - // blocklist entries are always TYPE_ANY for nautilus+ - inst_addr.set_type(entity_addr_t::TYPE_ANY); - if (blocklist.count(inst_addr)) { - victims.push_back(s); - continue; - } - if (prenautilus) { - // ...except pre-nautilus, they were TYPE_LEGACY - inst_addr.set_type(entity_addr_t::TYPE_LEGACY); - if (blocklist.count(inst_addr)) { - victims.push_back(s); + mds->objecter->with_osdmap( + [&](const OSDMap& o) { + for (const auto& p : sessions) { + if (!p.first.is_client()) { + // Do not apply OSDMap blocklist to MDS daemons, we find out + // about their death via MDSMap. + continue; + } + if (o.is_blocklisted(p.second->info.inst.addr)) { + victims.push_back(p.second); + } } - } - } + }); for (const auto& s : victims) { kill_session(s, nullptr); diff --git a/src/mds/Server.h b/src/mds/Server.h index d470125227a..83449e7c5d3 100644 --- a/src/mds/Server.h +++ b/src/mds/Server.h @@ -134,7 +134,7 @@ public: void find_idle_sessions(); void kill_session(Session *session, Context *on_safe); - size_t apply_blocklist(const std::set &blocklist); + size_t apply_blocklist(); void journal_close_session(Session *session, int state, Context *on_safe); size_t get_num_pending_reclaim() const { return client_reclaim_gather.size(); } -- 2.39.5