]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/ReplicatedPG: load older HitSets into memory
authorSage Weil <sage@inktank.com>
Wed, 19 Feb 2014 05:02:15 +0000 (21:02 -0800)
committerSage Weil <sage@inktank.com>
Wed, 19 Feb 2014 05:05:34 +0000 (21:05 -0800)
If our evict_mode is non-idle, load older HitSets into memory in the agent
work thread.

Signed-off-by: Sage Weil <sage@inktank.com>
src/osd/ReplicatedPG.cc
src/osd/ReplicatedPG.h
src/osd/TierAgentState.h

index f5b0f99641a50c391353135137837143ee68172d..da90daa6e82b89bfe16929618d616c4774200eef 100644 (file)
@@ -10462,6 +10462,8 @@ void ReplicatedPG::agent_work(int start_max)
   assert(is_primary());
   assert(is_active());
 
+  agent_load_hit_sets();
+
   const pg_pool_t *base_pool = get_osdmap()->get_pg_pool(pool.info.tier_of);
   assert(base_pool);
 
@@ -10551,6 +10553,39 @@ void ReplicatedPG::agent_work(int start_max)
   unlock();
 }
 
+void ReplicatedPG::agent_load_hit_sets()
+{
+  if (agent_state->evict_mode == TierAgentState::EVICT_MODE_IDLE) {
+    agent_state->discard_hit_sets();
+    return;
+  }
+
+  if (agent_state->hit_set_map.size() < info.hit_set.history.size()) {
+    dout(10) << __func__ << dendl;
+    for (list<pg_hit_set_info_t>::reverse_iterator p =
+          info.hit_set.history.rbegin();
+        p != info.hit_set.history.rend(); ++p) {
+      if (agent_state->hit_set_map.count(p->begin.sec()) == 0) {
+       dout(10) << __func__ << " loading " << p->begin << "-"
+                << p->end << dendl;
+       if (!pool.info.is_replicated()) {
+         // FIXME: EC not supported here yet
+         derr << __func__ << " on non-replicated pool" << dendl;
+         break;
+       }
+       bufferlist bl;
+       hobject_t oid = get_hit_set_archive_object(p->begin, p->end);
+       int r = osd->store->read(coll, oid, 0, 0, bl);
+       assert(r >= 0);
+       HitSetRef hs(new HitSet);
+       bufferlist::iterator pbl = bl.begin();
+       ::decode(*hs, pbl);
+       agent_state->add_hit_set(p->begin.sec(), hs);
+      }
+    }
+  }
+}
+
 struct C_AgentFlushStartStop : public Context {
   ReplicatedPGRef pg;
   hobject_t oid;
index b6a80e2594c8676bc0af6e25ef1114c2168a359a..64d156800ba575a1e866c08062e3cf33fa8d3977 100644 (file)
@@ -739,6 +739,8 @@ protected:
   bool agent_maybe_flush(ObjectContextRef& obc);  ///< maybe flush
   bool agent_maybe_evict(ObjectContextRef& obc);  ///< maybe evict
 
+  void agent_load_hit_sets();  ///< load HitSets, if needed
+
   /// estimate object atime and temperature
   ///
   /// @param oid [in] object name
index 5cb12c7e66faee7d34c2f20ddff8a27f8f2c0ad2..b5f7910f209938b630aacb37379a9aedfb458317 100644 (file)
@@ -90,6 +90,11 @@ struct TierAgentState {
       hit_set_map.erase(hit_set_map.begin());
   }
 
+  /// discard all open hit sets
+  void discard_hit_sets() {
+    hit_set_map.clear();
+  }
+
   void dump(Formatter *f) const {
     f->dump_string("flush_mode", get_flush_mode_name());
     f->dump_string("evict_mode", get_evict_mode_name());