Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osd/PG: reduce some overhead on operating MissingLoc #18186

Merged
merged 2 commits into from Oct 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/osd/PG.cc
Expand Up @@ -598,6 +598,7 @@ void PG::MissingLoc::add_batch_sources_info(
ldout(pg->cct, 10) << __func__ << ": adding sources in batch "
<< sources.size() << dendl;
unsigned loop = 0;
bool sources_updated = false;
for (map<hobject_t, pg_missing_item>::const_iterator i = needs_recovery_map.begin();
i != needs_recovery_map.end();
++i) {
Expand All @@ -608,7 +609,10 @@ void PG::MissingLoc::add_batch_sources_info(
if (i->second.is_delete())
continue;
missing_loc[i->first].insert(sources.begin(), sources.end());
missing_loc_sources.insert(sources.begin(), sources.end());
if (!sources_updated) {
missing_loc_sources.insert(sources.begin(), sources.end());
sources_updated = true;
}
}
}

Expand All @@ -620,6 +624,7 @@ bool PG::MissingLoc::add_source_info(
{
bool found_missing = false;
unsigned loop = 0;
bool sources_updated = false;
// found items?
for (map<hobject_t,pg_missing_item>::const_iterator p = needs_recovery_map.begin();
p != needs_recovery_map.end();
Expand Down Expand Up @@ -673,7 +678,10 @@ bool PG::MissingLoc::add_source_info(
<< " is on osd." << fromosd << dendl;

missing_loc[soid].insert(fromosd);
missing_loc_sources.insert(fromosd);
if (!sources_updated) {
missing_loc_sources.insert(fromosd);
sources_updated = true;
}
found_missing = true;
}

Expand Down
31 changes: 22 additions & 9 deletions src/osd/PG.h
Expand Up @@ -410,9 +410,15 @@ class PG : public DoutPrefixProvider {
return i->second.is_delete();
}
bool is_unfound(const hobject_t &hoid) const {
return needs_recovery(hoid) && !is_deleted(hoid) && (
!missing_loc.count(hoid) ||
!(*is_recoverable)(missing_loc.find(hoid)->second));
auto it = needs_recovery_map.find(hoid);
if (it == needs_recovery_map.end()) {
return false;
}
if (it->second.is_delete()) {
return false;
}
auto mit = missing_loc.find(hoid);
return mit == missing_loc.end() || !(*is_recoverable)(mit->second);
}
bool readable_with_acting(
const hobject_t &hoid,
Expand All @@ -423,7 +429,10 @@ class PG : public DoutPrefixProvider {
needs_recovery_map.begin();
i != needs_recovery_map.end();
++i) {
if (is_unfound(i->first))
if (i->second.is_delete())
continue;
auto mi = missing_loc.find(i->first);
if (mi == missing_loc.end() || !(*is_recoverable)(mi->second))
++ret;
}
return ret;
Expand All @@ -434,7 +443,10 @@ class PG : public DoutPrefixProvider {
needs_recovery_map.begin();
i != needs_recovery_map.end();
++i) {
if (is_unfound(i->first))
if (i->second.is_delete())
continue;
auto mi = missing_loc.find(i->first);
if (mi == missing_loc.end() || !(*is_recoverable)(mi->second))
return true;
}
return false;
Expand Down Expand Up @@ -473,8 +485,9 @@ class PG : public DoutPrefixProvider {
needs_recovery_map[hoid] = pg_missing_item(need, have);
}
void revise_need(const hobject_t &hoid, eversion_t need) {
assert(needs_recovery(hoid));
needs_recovery_map[hoid].need = need;
auto it = needs_recovery_map.find(hoid);
assert(it != needs_recovery_map.end());
it->second.need = need;
}

/// Adds info about a possible recovery source
Expand Down Expand Up @@ -550,8 +563,8 @@ class PG : public DoutPrefixProvider {
}

const set<pg_shard_t> &get_locations(const hobject_t &hoid) const {
return missing_loc.count(hoid) ?
missing_loc.find(hoid)->second : empty_set;
auto it = missing_loc.find(hoid);
return it == missing_loc.end() ? empty_set : it->second;
}
const map<hobject_t, set<pg_shard_t>> &get_missing_locs() const {
return missing_loc;
Expand Down