]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds/SnapServer: un-inline methods to reduce header dependencies
authorMax Kellermann <max.kellermann@ionos.com>
Tue, 19 Aug 2025 14:25:51 +0000 (16:25 +0200)
committerMax Kellermann <max.kellermann@ionos.com>
Fri, 5 Sep 2025 11:26:01 +0000 (13:26 +0200)
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
src/mds/SnapServer.cc
src/mds/SnapServer.h

index 3d35900faeb685583b61349de5e3b2faf968f6b7..275fc1e069cb7bf140d29871706b378363ffa82a 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "SnapServer.h"
 #include "MDSRank.h"
+#include "snap.h"
 #include "osd/OSDMap.h"
 #include "osdc/Objecter.h"
 
 
 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<version_t, snapid_t> 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<MRemoveSnaps> &m)
 {
   dout(10) << __func__ << " " << *m << dendl;
index 67f4be7842cc2cdada9215808095edeb9519fe4a..2ec668ca481a5512aa311926d2a95294f610a3fe 100644 (file)
 #include <set>
 
 #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<MRemoveSnaps> &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<snapid_t, SnapInfo>& _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<version_t, snapid_t> 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;