From ff1b132f4dbe1915ce1980873596a0cb4155d23b Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Fri, 17 Mar 2017 15:42:38 -0700 Subject: [PATCH] mon: OSDMonitor starting to abstract PGMap via PGService We added an unfortunate get_pg_map() function but it's still easy to find and puts off some of the logic work. We'll get to it soon. Signed-off-by: Greg Farnum --- src/mon/OSDMonitor.cc | 28 +++++++++++++++------------- src/mon/PGStatService.h | 16 ++++++++++++++++ 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 1c85408ea12..a24ad8d58a6 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -892,16 +892,17 @@ void OSDMonitor::create_pending() } if (osdmap.require_osd_release < CEPH_RELEASE_LUMINOUS) { // transition full ratios from PGMap to OSDMap (on upgrade) - PGMap *pg_map = &mon->pgmon()->pg_map; - if (osdmap.full_ratio != pg_map->full_ratio) { + float full_ratio = mon->pgservice.get_full_ratio(); + float nearfull_ratio = mon->pgservice.get_nearfull_ratio(); + if (osdmap.full_ratio != full_ratio) { dout(10) << __func__ << " full_ratio " << osdmap.full_ratio - << " -> " << pg_map->full_ratio << " (from pgmap)" << dendl; - pending_inc.new_full_ratio = pg_map->full_ratio; + << " -> " << full_ratio << " (from pgmap)" << dendl; + pending_inc.new_full_ratio = full_ratio; } - if (osdmap.nearfull_ratio != pg_map->nearfull_ratio) { + if (osdmap.nearfull_ratio != nearfull_ratio) { dout(10) << __func__ << " nearfull_ratio " << osdmap.nearfull_ratio - << " -> " << pg_map->nearfull_ratio << " (from pgmap)" << dendl; - pending_inc.new_nearfull_ratio = pg_map->nearfull_ratio; + << " -> " << nearfull_ratio << " (from pgmap)" << dendl; + pending_inc.new_nearfull_ratio = nearfull_ratio; } } else { // safety check (this shouldn't really happen) @@ -1450,6 +1451,7 @@ version_t OSDMonitor::get_trim_to() if (mon->monmap->get_required_features().contains_all( ceph::features::mon::FEATURE_LUMINOUS)) { { + // TODO: Get this hidden in PGStatService std::lock_guard l(creating_pgs_lock); if (!creating_pgs.pgs.empty()) { return 0; @@ -1457,12 +1459,12 @@ version_t OSDMonitor::get_trim_to() } floor = get_min_last_epoch_clean(); } else { - if (!mon->pgmon()->is_readable()) + if (!mon->pgservice.is_readable()) return 0; - if (mon->pgmon()->pg_map.creating_pgs.empty()) { + if (mon->pgservice.creating_pgs.empty()) { return 0; } - floor = mon->pgmon()->pg_map.get_min_last_epoch_clean(); + floor = mon->pgservice.get_min_last_epoch_clean(); } { dout(10) << " min_last_epoch_clean " << floor << dendl; @@ -3417,9 +3419,9 @@ void OSDMonitor::tick() // if map full setting has changed, get that info out there! if (osdmap.require_osd_release < CEPH_RELEASE_LUMINOUS && - mon->pgmon()->is_readable()) { + mon->pgservice.is_readable()) { // for pre-luminous compat only! - if (!mon->pgmon()->pg_map.full_osds.empty()) { + if (mon->pgservice.have_full_osds()) { dout(5) << "There are full osds, setting full flag" << dendl; add_flag(CEPH_OSDMAP_FULL); } else if (osdmap.test_flag(CEPH_OSDMAP_FULL)){ @@ -3427,7 +3429,7 @@ void OSDMonitor::tick() remove_flag(CEPH_OSDMAP_FULL); } - if (!mon->pgmon()->pg_map.nearfull_osds.empty()) { + if (mon->pgservice.have_nearfull_osds()) { dout(5) << "There are near full osds, setting nearfull flag" << dendl; add_flag(CEPH_OSDMAP_NEARFULL); } else if (osdmap.test_flag(CEPH_OSDMAP_NEARFULL)){ diff --git a/src/mon/PGStatService.h b/src/mon/PGStatService.h index d3c6516542c..4478f976513 100644 --- a/src/mon/PGStatService.h +++ b/src/mon/PGStatService.h @@ -43,6 +43,11 @@ public: parent = o; } + /** returns true if the underlying data is readable. Always true + * post-luminous, but not when we are redirecting to the PGMonitor + */ + bool is_readable() { return true; } + const pool_stat_t* get_pool_stat(int poolid) const { auto i = parent.pg_pool_sum.find(poolid); if (i != parent.pg_pool_sum.end()) { @@ -50,6 +55,17 @@ public: } return NULL; } + + PGMap& get_pg_map() { return parent; } + + float get_full_ratio() const { return parent.full_ratio; } + float get_nearfull_ratio() const { return parent.nearfull_ratio; } + + bool have_creating_pgs() const { return !parent.creating_pgs.empty(); } + epoch_t get_min_last_epoch_clean() const { return parent.get_min_last_epoch_clean(); } + + bool have_full_osds() const { return !parent.full_osds.empty(); } + bool have_nearfull_osds() const { return !parent.nearfull_osds.empty(); } }; -- 2.39.5