osd/ReplicatedPG: load older HitSets into memory

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>
This commit is contained in:
Sage Weil 2014-02-18 21:02:15 -08:00
parent 0af73755fa
commit a40cd5075c
3 changed files with 42 additions and 0 deletions

View File

@ -10462,6 +10462,8 @@ void ReplicatedPG::agent_work(int start_max)
assert(is_primary()); assert(is_primary());
assert(is_active()); assert(is_active());
agent_load_hit_sets();
const pg_pool_t *base_pool = get_osdmap()->get_pg_pool(pool.info.tier_of); const pg_pool_t *base_pool = get_osdmap()->get_pg_pool(pool.info.tier_of);
assert(base_pool); assert(base_pool);
@ -10551,6 +10553,39 @@ void ReplicatedPG::agent_work(int start_max)
unlock(); 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 { struct C_AgentFlushStartStop : public Context {
ReplicatedPGRef pg; ReplicatedPGRef pg;
hobject_t oid; hobject_t oid;

View File

@ -739,6 +739,8 @@ protected:
bool agent_maybe_flush(ObjectContextRef& obc); ///< maybe flush bool agent_maybe_flush(ObjectContextRef& obc); ///< maybe flush
bool agent_maybe_evict(ObjectContextRef& obc); ///< maybe evict bool agent_maybe_evict(ObjectContextRef& obc); ///< maybe evict
void agent_load_hit_sets(); ///< load HitSets, if needed
/// estimate object atime and temperature /// estimate object atime and temperature
/// ///
/// @param oid [in] object name /// @param oid [in] object name

View File

@ -90,6 +90,11 @@ struct TierAgentState {
hit_set_map.erase(hit_set_map.begin()); 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 { void dump(Formatter *f) const {
f->dump_string("flush_mode", get_flush_mode_name()); f->dump_string("flush_mode", get_flush_mode_name());
f->dump_string("evict_mode", get_evict_mode_name()); f->dump_string("evict_mode", get_evict_mode_name());