From d1b066cdbd1ec65b620996cb7f4da7006dfcb7d0 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Tue, 16 Jan 2024 14:01:54 -0500 Subject: [PATCH] mds: use new insert template via print Signed-off-by: Patrick Donnelly --- src/mds/LogEvent.h | 5 -- src/mds/MDSCacheObject.h | 5 -- src/mds/Mutation.h | 5 -- src/mds/SimpleLock.h | 5 -- src/mds/events/EMetaBlob.h | 5 -- src/mds/mdstypes.h | 125 +++++++++++++++++-------------------- 6 files changed, 57 insertions(+), 93 deletions(-) diff --git a/src/mds/LogEvent.h b/src/mds/LogEvent.h index 49955290fd696..1e748d904fc88 100644 --- a/src/mds/LogEvent.h +++ b/src/mds/LogEvent.h @@ -128,9 +128,4 @@ private: LogSegment *_segment = nullptr; }; -inline std::ostream& operator<<(std::ostream& out, const LogEvent &le) { - le.print(out); - return out; -} - #endif diff --git a/src/mds/MDSCacheObject.h b/src/mds/MDSCacheObject.h index 8710102b70d99..7da2a67c3a273 100644 --- a/src/mds/MDSCacheObject.h +++ b/src/mds/MDSCacheObject.h @@ -326,11 +326,6 @@ class MDSCacheObject { static uint64_t last_wait_seq; }; -inline std::ostream& operator<<(std::ostream& out, const MDSCacheObject& o) { - o.print(out); - return out; -} - inline std::ostream& operator<<(std::ostream& out, const mdsco_db_line_prefix& o) { o.object->print_db_line_prefix(out); return out; diff --git a/src/mds/Mutation.h b/src/mds/Mutation.h index 1a308c423f51b..74444d548ff0c 100644 --- a/src/mds/Mutation.h +++ b/src/mds/Mutation.h @@ -543,9 +543,4 @@ struct MDLockCache : public MutationImpl { typedef boost::intrusive_ptr MutationRef; typedef boost::intrusive_ptr MDRequestRef; -inline std::ostream& operator<<(std::ostream &out, const MutationImpl &mut) -{ - mut.print(out); - return out; -} #endif diff --git a/src/mds/SimpleLock.h b/src/mds/SimpleLock.h index 2a7a5fc806e74..33c091b6244e3 100644 --- a/src/mds/SimpleLock.h +++ b/src/mds/SimpleLock.h @@ -660,9 +660,4 @@ private: }; WRITE_CLASS_ENCODER(SimpleLock) -inline std::ostream& operator<<(std::ostream& out, const SimpleLock& l) -{ - l.print(out); - return out; -} #endif diff --git a/src/mds/events/EMetaBlob.h b/src/mds/events/EMetaBlob.h index 6c995dddeb029..02607ce8ba137 100644 --- a/src/mds/events/EMetaBlob.h +++ b/src/mds/events/EMetaBlob.h @@ -611,9 +611,4 @@ WRITE_CLASS_ENCODER(EMetaBlob::remotebit) WRITE_CLASS_ENCODER(EMetaBlob::nullbit) WRITE_CLASS_ENCODER_FEATURES(EMetaBlob::dirlump) -inline std::ostream& operator<<(std::ostream& out, const EMetaBlob& t) { - t.print(out); - return out; -} - #endif diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index 3381d44c95f15..a39ec5abbd5d0 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -85,12 +85,13 @@ public: return (rank == MDS_RANK_NONE); } + void print(std::ostream& out) const { + out << fscid << ":" << rank; + } + fs_cluster_id_t fscid = FS_CLUSTER_ID_NONE; mds_rank_t rank = MDS_RANK_NONE; }; -inline std::ostream& operator<<(std::ostream& out, const mds_role_t& role) { - return out << role.fscid << ":" << role.rank; -} // CAPS inline std::string gcap_string(int cap) @@ -277,15 +278,15 @@ struct old_rstat_t { void dump(ceph::Formatter *f) const; static void generate_test_instances(std::list& ls); + void print(std::ostream& out) const { + out << "old_rstat(first " << first << " " << rstat << " " << accounted_rstat << ")"; + } + snapid_t first; nest_info_t rstat, accounted_rstat; }; WRITE_CLASS_ENCODER(old_rstat_t) -inline std::ostream& operator<<(std::ostream& out, const old_rstat_t& o) { - return out << "old_rstat(first " << o.first << " " << o.rstat << " " << o.accounted_rstat << ")"; -} - class feature_bitset_t { public: typedef uint64_t block_type; @@ -351,11 +352,6 @@ private: }; WRITE_CLASS_ENCODER(feature_bitset_t) -inline std::ostream& operator<<(std::ostream& out, const feature_bitset_t& s) { - s.print(out); - return out; -} - struct metric_spec_t { metric_spec_t() {} metric_spec_t(const metric_spec_t& other) : @@ -394,11 +390,6 @@ struct metric_spec_t { }; WRITE_CLASS_ENCODER(metric_spec_t) -inline std::ostream& operator<<(std::ostream& out, const metric_spec_t& mst) { - mst.print(out); - return out; -} - /* * client_metadata_t */ @@ -480,6 +471,10 @@ struct dentry_key_t { dentry_key_t(snapid_t s, std::string_view n, __u32 h=0) : snapid(s), name(n), hash(h) {} + void print(std::ostream& out) const { + out << "(" << name << "," << snapid << ")"; + } + bool is_valid() { return name.length() || snapid; } // encode into something that can be decoded as a string. @@ -530,11 +525,6 @@ struct dentry_key_t { __u32 hash = 0; }; -inline std::ostream& operator<<(std::ostream& out, const dentry_key_t &k) -{ - return out << "(" << k.name << "," << k.snapid << ")"; -} - inline bool operator<(const dentry_key_t& k1, const dentry_key_t& k2) { /* @@ -556,6 +546,10 @@ struct string_snap_t { string_snap_t() {} string_snap_t(std::string_view n, snapid_t s) : name(n), snapid(s) {} + void print(std::ostream& out) const { + out << "(" << name << "," << snapid << ")"; + } + int compare(const string_snap_t& r) const { int ret = name.compare(r.name); if (ret) @@ -584,11 +578,6 @@ inline bool operator<(const string_snap_t& l, const string_snap_t& r) { return c < 0 || (c == 0 && l.snapid < r.snapid); } -inline std::ostream& operator<<(std::ostream& out, const string_snap_t &k) -{ - return out << "(" << k.name << "," << k.snapid << ")"; -} - /* * mds_table_pending_t * @@ -622,16 +611,15 @@ struct metareqid_t { decode(tid, p); } void dump(ceph::Formatter *f) const; + void print(std::ostream& out) const { + out << name << ":" << tid; + } entity_name_t name; uint64_t tid = 0; }; WRITE_CLASS_ENCODER(metareqid_t) -inline std::ostream& operator<<(std::ostream& out, const metareqid_t& r) { - return out << r.name << ":" << r.tid; -} - inline bool operator==(const metareqid_t& l, const metareqid_t& r) { return (l.name == r.name) && (l.tid == r.tid); } @@ -761,6 +749,13 @@ struct dirfrag_t { dirfrag_t() {} dirfrag_t(inodeno_t i, frag_t f) : ino(i), frag(f) { } + void print(std::ostream& out) const { + out << ino; + if (!frag.is_root()) { + out << "." << frag; + } + } + void encode(ceph::buffer::list& bl) const { using ceph::encode; encode(ino, bl); @@ -777,11 +772,6 @@ struct dirfrag_t { }; WRITE_CLASS_ENCODER(dirfrag_t) -inline std::ostream& operator<<(std::ostream& out, const dirfrag_t &df) { - out << df.ino; - if (!df.frag.is_root()) out << "." << df.frag; - return out; -} inline bool operator<(dirfrag_t l, dirfrag_t r) { if (l.ino < r.ino) return true; if (l.ino == r.ino && l.frag < r.frag) return true; @@ -875,6 +865,18 @@ public: } void dump(ceph::Formatter *f) const; void dump(ceph::Formatter *f, const DecayRate& rate) const; + void print(std::ostream& out) const { + CachedStackStringStream css; + *css << std::setprecision(1) << std::fixed + << "[pop" + " IRD:" << vec[0] + << " IWR:" << vec[1] + << " RDR:" << vec[2] + << " FET:" << vec[3] + << " STR:" << vec[4] + << " *LOAD:" << meta_load() << "]"; + out << css->strv(); + } static void generate_test_instances(std::list& ls); const DecayCounter &get(int t) const { @@ -916,7 +918,6 @@ public: } private: - friend inline std::ostream& operator<<(std::ostream& out, const dirfrag_load_vec_t& dl); std::array vec; }; @@ -927,20 +928,6 @@ inline void decode(dirfrag_load_vec_t& c, ceph::buffer::list::const_iterator &p) c.decode(p); } -inline std::ostream& operator<<(std::ostream& out, const dirfrag_load_vec_t& dl) -{ - CachedStackStringStream css; - *css << std::setprecision(1) << std::fixed - << "[pop" - " IRD:" << dl.vec[0] - << " IWR:" << dl.vec[1] - << " RDR:" << dl.vec[2] - << " FET:" << dl.vec[3] - << " STR:" << dl.vec[4] - << " *LOAD:" << dl.meta_load() << "]"; - return out << css->strv(); -} - struct mds_load_t { using clock = dirfrag_load_vec_t::clock; using time = dirfrag_load_vec_t::time; @@ -951,6 +938,15 @@ struct mds_load_t { mds_load_t() : auth(DecayRate()), all(DecayRate()) {} mds_load_t(const DecayRate &rate) : auth(rate), all(rate) {} + void print(std::ostream& out) const { + out << "mdsload<" << auth << "/" << all + << ", req " << req_rate + << ", hr " << cache_hit_rate + << ", qlen " << queue_len + << ", cpu " << cpu_load_avg + << ">"; + } + double req_rate = 0.0; double cache_hit_rate = 0.0; double queue_len = 0.0; @@ -970,16 +966,6 @@ inline void decode(mds_load_t &c, ceph::buffer::list::const_iterator &p) { c.decode(p); } -inline std::ostream& operator<<(std::ostream& out, const mds_load_t& load) -{ - return out << "mdsload<" << load.auth << "/" << load.all - << ", req " << load.req_rate - << ", hr " << load.cache_hit_rate - << ", qlen " << load.queue_len - << ", cpu " << load.cpu_load_avg - << ">"; -} - // ================================================================ typedef std::pair mds_authority_t; @@ -997,6 +983,16 @@ public: void encode(ceph::buffer::list& bl) const; void decode(ceph::buffer::list::const_iterator& bl); void dump(ceph::Formatter *f) const; + void print(std::ostream& out) const { + if (ino) { + out << ino << "." << snapid; + } else if (dname.length()) { + out << dirfrag << "/" << dname + << " snap " << snapid; + } else { + out << dirfrag; + } + } static void generate_test_instances(std::list& ls); inodeno_t ino = 0; @@ -1005,13 +1001,6 @@ public: snapid_t snapid; }; -inline std::ostream& operator<<(std::ostream& out, const MDSCacheObjectInfo &info) { - if (info.ino) return out << info.ino << "." << info.snapid; - if (info.dname.length()) return out << info.dirfrag << "/" << info.dname - << " snap " << info.snapid; - return out << info.dirfrag; -} - inline bool operator==(const MDSCacheObjectInfo& l, const MDSCacheObjectInfo& r) { if (l.ino || r.ino) return l.ino == r.ino && l.snapid == r.snapid; -- 2.39.5