From: Li Wang Date: Sat, 1 Aug 2015 04:14:41 +0000 (+0800) Subject: osd: avoid unnecessary calculation in agent_choose_mode() X-Git-Tag: v9.1.0~262^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8652a37039d60ac28d5809ff7fb44778ff0e5850;p=ceph.git osd: avoid unnecessary calculation in agent_choose_mode() Signed-off-by: Li Wang Reviewed-by: Yunchuan Wen --- diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 4b8c2eb0316c..07168b390d08 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -10997,6 +10997,17 @@ bool ReplicatedPG::agent_choose_mode(bool restart, OpRequestRef op) return requeued; } + TierAgentState::flush_mode_t flush_mode = TierAgentState::FLUSH_MODE_IDLE; + TierAgentState::evict_mode_t evict_mode = TierAgentState::EVICT_MODE_IDLE; + unsigned evict_effort = 0; + + if (info.stats.stats_invalid) { + // idle; stats can't be trusted until we scrub. + dout(20) << __func__ << " stats invalid (post-split), idle" << dendl; + goto skip_calc; + } + + { uint64_t divisor = pool.info.get_pg_num_divisor(info.pgid.pgid); assert(divisor > 0); @@ -11075,7 +11086,6 @@ bool ReplicatedPG::agent_choose_mode(bool restart, OpRequestRef op) << dendl; // 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; @@ -11087,18 +11097,13 @@ bool ReplicatedPG::agent_choose_mode(bool restart, OpRequestRef op) 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) { + if (dirty_micro > flush_high_target) { flush_mode = TierAgentState::FLUSH_MODE_HIGH; } else if (dirty_micro > flush_target) { flush_mode = TierAgentState::FLUSH_MODE_LOW; } // evict mode - TierAgentState::evict_mode_t evict_mode = TierAgentState::EVICT_MODE_IDLE; - unsigned evict_effort = 0; uint64_t evict_target = pool.info.cache_target_full_ratio_micro; uint64_t evict_slop = (float)evict_target * g_conf->osd_agent_slop; if (restart || agent_state->evict_mode == TierAgentState::EVICT_MODE_IDLE) @@ -11106,9 +11111,7 @@ bool ReplicatedPG::agent_choose_mode(bool restart, OpRequestRef op) else evict_target -= MIN(evict_target, evict_slop); - if (info.stats.stats_invalid) { - // idle; stats can't be trusted until we scrub. - } else if (full_micro > 1000000) { + if (full_micro > 1000000) { // evict anything clean evict_mode = TierAgentState::EVICT_MODE_FULL; evict_effort = 1000000; @@ -11130,7 +11133,9 @@ bool ReplicatedPG::agent_choose_mode(bool restart, OpRequestRef op) assert(evict_effort >= inc && evict_effort <= 1000000); dout(30) << __func__ << " evict_effort " << was << " quantized by " << inc << " to " << evict_effort << dendl; } + } + skip_calc: bool old_idle = agent_state->is_idle(); if (flush_mode != agent_state->flush_mode) { dout(5) << __func__ << " flush_mode "