]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: send health-checks to mgr
authorKefu Chai <kchai@redhat.com>
Mon, 23 Oct 2017 04:29:31 +0000 (12:29 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 31 Jan 2018 16:41:43 +0000 (00:41 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit f4b74125e44fe78154fb377fa06fc08b3325859d)

Conflicts:
src/osd/OSD.cc
src/osd/OSD.h: only the changes related to reporting
pending-creating-pgs are cherry-picked. because we want to minimize the
impact to luminous. and to remove the slow ops from cluster log is not
in the scope of this backport. also, with_unique_lock was introduced
after luminous is branched, so use the plain lock_guard<> instead.
src/osd/OSDHealthMetric.h: because denc.h does not support
denc of enum types in luminous. so we need to case from/to osd_metric
when necessary.

src/osd/OSD.cc
src/osd/OSD.h
src/osd/OSDHealthMetric.h [new file with mode: 0644]

index 8628d0c547203397df4a0a331baa0501adbfb28e..76aa56d058c51cbc3a50de4fa0882633166efb13 100644 (file)
@@ -5326,7 +5326,7 @@ void OSD::tick_without_osd_lock()
     }
   }
 
-  check_ops_in_flight();
+  mgrc.update_osd_health(get_health_metrics());
   service.kick_recovery_queue();
   tick_timer_without_osd_lock.add_event_after(OSD_TICK_INTERVAL, new C_Tick_WithoutOSDLock(this));
 }
@@ -7539,6 +7539,20 @@ void OSD::sched_scrub()
 
 
 
+vector<OSDHealthMetric> OSD::get_health_metrics()
+{
+  vector<OSDHealthMetric> metrics;
+  lock_guard<mutex> pending_creates_locker{pending_creates_lock};
+  auto n_primaries = pending_creates_from_mon;
+  for (const auto& create : pending_creates_from_osd) {
+    if (create.second) {
+      n_primaries++;
+    }
+  }
+  metrics.emplace_back(osd_metric::PENDING_CREATING_PGS, n_primaries);
+  return metrics;
+}
+
 // =====================================================
 // MAP
 
index 235dfaa81631957169003eb0ca5a072aa7fcc614..7781dfc1453d71142da0fbb95aa7dcc614a41983 100644 (file)
@@ -2299,6 +2299,10 @@ protected:
     }
   } remove_wq;
 
+  // -- status reporting --
+  MPGStats *collect_pg_stats();
+  std::vector<OSDHealthMetric> get_health_metrics();
+
 private:
   bool ms_can_fast_dispatch_any() const override { return true; }
   bool ms_can_fast_dispatch(const Message *m) const override {
diff --git a/src/osd/OSDHealthMetric.h b/src/osd/OSDHealthMetric.h
new file mode 100644 (file)
index 0000000..4ac4728
--- /dev/null
@@ -0,0 +1,61 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#pragma once
+
+#include <cstdint>
+#include "include/denc.h"
+
+enum class osd_metric : uint8_t {
+  SLOW_OPS,
+  PENDING_CREATING_PGS,
+  NONE,
+};
+
+union osd_metric_t {
+  struct {
+    uint32_t n1;
+    uint32_t n2;
+  };
+  uint64_t n;
+  osd_metric_t(uint32_t x, uint32_t y)
+    : n1(x), n2(y)
+  {}
+  osd_metric_t(uint64_t x = 0)
+    : n(x)
+  {}
+};
+
+class OSDHealthMetric
+{
+public:
+  OSDHealthMetric() = default;
+  OSDHealthMetric(osd_metric type_, uint64_t n)
+    : type((uint8_t)type_), value(n)
+  {}
+  OSDHealthMetric(osd_metric type_, uint32_t n1, uint32_t n2)
+    : type((uint8_t)type_), value(n1, n2)
+  {}
+  osd_metric get_type() const {
+    return (osd_metric)type;
+  }
+  uint64_t get_n() const {
+    return value.n;
+  }
+  uint32_t get_n1() const {
+    return value.n1;
+  }
+  uint32_t get_n2() const {
+    return value.n2;
+  }
+  DENC(OSDHealthMetric, v, p) {
+    DENC_START(1, 1, p);
+    denc(v.type, p);
+    denc(v.value.n, p);
+    DENC_FINISH(p);
+  }
+private:
+  uint8_t type = (uint8_t)osd_metric::NONE;
+  osd_metric_t value;
+};
+WRITE_CLASS_DENC(OSDHealthMetric)