From fc070255e8c87002dadd5b193d2277d8d55c75b3 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Thu, 18 May 2017 23:56:56 -0700 Subject: [PATCH] osdmonitor: use a new get_full_osd_counts to generate health without osdstat Signed-off-by: Greg Farnum --- src/mon/OSDMonitor.cc | 10 +++++----- src/osd/OSDMap.cc | 18 ++++++++++++++++++ src/osd/OSDMap.h | 4 ++++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index b74853f1a27a7..fc951c6bdb14a 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -3749,8 +3749,8 @@ void OSDMonitor::get_health(list >& summary, summary.push_back(make_pair(HEALTH_ERR, ss.str())); } - map full, backfillfull, nearfull; - osdmap.get_full_osd_util(mon->pgservice->get_osd_stat(), &full, &backfillfull, &nearfull); + set full, backfillfull, nearfull; + osdmap.get_full_osd_counts(&full, &backfillfull, &nearfull); if (full.size()) { ostringstream ss; ss << full.size() << " full osd(s)"; @@ -3769,17 +3769,17 @@ void OSDMonitor::get_health(list >& summary, if (detail) { for (auto& i: full) { ostringstream ss; - ss << "osd." << i.first << " is full at " << roundf(i.second * 100) << "%"; + ss << "osd." << i << " is full"; detail->push_back(make_pair(HEALTH_ERR, ss.str())); } for (auto& i: backfillfull) { ostringstream ss; - ss << "osd." << i.first << " is backfill full at " << roundf(i.second * 100) << "%"; + ss << "osd." << i << " is backfill full"; detail->push_back(make_pair(HEALTH_WARN, ss.str())); } for (auto& i: nearfull) { ostringstream ss; - ss << "osd." << i.first << " is near full at " << roundf(i.second * 100) << "%"; + ss << "osd." << i << " is near full"; detail->push_back(make_pair(HEALTH_WARN, ss.str())); } } diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 0f1c6f5df87c2..bf5f07e7d8d67 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -1148,6 +1148,24 @@ void OSDMap::get_full_osd_util( } } +void OSDMap::get_full_osd_counts(set *full, set *backfill, + set *nearfull) const +{ + full->clear(); + backfill->clear(); + nearfull->clear(); + for (int i = 0; i < max_osd; ++i) { + if (exists(i) && is_up(i) && is_in(i)) { + if (osd_state[i] & CEPH_OSD_FULL) + full->emplace(i); + else if (osd_state[i] & CEPH_OSD_BACKFILLFULL) + backfill->emplace(i); + else if (osd_state[i] & CEPH_OSD_NEARFULL) + nearfull->emplace(i); + } + } +} + void OSDMap::get_all_osds(set& ls) const { for (int i=0; i *backfill, map *nearfull) const; + void get_full_osd_counts(set *full, set *backfill, + set *nearfull) const; + + /***** cluster state *****/ /* osds */ int get_max_osd() const { return max_osd; } -- 2.39.5