From: xie xingguo Date: Mon, 3 Feb 2020 12:09:37 +0000 (+0800) Subject: osd/OSD: trim osd_markdown_log in tick() thread X-Git-Tag: v15.1.1~536^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=59db3379ae9c77358adc5e9f17aaa5e8462a036f;p=ceph.git osd/OSD: trim osd_markdown_log in tick() thread 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 --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 54aa67074f3e..7975f6d28d3e 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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()