From: Sage Weil Date: Tue, 28 Jan 2014 00:26:19 +0000 (-0800) Subject: osd/ReplicatedPG: initial agent to random hash position inside pg X-Git-Tag: v0.78~166^2~21 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3bc31272db218faa3a381836b29f677e15be6746;p=ceph.git osd/ReplicatedPG: initial agent to random hash position inside pg When the agent starts, start at a random offset to ensure we get a more uniform distribution of attention to all objects in the PG. Otherwise, we will disproportionately examine objects at the "beginning" of the PG if we are interrupted by peering or restarts or some other activity. Note that if the agent_state is preserved, we do not forget our position, which is also nice. We *could* persist this position in the pg_info_t somewhere, but I am not sure it is worth the effort. Signed-off-by: Sage Weil --- diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 714cf38ab7a..664c2e0f4b5 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -10183,8 +10183,16 @@ void ReplicatedPG::agent_setup() return; } if (!agent_state) { - dout(10) << __func__ << " allocated new state" << dendl; agent_state.reset(new TierAgentState); + + // choose random starting position + agent_state->position = hobject_t(); + agent_state->position.pool = info.pgid.pool(); + agent_state->position.hash = pool.info.get_random_pg_position(info.pgid, + rand()); + + dout(10) << __func__ << " allocated new state, position " + << agent_state->position << dendl; } else { dout(10) << __func__ << " keeping existing state" << dendl; }