Skip to content

Commit

Permalink
Merge pull request #20040 from liewegas/wip-snapmapper
Browse files Browse the repository at this point in the history
osd: make snapmapper warn+clean up instead of assert

Reviewed-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
tchaikov committed Mar 29, 2018
2 parents 2739b6f + 2f5a24d commit 7dbc67f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/common/legacy_config_opts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/common/options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(""),

Expand Down
24 changes: 20 additions & 4 deletions src/osd/PG.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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();
}
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/osd/SnapMapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7dbc67f

Please sign in to comment.