From 09839d00c0e1c5bc0e9ee2e1a1d24cb2cf9a1118 Mon Sep 17 00:00:00 2001 From: Yunchuan Wen Date: Tue, 4 Aug 2015 08:47:05 +0000 Subject: [PATCH] Allow evict operations to be throttled In agent_work(), it did not touch agent_ops when it started an evict operation, so evict operations were not throttled. This patch fixes it. Signed-off-by: Yunchuan Wen Reviewed-by: Li Wang Reviewed-by: Mingxin Liu --- src/osd/ReplicatedPG.cc | 12 ++++++++++++ src/osd/ReplicatedPG.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 4b8c2eb0316c..9dbb30c35829 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -10855,6 +10855,16 @@ bool ReplicatedPG::agent_maybe_flush(ObjectContextRef& obc) return true; } +struct C_AgentEvictStartStop : public Context { + ReplicatedPGRef pg; + C_AgentEvictStartStop(ReplicatedPG *p) : pg(p) { + pg->osd->agent_start_evict_op(); + } + void finish(int r) { + pg->osd->agent_finish_evict_op(); + } +}; + bool ReplicatedPG::agent_maybe_evict(ObjectContextRef& obc) { const hobject_t& soid = obc->obs.oi.soid; @@ -10943,6 +10953,8 @@ bool ReplicatedPG::agent_maybe_evict(ObjectContextRef& obc) dout(10) << __func__ << " evicting " << obc->obs.oi << dendl; RepGather *repop = simple_repop_create(obc); OpContext *ctx = repop->ctx; + Context *on_evict = new C_AgentEvictStartStop(this); + ctx->on_finish = on_evict; ctx->lock_to_release = OpContext::W_LOCK; ctx->at_version = get_next_version(); assert(ctx->new_obs.exists); diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index 9c280365da27..690da03a0dc2 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -922,6 +922,7 @@ protected: boost::scoped_ptr agent_state; friend struct C_AgentFlushStartStop; + friend struct C_AgentEvictStartStop; friend struct C_HitSetFlushing; void agent_setup(); ///< initialize agent state -- 2.47.3