From: Sage Weil Date: Fri, 24 Feb 2017 20:51:08 +0000 (-0500) Subject: mon: move dump_stuck_pg_stats from PGMonitor -> PGMap X-Git-Tag: v12.0.2~252^2~66 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cbd09fc135aeff78470e8eb3c25237a8a01bce45;p=ceph.git mon: move dump_stuck_pg_stats from PGMonitor -> PGMap Signed-off-by: Sage Weil --- diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index c23f34142882..e8a33c810682 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -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& args) const +{ + int stuck_types = 0; + + for (vector::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"); diff --git a/src/mon/PGMap.h b/src/mon/PGMap.h index a86db113ecb6..adc6d7533681 100644 --- a/src/mon/PGMap.h +++ b/src/mon/PGMap.h @@ -299,6 +299,10 @@ public: bool get_stuck_counts(const utime_t cutoff, map& 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& args) const; void dump(ostream& ss) const; void dump_basic(ostream& ss) const; diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index 10fa3af8114f..eb096996f4a8 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -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 >& summa } } -int PGMonitor::dump_stuck_pg_stats(stringstream &ds, - Formatter *f, - int threshold, - vector& args) const -{ - int stuck_types = 0; - - for (vector::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; diff --git a/src/mon/PGMonitor.h b/src/mon/PGMonitor.h index 5cdaaf2c21fd..32a5a647008a 100644 --- a/src/mon/PGMonitor.h +++ b/src/mon/PGMonitor.h @@ -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& args) const; - public: PGMonitor(Monitor *mn, Paxos *p, const string& service_name) : PaxosService(mn, p, service_name),