From: Mingxin Liu Date: Thu, 28 May 2015 06:33:10 +0000 (+0800) Subject: Osd: revise agent_choose_mode() to track the flush mode X-Git-Tag: v9.0.3~134^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8f6056aebbabcbe236d332f546d075e06a14c0ca;p=ceph.git Osd: revise agent_choose_mode() to track the flush mode Signed-off-by: Mingxin Liu Reviewed-by: Li Wang Suggested-by: Nick Fisk --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 294272844c44..e6393855132b 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -212,6 +212,7 @@ OSDService::OSDService(OSD *osd) : agent_lock("OSD::agent_lock"), agent_valid_iterator(false), agent_ops(0), + flush_mode_high_count(0), agent_active(true), agent_thread(this), agent_stop_flag(false), diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 2cf6819f596b..454896b5530b 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -581,6 +581,7 @@ public: set::iterator agent_queue_pos; bool agent_valid_iterator; int agent_ops; + int flush_mode_high_count; //once have one pg with FLUSH_MODE_HIGH then flush objects with high speed set agent_oids; bool agent_active; struct AgentThread : public Thread { @@ -672,6 +673,16 @@ public: return agent_ops; } + void agent_inc_high_count() { + Mutex::Locker l(agent_lock); + flush_mode_high_count ++; + } + + void agent_dec_high_count() { + Mutex::Locker l(agent_lock); + flush_mode_high_count --; + } + // -- Objecter, for teiring reads/writes from/to other OSDs -- Objecter *objecter; diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 4c549a5fd3d3..a59958425660 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -11020,17 +11020,23 @@ bool ReplicatedPG::agent_choose_mode(bool restart, OpRequestRef op) // flush mode TierAgentState::flush_mode_t flush_mode = TierAgentState::FLUSH_MODE_IDLE; uint64_t flush_target = pool.info.cache_target_dirty_ratio_micro; + uint64_t flush_high_target = pool.info.cache_target_dirty_high_ratio_micro; uint64_t flush_slop = (float)flush_target * g_conf->osd_agent_slop; - if (restart || agent_state->flush_mode == TierAgentState::FLUSH_MODE_IDLE) + if (restart || agent_state->flush_mode == TierAgentState::FLUSH_MODE_IDLE) { flush_target += flush_slop; - else + flush_high_target += flush_slop; + } else { flush_target -= MIN(flush_target, flush_slop); + flush_high_target -= MIN(flush_high_target, flush_slop); + } if (info.stats.stats_invalid) { // idle; stats can't be trusted until we scrub. dout(20) << __func__ << " stats invalid (post-split), idle" << dendl; + } else if (dirty_micro > flush_high_target) { + flush_mode = TierAgentState::FLUSH_MODE_HIGH; } else if (dirty_micro > flush_target) { - flush_mode = TierAgentState::FLUSH_MODE_ACTIVE; + flush_mode = TierAgentState::FLUSH_MODE_LOW; } // evict mode @@ -11075,6 +11081,10 @@ bool ReplicatedPG::agent_choose_mode(bool restart, OpRequestRef op) << " -> " << TierAgentState::get_flush_mode_name(flush_mode) << dendl; + if (flush_mode == TierAgentState::FLUSH_MODE_HIGH) + osd->agent_inc_high_count(); + if (agent_state->flush_mode == TierAgentState::FLUSH_MODE_HIGH) + osd->agent_dec_high_count(); agent_state->flush_mode = flush_mode; } if (evict_mode != agent_state->evict_mode) {