]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/ReplicatedPG: initial agent to random hash position inside pg
authorSage Weil <sage@inktank.com>
Tue, 28 Jan 2014 00:26:19 +0000 (16:26 -0800)
committerSage Weil <sage@inktank.com>
Sun, 16 Feb 2014 06:09:38 +0000 (22:09 -0800)
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>
src/osd/ReplicatedPG.cc

index 714cf38ab7a2dc543273ec5e1b4089221fb4e5d5..664c2e0f4b5ef612993898a6b9ab92200bb7d177 100644 (file)
@@ -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;
   }