]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: use new insert template via print
authorPatrick Donnelly <pdonnell@redhat.com>
Tue, 16 Jan 2024 19:01:54 +0000 (14:01 -0500)
committerPatrick Donnelly <pdonnell@redhat.com>
Wed, 20 Mar 2024 14:56:51 +0000 (10:56 -0400)
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/mds/LogEvent.h
src/mds/MDSCacheObject.h
src/mds/Mutation.h
src/mds/SimpleLock.h
src/mds/events/EMetaBlob.h
src/mds/mdstypes.h

index 49955290fd6961fc8b15c47f15d18732c5ab1d1b..1e748d904fc884558e2a7026193154e6b6cd37a8 100644 (file)
@@ -128,9 +128,4 @@ private:
   LogSegment *_segment = nullptr;
 };
 
-inline std::ostream& operator<<(std::ostream& out, const LogEvent &le) {
-  le.print(out);
-  return out;
-}
-
 #endif
index 8710102b70d99268881b2af09061b8bbb0f39411..7da2a67c3a273400097a341b4ddb957c60964813 100644 (file)
@@ -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;
index 1a308c423f51b26c85995fdd64e1190932c9bffd..74444d548ff0c1590d9adec3f756f468c12722fa 100644 (file)
@@ -543,9 +543,4 @@ struct MDLockCache : public MutationImpl {
 typedef boost::intrusive_ptr<MutationImpl> MutationRef;
 typedef boost::intrusive_ptr<MDRequestImpl> MDRequestRef;
 
-inline std::ostream& operator<<(std::ostream &out, const MutationImpl &mut)
-{
-  mut.print(out);
-  return out;
-}
 #endif
index 2a7a5fc806e7476f294cf1b6fb1caa929e605ceb..33c091b6244e3eb281e640f540e312e9d8423efc 100644 (file)
@@ -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
index 6c995dddeb029ef81dbad0d551eb80590320e9b2..02607ce8ba137a6202344a4c31b3be82ed3c5367 100644 (file)
@@ -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
index 3381d44c95f150b7c87094e00581261ce7075c1b..a39ec5abbd5d051133d28204248d292de73b6ed9 100644 (file)
@@ -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<old_rstat_t*>& 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<dirfrag_load_vec_t*>& 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<DecayCounter, NUM> 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_rank_t, mds_rank_t> 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<MDSCacheObjectInfo*>& 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;