]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds/flock: un-inline methods to reduce header dependencies
authorMax Kellermann <max.kellermann@ionos.com>
Fri, 25 Oct 2024 13:45:14 +0000 (15:45 +0200)
committerMax Kellermann <max.kellermann@ionos.com>
Thu, 17 Apr 2025 16:00:16 +0000 (18:00 +0200)
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
src/mds/flock.cc
src/mds/flock.h

index 929729a72eef285a865277240017fd7b1281819e..647d0a94d07a4c4d52b7a3df7eb42cc0718760d8 100644 (file)
@@ -5,6 +5,8 @@
 #include "common/debug.h"
 #include "mdstypes.h"
 
+#include <iostream>
+
 #define dout_subsys ceph_subsys_mds
 
 using std::list;
@@ -13,6 +15,14 @@ using std::multimap;
 
 static multimap<ceph_filelock, ceph_lock_state_t*> global_waiting_locks;
 
+std::ostream& operator<<(std::ostream& out, const ceph_filelock& l) {
+  out << "start: " << l.start << ", length: " << l.length
+      << ", client: " << l.client << ", owner: " << l.owner
+      << ", pid: " << l.pid << ", type: " << (int)l.type
+      << std::endl;
+  return out;
+}
+
 static void remove_global_waiting(ceph_filelock &fl, ceph_lock_state_t *lock_state)
 {
   for (auto p = global_waiting_locks.find(fl);
@@ -36,6 +46,18 @@ ceph_lock_state_t::~ceph_lock_state_t()
   }
 }
 
+void ceph_lock_state_t::encode(ceph::bufferlist& bl) const {
+  using ceph::encode;
+  encode(held_locks, bl);
+  encode(client_held_lock_counts, bl);
+}
+
+void ceph_lock_state_t::decode(ceph::bufferlist::const_iterator& bl) {
+  using ceph::decode;
+  decode(held_locks, bl);
+  decode(client_held_lock_counts, bl);
+}
+
 void ceph_lock_state_t::dump(ceph::Formatter *f) const {
   f->dump_int("type", type);
   f->dump_int("held_locks", held_locks.size());
@@ -641,3 +663,21 @@ ceph_lock_state_t::contains_exclusive_lock(list<multimap<uint64_t,
   }
   return NULL;
 }
+
+std::ostream& operator<<(std::ostream &out, const ceph_lock_state_t &l) {
+  out << "ceph_lock_state_t. held_locks.size()=" << l.held_locks.size()
+      << ", waiting_locks.size()=" << l.waiting_locks.size()
+      << ", client_held_lock_counts -- " << l.client_held_lock_counts
+      << "\n client_waiting_lock_counts -- " << l.client_waiting_lock_counts
+      << "\n held_locks -- ";
+    for (auto iter = l.held_locks.begin();
+         iter != l.held_locks.end();
+         ++iter)
+      out << iter->second;
+    out << "\n waiting_locks -- ";
+    for (auto iter =l.waiting_locks.begin();
+         iter != l.waiting_locks.end();
+         ++iter)
+      out << iter->second << "\n";
+  return out;
+}
index 32f26153d5ffacfebf3b9bceb06c22228bf8a542..9e6f67976f0c2f36b1a17f3be85c699061ca5e28 100644 (file)
@@ -7,17 +7,11 @@
 #include "include/types.h" // for client_t
 
 #include <cstdint>
+#include <iosfwd>
 #include <list>
 #include <map>
-#include <ostream>
 
-inline std::ostream& operator<<(std::ostream& out, const ceph_filelock& l) {
-  out << "start: " << l.start << ", length: " << l.length
-      << ", client: " << l.client << ", owner: " << l.owner
-      << ", pid: " << l.pid << ", type: " << (int)l.type
-      << std::endl;
-  return out;
-}
+std::ostream& operator<<(std::ostream& out, const ceph_filelock& l);
 
 inline bool ceph_filelock_owner_equal(const ceph_filelock& l, const ceph_filelock& r)
 {
@@ -126,16 +120,8 @@ public:
 
   bool remove_all_from(client_t client);
 
-  void encode(ceph::bufferlist& bl) const {
-    using ceph::encode;
-    encode(held_locks, bl);
-    encode(client_held_lock_counts, bl);
-  }
-  void decode(ceph::bufferlist::const_iterator& bl) {
-    using ceph::decode;
-    decode(held_locks, bl);
-    decode(client_held_lock_counts, bl);
-  }
+  void encode(ceph::bufferlist& bl) const;
+  void decode(ceph::bufferlist::const_iterator& bl);
   void dump(ceph::Formatter *f) const;
   static void generate_test_instances(std::list<ceph_lock_state_t*>& ls);
   bool empty() const {
@@ -274,22 +260,6 @@ private:
 };
 WRITE_CLASS_ENCODER(ceph_lock_state_t)
 
-inline std::ostream& operator<<(std::ostream &out, const ceph_lock_state_t &l) {
-  out << "ceph_lock_state_t. held_locks.size()=" << l.held_locks.size()
-      << ", waiting_locks.size()=" << l.waiting_locks.size()
-      << ", client_held_lock_counts -- " << l.client_held_lock_counts
-      << "\n client_waiting_lock_counts -- " << l.client_waiting_lock_counts
-      << "\n held_locks -- ";
-    for (auto iter = l.held_locks.begin();
-         iter != l.held_locks.end();
-         ++iter)
-      out << iter->second;
-    out << "\n waiting_locks -- ";
-    for (auto iter =l.waiting_locks.begin();
-         iter != l.waiting_locks.end();
-         ++iter)
-      out << iter->second << "\n";
-  return out;
-}
+std::ostream& operator<<(std::ostream &out, const ceph_lock_state_t &l);
 
 #endif