From: Max Kellermann Date: Wed, 13 Nov 2024 20:56:49 +0000 (+0100) Subject: mds/Migrator: un-inline methods to reduce compile times X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=52690e43bec65328887bae09427fa1d8057d3652;p=ceph.git mds/Migrator: un-inline methods to reduce compile times Signed-off-by: Max Kellermann --- diff --git a/src/mds/Migrator.cc b/src/mds/Migrator.cc index d23acc7c0ce..e642f73b9c8 100644 --- a/src/mds/Migrator.cc +++ b/src/mds/Migrator.cc @@ -83,6 +83,65 @@ using namespace std; +struct Migrator::export_state_t { + export_state_t() {} + + void set_state(int s) { + ceph_assert(s != state); + if (state != EXPORT_CANCELLED) { + auto& t = state_history.at(state); + t.second = double(ceph_clock_now()) - double(t.first); + } + state = s; + state_history[state] = std::pair(ceph_clock_now(), 0.0); + } + utime_t get_start_time(int s) const { + ceph_assert(state_history.count(s) > 0); + return state_history.at(s).first; + } + double get_time_spent(int s) const { + ceph_assert(state_history.count(s) > 0); + const auto& t = state_history.at(s); + return s == state ? double(ceph_clock_now()) - double(t.first) : t.second; + } + double get_freeze_tree_time() const { + ceph_assert(state >= EXPORT_DISCOVERING); + ceph_assert(state_history.count((int)EXPORT_DISCOVERING) > 0); + return double(ceph_clock_now()) - double(state_history.at((int)EXPORT_DISCOVERING).first); + }; + + int state = EXPORT_CANCELLED; + mds_rank_t peer = MDS_RANK_NONE; + uint64_t tid = 0; + std::set warning_ack_waiting; + std::set notify_ack_waiting; + std::map > peer_imported; + MutationRef mut; + size_t approx_size = 0; + // record the start time and time spent of each export state + std::map > state_history; + // record the clients whose sessions need to be flushed + std::set export_client_set; + // for freeze tree deadlock detection + utime_t last_cum_auth_pins_change; + int last_cum_auth_pins = 0; + int num_remote_waiters = 0; // number of remote authpin waiters + std::shared_ptr parent; +}; + +struct Migrator::import_state_t { + import_state_t() : mut() {} + int state = 0; + mds_rank_t peer = 0; + uint64_t tid = 0; + std::set bystanders; + std::list bound_ls; + std::list updated_scatterlocks; + std::map > session_map; + std::map > peer_exports; + MutationRef mut; +}; + class MigratorContext : public MDSContext { protected: Migrator *mig; @@ -637,7 +696,65 @@ void Migrator::show_exporting() } } +int Migrator::is_exporting(CDir *dir) const { + auto it = export_state.find(dir); + if (it != export_state.end()) return it->second.state; + return 0; +} + +int Migrator::is_importing(dirfrag_t df) const { + auto it = import_state.find(df); + if (it != import_state.end()) return it->second.state; + return 0; +} + +bool Migrator::is_ambiguous_import(dirfrag_t df) const { + auto it = import_state.find(df); + if (it == import_state.end()) + return false; + if (it->second.state >= IMPORT_LOGGINGSTART && + it->second.state < IMPORT_ABORTING) + return true; + return false; +} + +int Migrator::get_import_state(dirfrag_t df) const { + auto it = import_state.find(df); + ceph_assert(it != import_state.end()); + return it->second.state; +} + +int Migrator::get_import_peer(dirfrag_t df) const { + auto it = import_state.find(df); + ceph_assert(it != import_state.end()); + return it->second.peer; +} + +int Migrator::get_export_state(CDir *dir) const { + auto it = export_state.find(dir); + ceph_assert(it != export_state.end()); + return it->second.state; +} + +bool Migrator::export_has_warned(CDir *dir, mds_rank_t who) { + auto it = export_state.find(dir); + ceph_assert(it != export_state.end()); + ceph_assert(it->second.state == EXPORT_WARNING); + return (it->second.warning_ack_waiting.count(who) == 0); +} + +bool Migrator::export_has_notified(CDir *dir, mds_rank_t who) const { + auto it = export_state.find(dir); + ceph_assert(it != export_state.end()); + ceph_assert(it->second.state == EXPORT_NOTIFYING); + return (it->second.notify_ack_waiting.count(who) == 0); +} +void Migrator::export_freeze_inc_num_waiters(CDir *dir) { + auto it = export_state.find(dir); + ceph_assert(it != export_state.end()); + it->second.num_remote_waiters++; +} void Migrator::audit() { @@ -3861,6 +3978,8 @@ Migrator::Migrator(MDSRank *m, MDCache *c) : mds(m), mdcache(c) { inject_session_race = g_conf().get_val("mds_inject_migrator_session_race"); } +Migrator::~Migrator() noexcept = default; + void Migrator::handle_conf_change(const std::set& changed, const MDSMap& mds_map) { if (changed.count("mds_max_export_size")) diff --git a/src/mds/Migrator.h b/src/mds/Migrator.h index d768e46fbd0..88f99bd8531 100644 --- a/src/mds/Migrator.h +++ b/src/mds/Migrator.h @@ -77,6 +77,7 @@ public: // -- cons -- Migrator(MDSRank *m, MDCache *c); + ~Migrator() noexcept; static std::string_view get_export_statename(int s) { switch (s) { @@ -118,68 +119,25 @@ public: int get_export_queue_size() const { return export_queue.size(); } // -- status -- - int is_exporting(CDir *dir) const { - auto it = export_state.find(dir); - if (it != export_state.end()) return it->second.state; - return 0; - } + int is_exporting(CDir *dir) const; bool is_exporting() const { return !export_state.empty(); } - int is_importing(dirfrag_t df) const { - auto it = import_state.find(df); - if (it != import_state.end()) return it->second.state; - return 0; - } + int is_importing(dirfrag_t df) const; bool is_importing() const { return !import_state.empty(); } - bool is_ambiguous_import(dirfrag_t df) const { - auto it = import_state.find(df); - if (it == import_state.end()) - return false; - if (it->second.state >= IMPORT_LOGGINGSTART && - it->second.state < IMPORT_ABORTING) - return true; - return false; - } - - int get_import_state(dirfrag_t df) const { - auto it = import_state.find(df); - ceph_assert(it != import_state.end()); - return it->second.state; - } - int get_import_peer(dirfrag_t df) const { - auto it = import_state.find(df); - ceph_assert(it != import_state.end()); - return it->second.peer; - } + bool is_ambiguous_import(dirfrag_t df) const; - int get_export_state(CDir *dir) const { - auto it = export_state.find(dir); - ceph_assert(it != export_state.end()); - return it->second.state; - } + int get_import_state(dirfrag_t df) const; + int get_import_peer(dirfrag_t df) const; + int get_export_state(CDir *dir) const; // this returns true if we are export @dir, // and are not waiting for @who to be // be warned of ambiguous auth. // only returns meaningful results during EXPORT_WARNING state. - bool export_has_warned(CDir *dir, mds_rank_t who) { - auto it = export_state.find(dir); - ceph_assert(it != export_state.end()); - ceph_assert(it->second.state == EXPORT_WARNING); - return (it->second.warning_ack_waiting.count(who) == 0); - } + bool export_has_warned(CDir *dir, mds_rank_t who); - bool export_has_notified(CDir *dir, mds_rank_t who) const { - auto it = export_state.find(dir); - ceph_assert(it != export_state.end()); - ceph_assert(it->second.state == EXPORT_NOTIFYING); - return (it->second.notify_ack_waiting.count(who) == 0); - } + bool export_has_notified(CDir *dir, mds_rank_t who) const; - void export_freeze_inc_num_waiters(CDir *dir) { - auto it = export_state.find(dir); - ceph_assert(it != export_state.end()); - it->second.num_remote_waiters++; - } + void export_freeze_inc_num_waiters(CDir *dir); void find_stale_export_freeze(); // -- misc -- @@ -270,65 +228,10 @@ protected: }; // export fun - struct export_state_t { - export_state_t() {} - - void set_state(int s) { - ceph_assert(s != state); - if (state != EXPORT_CANCELLED) { - auto& t = state_history.at(state); - t.second = double(ceph_clock_now()) - double(t.first); - } - state = s; - state_history[state] = std::pair(ceph_clock_now(), 0.0); - } - utime_t get_start_time(int s) const { - ceph_assert(state_history.count(s) > 0); - return state_history.at(s).first; - } - double get_time_spent(int s) const { - ceph_assert(state_history.count(s) > 0); - const auto& t = state_history.at(s); - return s == state ? double(ceph_clock_now()) - double(t.first) : t.second; - } - double get_freeze_tree_time() const { - ceph_assert(state >= EXPORT_DISCOVERING); - ceph_assert(state_history.count((int)EXPORT_DISCOVERING) > 0); - return double(ceph_clock_now()) - double(state_history.at((int)EXPORT_DISCOVERING).first); - }; - - int state = EXPORT_CANCELLED; - mds_rank_t peer = MDS_RANK_NONE; - uint64_t tid = 0; - std::set warning_ack_waiting; - std::set notify_ack_waiting; - std::map > peer_imported; - MutationRef mut; - size_t approx_size = 0; - // record the start time and time spent of each export state - std::map > state_history; - // record the clients whose sessions need to be flushed - std::set export_client_set; - // for freeze tree deadlock detection - utime_t last_cum_auth_pins_change; - int last_cum_auth_pins = 0; - int num_remote_waiters = 0; // number of remote authpin waiters - std::shared_ptr parent; - }; + struct export_state_t; // import fun - struct import_state_t { - import_state_t() : mut() {} - int state = 0; - mds_rank_t peer = 0; - uint64_t tid = 0; - std::set bystanders; - std::list bound_ls; - std::list updated_scatterlocks; - std::map > session_map; - std::map > peer_exports; - MutationRef mut; - }; + struct import_state_t; typedef std::map::iterator export_state_iterator;