From: Zhiqiang Wang Date: Thu, 3 Dec 2015 03:22:21 +0000 (+0800) Subject: osd: do evict after flush X-Git-Tag: v10.0.3~159^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=341e3f95f74e4b9e77f1631f4fd69cab4961890c;p=ceph.git osd: do evict after flush When the evict mode is not idle, after successfully flushing an object to the base pool, we can try to evict it. We don't need to clear the dirty bit in this case. Signed-off-by: Zhiqiang Wang --- diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 92201d0d6a9..1dceea62926 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -7919,6 +7919,19 @@ int ReplicatedPG::try_flush_mark_clean(FlushOpRef fop) } } + // successfully flushed, can we evict this object? + if (!fop->op && agent_state->evict_mode != TierAgentState::EVICT_MODE_IDLE && + agent_maybe_evict(obc, true)) { + osd->logger->inc(l_osd_tier_clean); + if (fop->on_flush) { + Context *on_flush = fop->on_flush; + fop->on_flush = NULL; + on_flush->complete(0); + } + flush_ops.erase(oid); + return 0; + } + // successfully flushed; can we clear the dirty bit? // try to take the lock manually, since we don't // have a ctx yet. @@ -11518,7 +11531,7 @@ bool ReplicatedPG::agent_work(int start_max, int agent_flush_quota) } if (agent_state->evict_mode != TierAgentState::EVICT_MODE_IDLE && - agent_maybe_evict(obc)) + agent_maybe_evict(obc, false)) ++started; else if (agent_state->flush_mode != TierAgentState::FLUSH_MODE_IDLE && agent_flush_quota > 0 && agent_maybe_flush(obc)) { @@ -11712,10 +11725,10 @@ struct C_AgentEvictStartStop : public Context { } }; -bool ReplicatedPG::agent_maybe_evict(ObjectContextRef& obc) +bool ReplicatedPG::agent_maybe_evict(ObjectContextRef& obc, bool after_flush) { const hobject_t& soid = obc->obs.oi.soid; - if (obc->obs.oi.is_dirty()) { + if (!after_flush && obc->obs.oi.is_dirty()) { dout(20) << __func__ << " skip (dirty) " << obc->obs.oi << dendl; return false; } @@ -11785,6 +11798,8 @@ bool ReplicatedPG::agent_maybe_evict(ObjectContextRef& obc) ctx->delta_stats.num_objects_omap--; ctx->delta_stats.num_evict++; ctx->delta_stats.num_evict_kb += SHIFT_ROUND_UP(obc->obs.oi.size, 10); + if (obc->obs.oi.is_dirty()) + --ctx->delta_stats.num_objects_dirty; assert(r == 0); finish_ctx(ctx, pg_log_entry_t::DELETE, false); simple_repop_submit(repop); diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index e31c9fdeecb..22fac1ae91f 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -934,7 +934,7 @@ protected: } bool agent_work(int max, int agent_flush_quota); bool agent_maybe_flush(ObjectContextRef& obc); ///< maybe flush - bool agent_maybe_evict(ObjectContextRef& obc); ///< maybe evict + bool agent_maybe_evict(ObjectContextRef& obc, bool after_flush); ///< maybe evict void agent_load_hit_sets(); ///< load HitSets, if needed