]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd/OSD: trim osd_markdown_log in tick() thread
authorxie xingguo <xie.xingguo@zte.com.cn>
Mon, 3 Feb 2020 12:09:37 +0000 (20:09 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Mon, 3 Feb 2020 12:09:37 +0000 (20:09 +0800)
so we don't have to do it in multiple places. Note that
we can't do it in the tick_without_osd_lock thread instead
because we we can not access it safely without the protection
of osd_lock.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/osd/OSD.cc

index 54aa67074f3e19cd07b25ccf47b2c5d9cb90161c..7975f6d28d3e0ef02ab497e34a8d1a0bb298cee7 100644 (file)
@@ -5794,6 +5794,13 @@ void OSD::tick()
   ceph_assert(ceph_mutex_is_locked(osd_lock));
   dout(10) << "tick" << dendl;
 
+  utime_t now = ceph_clock_now();
+  // throw out any obsolete markdown log
+  utime_t grace = utime_t(cct->_conf->osd_max_markdown_period, 0);
+  while (!osd_markdown_log.empty() &&
+          osd_markdown_log.front() + grace < now)
+    osd_markdown_log.pop_front();
+
   if (is_active() || is_waiting_for_healthy()) {
     maybe_update_heartbeat_peers();
   }
@@ -5804,7 +5811,6 @@ void OSD::tick()
 
   if (is_waiting_for_healthy() || is_booting()) {
     std::lock_guard l(heartbeat_lock);
-    utime_t now = ceph_clock_now();
     if (now - last_mon_heartbeat > cct->_conf->osd_mon_heartbeat_interval) {
       last_mon_heartbeat = now;
       dout(1) << __func__ << " checking mon for new map" << dendl;
@@ -6411,10 +6417,6 @@ bool OSD::_is_healthy()
 
   if (is_waiting_for_healthy()) {
      utime_t now = ceph_clock_now();
-     utime_t grace = utime_t(cct->_conf->osd_max_markdown_period, 0);
-     while (!osd_markdown_log.empty() &&
-             osd_markdown_log.front() + grace < now)
-       osd_markdown_log.pop_front();
      if (osd_markdown_log.size() <= 1) {
        dout(5) << __func__ << " first time marked as down,"
                << " try reboot unconditionally" << dendl;
@@ -8221,10 +8223,6 @@ void OSD::_committed_osd_maps(epoch_t first, epoch_t last, MOSDMap *m)
        utime_t now = ceph_clock_now();
        utime_t grace = utime_t(cct->_conf->osd_max_markdown_period, 0);
        osd_markdown_log.push_back(now);
-       //clear all out-of-date log
-       while (!osd_markdown_log.empty() &&
-              osd_markdown_log.front() + grace < now)
-         osd_markdown_log.pop_front();
        if ((int)osd_markdown_log.size() > cct->_conf->osd_max_markdown_count) {
          dout(0) << __func__ << " marked down "
                  << osd_markdown_log.size()