From b10cccdedade21055defb4d7a7aa6d5afd001862 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 25 Oct 2024 15:45:14 +0200 Subject: [PATCH] mds/flock: un-inline methods to reduce header dependencies Signed-off-by: Max Kellermann --- src/mds/flock.cc | 40 ++++++++++++++++++++++++++++++++++++++++ src/mds/flock.h | 40 +++++----------------------------------- 2 files changed, 45 insertions(+), 35 deletions(-) diff --git a/src/mds/flock.cc b/src/mds/flock.cc index 929729a72eef2..647d0a94d07a4 100644 --- a/src/mds/flock.cc +++ b/src/mds/flock.cc @@ -5,6 +5,8 @@ #include "common/debug.h" #include "mdstypes.h" +#include + #define dout_subsys ceph_subsys_mds using std::list; @@ -13,6 +15,14 @@ using std::multimap; static multimap 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(listsecond; + out << "\n waiting_locks -- "; + for (auto iter =l.waiting_locks.begin(); + iter != l.waiting_locks.end(); + ++iter) + out << iter->second << "\n"; + return out; +} diff --git a/src/mds/flock.h b/src/mds/flock.h index 32f26153d5ffa..9e6f67976f0c2 100644 --- a/src/mds/flock.h +++ b/src/mds/flock.h @@ -7,17 +7,11 @@ #include "include/types.h" // for client_t #include +#include #include #include -#include -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& 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 -- 2.39.5