]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: move dump_stuck_pg_stats from PGMonitor -> PGMap
authorSage Weil <sage@redhat.com>
Fri, 24 Feb 2017 20:51:08 +0000 (15:51 -0500)
committerSage Weil <sage@redhat.com>
Wed, 29 Mar 2017 15:38:32 +0000 (11:38 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/PGMap.cc
src/mon/PGMap.h
src/mon/PGMonitor.cc
src/mon/PGMonitor.h

index c23f34142882d07b5b36a531f43da8ae8234e9f8..e8a33c8106827365e9fb27b33fb37683a3d093d8 100644 (file)
@@ -1112,6 +1112,44 @@ void PGMap::dump_stuck_plain(ostream& ss, int types, utime_t cutoff) const
     dump_pg_stats_plain(ss, stuck_pg_stats, true);
 }
 
+int PGMap::dump_stuck_pg_stats(
+  stringstream &ds,
+  Formatter *f,
+  int threshold,
+  vector<string>& args) const
+{
+  int stuck_types = 0;
+
+  for (vector<string>::iterator i = args.begin(); i != args.end(); ++i) {
+    if (*i == "inactive")
+      stuck_types |= PGMap::STUCK_INACTIVE;
+    else if (*i == "unclean")
+      stuck_types |= PGMap::STUCK_UNCLEAN;
+    else if (*i == "undersized")
+      stuck_types |= PGMap::STUCK_UNDERSIZED;
+    else if (*i == "degraded")
+      stuck_types |= PGMap::STUCK_DEGRADED;
+    else if (*i == "stale")
+      stuck_types |= PGMap::STUCK_STALE;
+    else {
+      ds << "Unknown type: " << *i << std::endl;
+      return -EINVAL;
+    }
+  }
+
+  utime_t now(ceph_clock_now());
+  utime_t cutoff = now - utime_t(threshold, 0);
+
+  if (!f) {
+    dump_stuck_plain(ds, stuck_types, cutoff);
+  } else {
+    dump_stuck(f, stuck_types, cutoff);
+    f->flush(ds);
+  }
+
+  return 0;
+}
+
 void PGMap::dump_osd_perf_stats(Formatter *f) const
 {
   f->open_array_section("osd_perf_infos");
index a86db113ecb677a5e1961a0126c0b14fc9dfe0c7..adc6d75336810b523af32368c18aa502387901a7 100644 (file)
@@ -299,6 +299,10 @@ public:
   bool get_stuck_counts(const utime_t cutoff, map<string, int>& note) const;
   void dump_stuck(Formatter *f, int types, utime_t cutoff) const;
   void dump_stuck_plain(ostream& ss, int types, utime_t cutoff) const;
+  int dump_stuck_pg_stats(stringstream &ds,
+                          Formatter *f,
+                          int threshold,
+                          vector<string>& args) const;
 
   void dump(ostream& ss) const;
   void dump_basic(ostream& ss) const;
index 10fa3af8114f779e0b7fedeb94dca9ffc7284b25..eb096996f4a875d9de1c285b352b433e86df1e5b 100644 (file)
@@ -1152,7 +1152,7 @@ bool PGMonitor::preprocess_command(MonOpRequestRef op)
     cmd_getval(g_ceph_context, cmdmap, "threshold", threshold,
                int64_t(g_conf->mon_pg_stuck_threshold));
 
-    r = dump_stuck_pg_stats(ds, f.get(), (int)threshold, stuckop_vec);
+    r = pg_map.dump_stuck_pg_stats(ds, f.get(), (int)threshold, stuckop_vec);
     if (r < 0)
       ss << "failed";  
     else 
@@ -1882,43 +1882,6 @@ void PGMonitor::check_full_osd_health(list<pair<health_status_t,string> >& summa
   }
 }
 
-int PGMonitor::dump_stuck_pg_stats(stringstream &ds,
-                                   Formatter *f,
-                                   int threshold,
-                                   vector<string>& args) const
-{
-  int stuck_types = 0;
-
-  for (vector<string>::iterator i = args.begin(); i != args.end(); ++i) {
-    if (*i == "inactive")
-      stuck_types |= PGMap::STUCK_INACTIVE;
-    else if (*i == "unclean")
-      stuck_types |= PGMap::STUCK_UNCLEAN;
-    else if (*i == "undersized")
-      stuck_types |= PGMap::STUCK_UNDERSIZED;
-    else if (*i == "degraded")
-      stuck_types |= PGMap::STUCK_DEGRADED;
-    else if (*i == "stale")
-      stuck_types |= PGMap::STUCK_STALE;
-    else {
-      ds << "Unknown type: " << *i << std::endl;
-      return -EINVAL;
-    }
-  }
-
-  utime_t now(ceph_clock_now());
-  utime_t cutoff = now - utime_t(threshold, 0);
-
-  if (!f) {
-    pg_map.dump_stuck_plain(ds, stuck_types, cutoff);
-  } else {
-    pg_map.dump_stuck(f, stuck_types, cutoff);
-    f->flush(ds);
-  }
-
-  return 0;
-}
-
 void PGMonitor::check_subs()
 {
   dout(10) << __func__ << dendl;
index 5cdaaf2c21fdf050b0c2f7f0a1116627505567c7..32a5a647008acdc627624a60deb404ea388a44a0 100644 (file)
@@ -91,15 +91,6 @@ private:
 
   epoch_t send_pg_creates(int osd, Connection *con, epoch_t next);
 
-  /**
-   * Dump stats from pgs stuck in specified states.
-   *
-   * @return 0 on success, negative error code on failure
-   */
-  int dump_stuck_pg_stats(stringstream &ds, Formatter *f,
-                         int threshold,
-                         vector<string>& args) const;
-
 public:
   PGMonitor(Monitor *mn, Paxos *p, const string& service_name)
     : PaxosService(mn, p, service_name),