Skip to content

Commit

Permalink
osd/ReplicatedPG: load older HitSets into memory
Browse files Browse the repository at this point in the history
If our evict_mode is non-idle, load older HitSets into memory in the agent
work thread.

Signed-off-by: Sage Weil <[email protected]>
  • Loading branch information
Sage Weil committed Feb 19, 2014
1 parent 0af7375 commit a40cd50
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/osd/ReplicatedPG.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/osd/ReplicatedPG.h
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,8 @@ class ReplicatedPG : public PG, public PGBackend::Listener {
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
Expand Down
5 changes: 5 additions & 0 deletions src/osd/TierAgentState.h
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit a40cd50

Please sign in to comment.