]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: OSDMonitor starting to abstract PGMap via PGService
authorGreg Farnum <gfarnum@redhat.com>
Fri, 17 Mar 2017 22:42:38 +0000 (15:42 -0700)
committerSage Weil <sage@redhat.com>
Fri, 2 Jun 2017 16:59:13 +0000 (12:59 -0400)
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 <gfarnum@redhat.com>
src/mon/OSDMonitor.cc
src/mon/PGStatService.h

index 1c85408ea125024042effc76ae00650306872df0..a24ad8d58a6bf8df90b70c42a31c35420032d350 100644 (file)
@@ -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<std::mutex> 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)){
index d3c6516542ca727664b76253fd1c49e0251e5f1b..4478f976513c96e662f67c7012a2b213e201446b 100644 (file)
@@ -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(); }
 };