From 342d1210de857dcc2460917d5710caddfc13df5d Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Wed, 19 Jul 2023 11:52:29 -0400 Subject: [PATCH] mds: mark print methods const Signed-off-by: Patrick Donnelly --- src/mds/BatchOp.h | 2 +- src/mds/CDentry.cc | 4 ++-- src/mds/CDentry.h | 4 ++-- src/mds/CDir.cc | 4 ++-- src/mds/CDir.h | 4 ++-- src/mds/CInode.cc | 4 ++-- src/mds/CInode.h | 4 ++-- src/mds/FSMapUser.cc | 2 +- src/mds/FSMapUser.h | 4 ++-- src/mds/MDSCacheObject.h | 10 +++------- src/mds/Server.cc | 2 +- 11 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/mds/BatchOp.h b/src/mds/BatchOp.h index bc4e21bcea959..5277c3d69f8d7 100644 --- a/src/mds/BatchOp.h +++ b/src/mds/BatchOp.h @@ -27,7 +27,7 @@ public: virtual void add_request(const ceph::ref_t& mdr) = 0; virtual ceph::ref_t find_new_head() = 0; - virtual void print(std::ostream&) = 0; + virtual void print(std::ostream&) const = 0; void forward(mds_rank_t target); void respond(int r); diff --git a/src/mds/CDentry.cc b/src/mds/CDentry.cc index 6f20f53d144da..0b83d34afcd10 100644 --- a/src/mds/CDentry.cc +++ b/src/mds/CDentry.cc @@ -33,7 +33,7 @@ using namespace std; -ostream& CDentry::print_db_line_prefix(ostream& out) +ostream& CDentry::print_db_line_prefix(ostream& out) const { return out << ceph_clock_now() << " mds." << dir->mdcache->mds->get_nodeid() << ".cache.den(" << dir->ino() << " " << name << ") "; } @@ -137,7 +137,7 @@ bool operator<(const CDentry& l, const CDentry& r) } -void CDentry::print(ostream& out) +void CDentry::print(ostream& out) const { out << *this; } diff --git a/src/mds/CDentry.h b/src/mds/CDentry.h index 0d468c6f07428..7a499399673fc 100644 --- a/src/mds/CDentry.h +++ b/src/mds/CDentry.h @@ -357,8 +357,8 @@ public: void remove_client_lease(ClientLease *r, Locker *locker); // returns remaining mask (if any), and kicks locker eval_gathers void remove_client_leases(Locker *locker); - std::ostream& print_db_line_prefix(std::ostream& out) override; - void print(std::ostream& out) override; + std::ostream& print_db_line_prefix(std::ostream& out) const override; + void print(std::ostream& out) const override; void dump(ceph::Formatter *f) const; static void encode_remote(inodeno_t& ino, unsigned char d_type, diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index ca0c2ec17f035..0484c38cc3030 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -180,7 +180,7 @@ ostream& operator<<(ostream& out, const CDir& dir) } -void CDir::print(ostream& out) +void CDir::print(ostream& out) const { out << *this; } @@ -188,7 +188,7 @@ void CDir::print(ostream& out) -ostream& CDir::print_db_line_prefix(ostream& out) +ostream& CDir::print_db_line_prefix(ostream& out) const { return out << ceph_clock_now() << " mds." << mdcache->mds->get_nodeid() << ".cache.dir(" << this->dirfrag() << ") "; } diff --git a/src/mds/CDir.h b/src/mds/CDir.h index 58507db970b4b..7cc4dc7ffcf83 100644 --- a/src/mds/CDir.h +++ b/src/mds/CDir.h @@ -611,8 +611,8 @@ public: } void enable_frozen_inode(); - std::ostream& print_db_line_prefix(std::ostream& out) override; - void print(std::ostream& out) override; + std::ostream& print_db_line_prefix(std::ostream& out) const override; + void print(std::ostream& out) const override; void dump(ceph::Formatter *f, int flags = DUMP_DEFAULT) const; void dump_load(ceph::Formatter *f); diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index 839d5fb656685..56f5c3e0dda6c 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -131,7 +131,7 @@ std::string_view CInode::pin_name(int p) const } //int cinode_pins[CINODE_NUM_PINS]; // counts -ostream& CInode::print_db_line_prefix(ostream& out) +ostream& CInode::print_db_line_prefix(ostream& out) const { return out << ceph_clock_now() << " mds." << mdcache->mds->get_nodeid() << ".cache.ino(" << ino() << ") "; } @@ -338,7 +338,7 @@ CInode::CInode(MDCache *c, bool auth, snapid_t f, snapid_t l) : state_set(STATE_AUTH); } -void CInode::print(ostream& out) +void CInode::print(ostream& out) const { out << *this; } diff --git a/src/mds/CInode.h b/src/mds/CInode.h index 2f7d6d242b896..5c7e1ab2e3238 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -423,7 +423,7 @@ class CInode : public MDSCacheObject, public InodeStoreBase, public Counter by_rank; std::map by_state; diff --git a/src/mds/FSMapUser.h b/src/mds/FSMapUser.h index a0be8e714aff7..96ac26d6da947 100644 --- a/src/mds/FSMapUser.h +++ b/src/mds/FSMapUser.h @@ -46,7 +46,7 @@ public: void decode(ceph::buffer::list::const_iterator& bl); void print(std::ostream& out) const; - void print_summary(ceph::Formatter *f, std::ostream *out); + void print_summary(ceph::Formatter *f, std::ostream *out) const; static void generate_test_instances(std::list& ls); @@ -57,7 +57,7 @@ public: WRITE_CLASS_ENCODER_FEATURES(FSMapUser::fs_info_t) WRITE_CLASS_ENCODER_FEATURES(FSMapUser) -inline std::ostream& operator<<(std::ostream& out, FSMapUser& m) { +inline std::ostream& operator<<(std::ostream& out, const FSMapUser& m) { m.print_summary(NULL, &out); return out; } diff --git a/src/mds/MDSCacheObject.h b/src/mds/MDSCacheObject.h index 53d33460bc6f9..8710102b70d99 100644 --- a/src/mds/MDSCacheObject.h +++ b/src/mds/MDSCacheObject.h @@ -98,8 +98,8 @@ class MDSCacheObject { std::string_view generic_pin_name(int p) const; // printing - virtual void print(std::ostream& out) = 0; - virtual std::ostream& print_db_line_prefix(std::ostream& out) { + virtual void print(std::ostream& out) const = 0; + virtual std::ostream& print_db_line_prefix(std::ostream& out) const { return out << "mdscacheobject(" << this << ") "; } @@ -326,11 +326,7 @@ class MDSCacheObject { static uint64_t last_wait_seq; }; -std::ostream& operator<<(std::ostream& out, const mdsco_db_line_prefix& o); -// printer -std::ostream& operator<<(std::ostream& out, const MDSCacheObject &o); - -inline std::ostream& operator<<(std::ostream& out, MDSCacheObject &o) { +inline std::ostream& operator<<(std::ostream& out, const MDSCacheObject& o) { o.print(out); return out; } diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 91dd0a3bd7d62..7ed27c14b10d3 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -138,7 +138,7 @@ public: batch_reqs.clear(); server->reply_client_request(mdr, make_message(*mdr->client_request, r)); } - void print(std::ostream& o) { + void print(std::ostream& o) const override { o << "[batch front=" << *mdr << "]"; } }; -- 2.39.5