From 8c47f85b825f5a2eb18280fc4ab85def4ece4a68 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 19 Aug 2025 16:36:44 +0200 Subject: [PATCH] mds/MDSTableServer: forward-declare MMDSTableRequest Signed-off-by: Max Kellermann --- src/mds/MDSTableServer.cc | 62 ++++++++++++++++++++++++++++++++++++ src/mds/MDSTableServer.h | 66 ++++++++++----------------------------- 2 files changed, 78 insertions(+), 50 deletions(-) diff --git a/src/mds/MDSTableServer.cc b/src/mds/MDSTableServer.cc index 505a686db2caf..6bafcdcb162b8 100644 --- a/src/mds/MDSTableServer.cc +++ b/src/mds/MDSTableServer.cc @@ -21,6 +21,8 @@ #include "events/ETableServer.h" #include "common/debug.h" +#include "messages/MMDSTableRequest.h" + #define dout_context g_ceph_context #define dout_subsys ceph_subsys_mds #undef dout_prefix @@ -28,6 +30,56 @@ using namespace std; +struct MDSTableServer::notify_info_t { + notify_info_t() {} + std::set notify_ack_gather; + mds_rank_t mds; + ref_t reply = NULL; + MDSContext *onfinish = nullptr; +}; + +MDSTableServer::MDSTableServer(MDSRank *m, int tab) : + MDSTable(m, get_mdstable_name(tab), false), table(tab) {} + +MDSTableServer::~MDSTableServer() = default; + +MDSTableServer::MDSTableServer(const MDSTableServer &) = default; +MDSTableServer &MDSTableServer::operator=(const MDSTableServer &) = default; + +void MDSTableServer::_note_prepare(mds_rank_t mds, uint64_t reqid, bool replay) { + version++; + if (replay) + projected_version = version; + pending_for_mds[version].mds = mds; + pending_for_mds[version].reqid = reqid; + pending_for_mds[version].tid = version; +} + +void MDSTableServer::_note_commit(uint64_t tid, bool replay) { + version++; + if (replay) + projected_version = version; + pending_for_mds.erase(tid); +} + +void MDSTableServer::_note_rollback(uint64_t tid, bool replay) { + version++; + if (replay) + projected_version = version; + pending_for_mds.erase(tid); +} + +void MDSTableServer::_note_server_update(bufferlist& bl, bool replay) { + version++; + if (replay) + projected_version = version; +} + +void MDSTableServer::reset_state() { + pending_for_mds.clear(); + ++version; +} + void MDSTableServer::handle_request(const cref_t &req) { ceph_assert(req->op >= 0); @@ -297,6 +349,16 @@ void MDSTableServer::_do_server_recovery() recovered = true; } +void MDSTableServer::encode_state(bufferlist& bl) const { + encode_server_state(bl); + encode(pending_for_mds, bl); +} + +void MDSTableServer::decode_state(bufferlist::const_iterator& bl) { + decode_server_state(bl); + decode(pending_for_mds, bl); +} + void MDSTableServer::finish_recovery(set& active) { dout(7) << __func__ << dendl; diff --git a/src/mds/MDSTableServer.h b/src/mds/MDSTableServer.h index 6d84374a152e0..29cd999eaa372 100644 --- a/src/mds/MDSTableServer.h +++ b/src/mds/MDSTableServer.h @@ -22,19 +22,21 @@ #include "mdstypes.h" // for mds_table_pending_t #include "mds_table_types.h" // for get_mdstable_name() -#include "messages/MMDSTableRequest.h" - #include "common/ref.h" // for cref_t class MDSContext; +class MMDSTableRequest; class MDSTableServer : public MDSTable { public: friend class C_ServerRecovery; - MDSTableServer(MDSRank *m, int tab) : - MDSTable(m, get_mdstable_name(tab), false), table(tab) {} - ~MDSTableServer() override {} + MDSTableServer(MDSRank *m, int tab); + ~MDSTableServer(); + + // required by DencoderImplFeatureful::copy() + MDSTableServer(const MDSTableServer &); + MDSTableServer &operator=(const MDSTableServer &); virtual void handle_query(const cref_t &m) = 0; virtual void _prepare(const bufferlist &bl, uint64_t reqid, mds_rank_t bymds, bufferlist& out) = 0; @@ -44,36 +46,12 @@ public: virtual void _server_update(bufferlist& bl) { ceph_abort(); } virtual bool _notify_prep(version_t tid) { return false; }; - void _note_prepare(mds_rank_t mds, uint64_t reqid, bool replay=false) { - version++; - if (replay) - projected_version = version; - pending_for_mds[version].mds = mds; - pending_for_mds[version].reqid = reqid; - pending_for_mds[version].tid = version; - } - void _note_commit(uint64_t tid, bool replay=false) { - version++; - if (replay) - projected_version = version; - pending_for_mds.erase(tid); - } - void _note_rollback(uint64_t tid, bool replay=false) { - version++; - if (replay) - projected_version = version; - pending_for_mds.erase(tid); - } - void _note_server_update(bufferlist& bl, bool replay=false) { - version++; - if (replay) - projected_version = version; - } - - void reset_state() override { - pending_for_mds.clear(); - ++version; - } + void _note_prepare(mds_rank_t mds, uint64_t reqid, bool replay=false); + void _note_commit(uint64_t tid, bool replay=false); + void _note_rollback(uint64_t tid, bool replay=false); + void _note_server_update(bufferlist& bl, bool replay=false); + + void reset_state() override; void handle_request(const cref_t &m); void do_server_update(bufferlist& bl); @@ -81,14 +59,8 @@ public: virtual void encode_server_state(bufferlist& bl) const = 0; virtual void decode_server_state(bufferlist::const_iterator& bl) = 0; - void encode_state(bufferlist& bl) const override { - encode_server_state(bl); - encode(pending_for_mds, bl); - } - void decode_state(bufferlist::const_iterator& bl) override { - decode_server_state(bl); - decode(pending_for_mds, bl); - } + void encode_state(bufferlist& bl) const override; + void decode_state(bufferlist::const_iterator& bl) override; // recovery void finish_recovery(std::set& active); @@ -101,13 +73,7 @@ protected: bool recovered = false; std::set active_clients; private: - struct notify_info_t { - notify_info_t() {} - std::set notify_ack_gather; - mds_rank_t mds; - ref_t reply = NULL; - MDSContext *onfinish = nullptr; - }; + struct notify_info_t; friend class C_Prepare; friend class C_Commit; -- 2.39.5