Merge pull request #20040 from liewegas/wip-snapmapper

osd: make snapmapper warn+clean up instead of assert

Reviewed-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2018-03-29 08:29:19 +08:00 committed by GitHub
commit 7dbc67f5e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 7 deletions

View File

@ -778,7 +778,7 @@ OPTION(osd_debug_drop_ping_duration, OPT_INT)
OPTION(osd_debug_op_order, OPT_BOOL)
OPTION(osd_debug_verify_missing_on_start, OPT_BOOL)
OPTION(osd_debug_scrub_chance_rewrite_digest, OPT_U64)
OPTION(osd_debug_verify_snaps_on_info, OPT_BOOL)
OPTION(osd_debug_verify_snaps, OPT_BOOL)
OPTION(osd_debug_verify_stray_on_activate, OPT_BOOL)
OPTION(osd_debug_skip_full_check_in_backfill_reservation, OPT_BOOL)
OPTION(osd_debug_reject_backfill_probability, OPT_DOUBLE)

View File

@ -3220,7 +3220,7 @@ std::vector<Option> get_global_options() {
.set_default(0)
.set_description(""),
Option("osd_debug_verify_snaps_on_info", Option::TYPE_BOOL, Option::LEVEL_DEV)
Option("osd_debug_verify_snaps", Option::TYPE_BOOL, Option::LEVEL_DEV)
.set_default(false)
.set_description(""),

View File

@ -3856,6 +3856,7 @@ void PG::update_snap_map(
try {
decode(snaps, p);
} catch (...) {
derr << __func__ << " decode snaps failure on " << *i << dendl;
snaps.clear();
}
set<snapid_t> _snaps(snaps.begin(), snaps.end());
@ -4463,10 +4464,25 @@ void PG::_scan_snaps(ScrubMap &smap)
<< "...repaired";
}
snap_mapper.add_oid(hoid, obj_snaps, &_t);
r = osd->store->queue_transaction(ch, std::move(t));
if (r != 0) {
derr << __func__ << ": queue_transaction got " << cpp_strerror(r)
<< dendl;
// wait for repair to apply to avoid confusing other bits of the system.
{
Cond my_cond;
Mutex my_lock("PG::_scan_snaps my_lock");
int r = 0;
bool done;
t.register_on_applied_sync(
new C_SafeCond(&my_lock, &my_cond, &done, &r));
r = osd->store->queue_transaction(ch, std::move(t));
if (r != 0) {
derr << __func__ << ": queue_transaction got " << cpp_strerror(r)
<< dendl;
} else {
my_lock.Lock();
while (!done)
my_cond.Wait(my_lock);
my_lock.Unlock();
}
}
}
}

View File

@ -243,11 +243,17 @@ void SnapMapper::add_oid(
MapCacher::Transaction<std::string, bufferlist> *t)
{
dout(20) << __func__ << " " << oid << " " << snaps << dendl;
assert(!snaps.empty());
assert(check(oid));
{
object_snaps out;
int r = get_snaps(oid, &out);
assert(r == -ENOENT);
if (r != -ENOENT) {
derr << __func__ << " found existing snaps mapped on " << oid
<< ", removing" << dendl;
assert(!cct->_conf->osd_debug_verify_snaps);
remove_oid(oid, t);
}
}
object_snaps _snaps(oid, snaps);