From ca652104fe91ac41c7c1788a2907178c36fbe6ef Mon Sep 17 00:00:00 2001 From: yaoning Date: Thu, 24 Nov 2016 14:35:58 +0800 Subject: [PATCH] mon: no delay for single message MSG_ALIVE and MSG_PGTEMP delay and batch proposed as before if lots of messages arrive at the same time if too many messages are MSG_ALIVE and MSG_PGTEMP, wait a long period as before Signed-off-by: yaoning --- src/mon/OSDMonitor.cc | 17 +++++++++++++++++ src/mon/OSDMonitor.h | 3 +++ src/mon/Paxos.h | 8 ++++++++ 3 files changed, 28 insertions(+) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 082eee77df693..731fb2764ab63 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -80,6 +80,7 @@ OSDMonitor::OSDMonitor(CephContext *cct, Monitor *mn, Paxos *p, const string& se cct(cct), inc_osd_cache(g_conf->mon_osd_cache_size), full_osd_cache(g_conf->mon_osd_cache_size), + last_attempted_minwait_time(utime_t()), op_tracker(cct, true, 1) {} @@ -1364,6 +1365,22 @@ bool OSDMonitor::should_propose(double& delay) return true; } + // propose as fast as possible if updating up_thru or pg_temp + // want to merge OSDMap changes as much as possible + if ((pending_inc.new_primary_temp.size() == 1 + || pending_inc.new_up_thru.size() == 1) + && pending_inc.new_state.size() < 2) { + dout(15) << " propose as fast as possible for up_thru/pg_temp" << dendl; + + utime_t now = ceph_clock_now(); + if (now - last_attempted_minwait_time > g_conf->paxos_propose_interval + && now - paxos->get_last_commit_time() > g_conf->paxos_min_wait) { + delay = g_conf->paxos_min_wait; + last_attempted_minwait_time = now; + return true; + } + } + return PaxosService::should_propose(delay); } diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index 612870ec72cf8..9fa41729f6f29 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -131,6 +131,9 @@ private: bool check_failure(utime_t now, int target_osd, failure_info_t& fi); void force_failure(utime_t now, int target_osd); + // the time of last msg(MSG_ALIVE and MSG_PGTEMP) proposed without delay + utime_t last_attempted_minwait_time; + bool _have_pending_crush(); CrushWrapper &_get_stable_crush(); void _get_pending_crush(CrushWrapper& newcrush); diff --git a/src/mon/Paxos.h b/src/mon/Paxos.h index 99caf77c03191..3c5a15f9c24a2 100644 --- a/src/mon/Paxos.h +++ b/src/mon/Paxos.h @@ -1212,6 +1212,14 @@ public: * @return the first committed version */ version_t get_first_committed() { return first_committed; } + /** + * Get the last commit time + * + * @returns Our last commit time + */ + utime_t get_last_commit_time() const{ + return last_commit_time; + } /** * Check if a given version is readable. * -- 2.39.5