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: Check for and automatically repair object info soid during scrub #16052

Merged
merged 1 commit into from Jul 7, 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
47 changes: 47 additions & 0 deletions src/osd/PG.cc
Expand Up @@ -4023,6 +4023,52 @@ void PG::_scan_snaps(ScrubMap &smap)
}
}

void PG::_repair_oinfo_oid(ScrubMap &smap)
{
for (map<hobject_t, ScrubMap::object>::reverse_iterator i = smap.objects.rbegin();
i != smap.objects.rend();
++i) {
const hobject_t &hoid = i->first;
ScrubMap::object &o = i->second;

bufferlist bl;
if (o.attrs.find(OI_ATTR) == o.attrs.end()) {
continue;
}
bl.push_back(o.attrs[OI_ATTR]);
object_info_t oi;
try {
oi.decode(bl);
} catch(...) {
continue;
}
if (oi.soid != hoid) {
ObjectStore::Transaction t;
OSDriver::OSTransaction _t(osdriver.get_transaction(&t));
osd->clog->error() << "osd." << osd->whoami
<< " found object info error on pg "
<< info.pgid
<< " oid " << hoid << " oid in object info: "
<< oi.soid
<< "...repaired";
// Fix object info
oi.soid = hoid;
bl.clear();
::encode(oi, bl, get_osdmap()->get_features(CEPH_ENTITY_TYPE_OSD, nullptr));

bufferptr bp(bl.c_str(), bl.length());
o.attrs[OI_ATTR] = bp;

t.setattr(coll, ghobject_t(hoid), OI_ATTR, bl);
int r = osd->store->apply_transaction(osr.get(), std::move(t));
if (r != 0) {
derr << __func__ << ": apply_transaction got " << cpp_strerror(r)
<< dendl;
}
}
}
}

/*
* build a scrub map over a chunk without releasing the lock
* only used by chunky scrub
Expand Down Expand Up @@ -4055,6 +4101,7 @@ int PG::build_scrub_map_chunk(
get_pgbackend()->be_scan_list(map, ls, deep, seed, handle);
_scan_rollback_obs(rollback_obs, handle);
_scan_snaps(map);
_repair_oinfo_oid(map);

dout(20) << __func__ << " done" << dendl;
return 0;
Expand Down
1 change: 1 addition & 0 deletions src/osd/PG.h
Expand Up @@ -1347,6 +1347,7 @@ class PG : public DoutPrefixProvider {
void scrub_finish();
void scrub_clear_state();
void _scan_snaps(ScrubMap &map);
void _repair_oinfo_oid(ScrubMap &map);
void _scan_rollback_obs(
const vector<ghobject_t> &rollback_obs,
ThreadPool::TPHandle &handle);
Expand Down