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 <sage@inktank.com>
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;
}