From: Max Kellermann Date: Tue, 19 Aug 2025 14:25:51 +0000 (+0200) Subject: mds/SnapServer: un-inline methods to reduce header dependencies X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f4e58c2d8b957d2ba8ecccf1af471b7b156e7e62;p=ceph.git mds/SnapServer: un-inline methods to reduce header dependencies Signed-off-by: Max Kellermann --- diff --git a/src/mds/SnapServer.cc b/src/mds/SnapServer.cc index 3d35900faeb..275fc1e069c 100644 --- a/src/mds/SnapServer.cc +++ b/src/mds/SnapServer.cc @@ -14,6 +14,7 @@ #include "SnapServer.h" #include "MDSRank.h" +#include "snap.h" #include "osd/OSDMap.h" #include "osdc/Objecter.h" @@ -34,6 +35,12 @@ using namespace std; +SnapServer::SnapServer(MDSRank *m, MonClient *monc) + : MDSTableServer(m, TABLE_SNAP), mon_client(monc) {} +SnapServer::SnapServer() : MDSTableServer(NULL, TABLE_SNAP) {} + +SnapServer::~SnapServer() noexcept = default; + void SnapServer::reset_state() { last_snap = 1; /* snapid 1 reserved for initial root snaprealm */ @@ -69,6 +76,50 @@ void SnapServer::reset_state() MDSTableServer::reset_state(); } +void SnapServer::encode_server_state(bufferlist& bl) const { + ENCODE_START(5, 3, bl); + encode(last_snap, bl); + encode(snaps, bl); + encode(need_to_purge, bl); + encode(pending_update, bl); + encode(pending_destroy, bl); + encode(pending_noop, bl); + encode(last_created, bl); + encode(last_destroyed, bl); + encode(snaprealm_v2_since, bl); + ENCODE_FINISH(bl); +} + +void SnapServer::decode_server_state(bufferlist::const_iterator& bl) { + DECODE_START_LEGACY_COMPAT_LEN(5, 3, 3, bl); + decode(last_snap, bl); + decode(snaps, bl); + decode(need_to_purge, bl); + decode(pending_update, bl); + if (struct_v >= 2) + decode(pending_destroy, bl); + else { + std::map t; + decode(t, bl); + for (auto& [ver, snapid] : t) { + pending_destroy[ver].first = snapid; + } + } + decode(pending_noop, bl); + if (struct_v >= 4) { + decode(last_created, bl); + decode(last_destroyed, bl); + } else { + last_created = last_snap; + last_destroyed = last_snap; + } + if (struct_v >= 5) + decode(snaprealm_v2_since, bl); + else + snaprealm_v2_since = CEPH_NOSNAP; + + DECODE_FINISH(bl); +} // SERVER @@ -364,6 +415,10 @@ void SnapServer::check_osd_map(bool force) last_checked_osdmap = version; } +bool SnapServer::can_allow_multimds_snaps() const { + return snaps.empty() || snaps.begin()->first >= snaprealm_v2_since; +} + void SnapServer::handle_remove_snaps(const cref_t &m) { dout(10) << __func__ << " " << *m << dendl; diff --git a/src/mds/SnapServer.h b/src/mds/SnapServer.h index 67f4be7842c..2ec668ca481 100644 --- a/src/mds/SnapServer.h +++ b/src/mds/SnapServer.h @@ -20,19 +20,19 @@ #include #include "MDSTableServer.h" -#include "snap.h" #include "include/encoding.h" #include "include/object.h" // for struct snapid_t class MDSRank; class MRemoveSnaps; class MonClient; +struct SnapInfo; class SnapServer : public MDSTableServer { public: - SnapServer(MDSRank *m, MonClient *monc) - : MDSTableServer(m, TABLE_SNAP), mon_client(monc) {} - SnapServer() : MDSTableServer(NULL, TABLE_SNAP) {} + SnapServer(MDSRank *m, MonClient *monc); + SnapServer(); + ~SnapServer() noexcept; void handle_remove_snaps(const cref_t &m); @@ -58,9 +58,7 @@ public: void check_osd_map(bool force); - bool can_allow_multimds_snaps() const { - return snaps.empty() || snaps.begin()->first >= snaprealm_v2_since; - } + bool can_allow_multimds_snaps() const; void encode(bufferlist& bl) const { encode_server_state(bl); @@ -76,49 +74,8 @@ public: std::map& _snaps); protected: - void encode_server_state(bufferlist& bl) const override { - ENCODE_START(5, 3, bl); - encode(last_snap, bl); - encode(snaps, bl); - encode(need_to_purge, bl); - encode(pending_update, bl); - encode(pending_destroy, bl); - encode(pending_noop, bl); - encode(last_created, bl); - encode(last_destroyed, bl); - encode(snaprealm_v2_since, bl); - ENCODE_FINISH(bl); - } - void decode_server_state(bufferlist::const_iterator& bl) override { - DECODE_START_LEGACY_COMPAT_LEN(5, 3, 3, bl); - decode(last_snap, bl); - decode(snaps, bl); - decode(need_to_purge, bl); - decode(pending_update, bl); - if (struct_v >= 2) - decode(pending_destroy, bl); - else { - std::map t; - decode(t, bl); - for (auto& [ver, snapid] : t) { - pending_destroy[ver].first = snapid; - } - } - decode(pending_noop, bl); - if (struct_v >= 4) { - decode(last_created, bl); - decode(last_destroyed, bl); - } else { - last_created = last_snap; - last_destroyed = last_snap; - } - if (struct_v >= 5) - decode(snaprealm_v2_since, bl); - else - snaprealm_v2_since = CEPH_NOSNAP; - - DECODE_FINISH(bl); - } + void encode_server_state(bufferlist& bl) const override; + void decode_server_state(bufferlist::const_iterator& bl) override; // server bits void _prepare(const bufferlist &bl, uint64_t reqid, mds_rank_t bymds, bufferlist &out) override;