]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/PGMonitor: simplify propose logic for check_osd_map() process
authorxie xingguo <xie.xingguo@zte.com.cn>
Tue, 31 May 2016 02:45:02 +0000 (10:45 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Fri, 3 Jun 2016 09:45:51 +0000 (17:45 +0800)
We'll assure pg_map.last_osdmap_epoch is smaller than osdmap's epoch
at the function entry, so we are doomed to update pending_inc.osdmap_epoch,
which means the "propose" variables will be always set to true.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/mon/PGMonitor.cc
src/mon/PGMonitor.h

index 3b88258bd4007affe5dcaca547a7fe916e118713..5ae91286f1e1aeab26cce541db6d6942bb4d5a9b 100644 (file)
@@ -935,23 +935,15 @@ void PGMonitor::check_osd_map(epoch_t epoch)
     }
   }
 
-  bool propose = false;
-  if (pg_map.last_osdmap_epoch < epoch) {
-    pending_inc.osdmap_epoch = epoch;
-    propose = true;
-  }
-
-  if (map_pg_creates())
-    propose = true;
-  if (register_new_pgs())
-    propose = true;
+  assert(pg_map.last_osdmap_epoch < epoch);
+  pending_inc.osdmap_epoch = epoch;
+  map_pg_creates();
+  register_new_pgs();
 
-  if ((need_check_down_pgs || !need_check_down_pg_osds.empty()) &&
-      check_down_pgs())
-    propose = true;
+  if (need_check_down_pgs || !need_check_down_pg_osds.empty())
+    check_down_pgs();
 
-  if (propose)
-    propose_pending();
+  propose_pending();
 }
 
 void PGMonitor::register_pg(OSDMap *osdmap,
@@ -1037,7 +1029,7 @@ void PGMonitor::register_pg(OSDMap *osdmap,
   }
 }
 
-bool PGMonitor::register_new_pgs()
+void PGMonitor::register_new_pgs()
 {
   // iterate over crush mapspace
   OSDMap *osdmap = &mon->osdmon()->osdmap;
@@ -1119,10 +1111,9 @@ bool PGMonitor::register_new_pgs()
 
   dout(10) << "register_new_pgs registered " << created << " new pgs, removed "
            << removed << " uncreated pgs" << dendl;
-  return (created || removed);
 }
 
-bool PGMonitor::map_pg_creates()
+void PGMonitor::map_pg_creates()
 {
   OSDMap *osdmap = &mon->osdmon()->osdmap;
 
@@ -1190,9 +1181,7 @@ bool PGMonitor::map_pg_creates()
   }
   if (changed) {
     dout(10) << __func__ << " " << changed << " pgs changed primary" << dendl;
-    return true;
   }
-  return false;
 }
 
 void PGMonitor::send_pg_creates()
@@ -1303,12 +1292,12 @@ void PGMonitor::_try_mark_pg_stale(
   }
 }
 
-bool PGMonitor::check_down_pgs()
+void PGMonitor::check_down_pgs()
 {
   dout(10) << "check_down_pgs last_osdmap_epoch "
           << pg_map.last_osdmap_epoch << dendl;
   if (pg_map.last_osdmap_epoch == 0)
-    return false;
+    return;
 
   // use the OSDMap that matches the one pg_map has consumed.
   std::unique_ptr<OSDMap> osdmap;
@@ -1318,8 +1307,6 @@ bool PGMonitor::check_down_pgs()
   osdmap.reset(new OSDMap);
   osdmap->decode(bl);
 
-  bool ret = false;
-
   // if a large number of osds changed state, just iterate over the whole
   // pg map.
   if (need_check_down_pg_osds.size() > (unsigned)osdmap->get_num_osds() *
@@ -1332,7 +1319,6 @@ bool PGMonitor::check_down_pgs()
           p.second.acting_primary != -1 &&
           osdmap->is_down(p.second.acting_primary)) {
        _try_mark_pg_stale(osdmap.get(), p.first, p.second);
-       ret = true;
       }
     }
   } else {
@@ -1343,7 +1329,6 @@ bool PGMonitor::check_down_pgs()
          assert(stat.acting_primary == osd);
          if ((stat.state & PG_STATE_STALE) == 0) {
            _try_mark_pg_stale(osdmap.get(), pgid, stat);
-           ret = true;
          }
        }
       }
@@ -1351,8 +1336,6 @@ bool PGMonitor::check_down_pgs()
   }
   need_check_down_pgs = false;
   need_check_down_pg_osds.clear();
-
-  return ret;
 }
 
 inline string percentify(const float& a) {
index b02003b5e8c89b81add49a7e43b6b60677d85b6d..c2b917b63aa60360c721c8c3179053ec910bd9e0 100644 (file)
@@ -115,17 +115,13 @@ private:
 
   /**
    * check latest osdmap for new pgs to register
-   *
-   * @return true if we updated pending_inc (and should propose)
    */
-  bool register_new_pgs();
+  void register_new_pgs();
 
   /**
    * recalculate creating pg mappings
-   *
-   * @return true if we updated pending_inc
    */
-  bool map_pg_creates();
+  void map_pg_creates();
 
   void send_pg_creates();
   epoch_t send_pg_creates(int osd, Connection *con, epoch_t next);
@@ -136,9 +132,8 @@ private:
    * clears need_check_down_pgs
    * clears need_check_down_pg_osds
    *
-   * @return true if we updated pending_inc (and should propose)
    */
-  bool check_down_pgs();
+  void check_down_pgs();
   void _try_mark_pg_stale(const OSDMap *osdmap, pg_t pgid,
                          const pg_stat_t& cur_stat);