From 42eb24f18d5114410bd2a3e84e9219584d9e165e Mon Sep 17 00:00:00 2001 From: David Zafman Date: Thu, 1 Dec 2016 16:39:42 -0800 Subject: [PATCH] osd: When deep-scrub errors present upgrade regular scrubs Previously, if a weekly deep-scrub found errors the next daily scrub would cause the deep-scrub information to be removed. Signed-off-by: David Zafman (cherry picked from commit 532a759dca466181f37a329f86045c34f1a2506f) --- src/osd/PG.cc | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index c11c085022b9b..0504f06cda19c 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -3328,6 +3328,7 @@ void PG::requeue_ops(list &ls) // returns true if a scrub has been newly kicked off bool PG::sched_scrub() { + bool nodeep_scrub = false; assert(_lock.is_locked()); if (!(is_primary() && is_active() && is_clean() && !is_scrubbing())) { return false; @@ -3351,8 +3352,10 @@ bool PG::sched_scrub() //NODEEP_SCRUB so ignore time initiated deep-scrub if (osd->osd->get_osdmap()->test_flag(CEPH_OSDMAP_NODEEP_SCRUB) || - pool.info.has_flag(pg_pool_t::FLAG_NODEEP_SCRUB)) + pool.info.has_flag(pg_pool_t::FLAG_NODEEP_SCRUB)) { time_for_deep = false; + nodeep_scrub = true; + } if (!scrubber.must_scrub) { assert(!scrubber.must_deep_scrub); @@ -3410,6 +3413,24 @@ bool PG::sched_scrub() if (time_for_deep) { dout(10) << "sched_scrub: scrub will be deep" << dendl; state_set(PG_STATE_DEEP_SCRUB); + } else if (!scrubber.must_deep_scrub && info.stats.stats.sum.num_deep_scrub_errors) { + if (!nodeep_scrub) { + osd->clog->info() << "osd." << osd->whoami + << " pg " << info.pgid + << " Deep scrub errors, upgrading scrub to deep-scrub"; + state_set(PG_STATE_DEEP_SCRUB); + } else if (!scrubber.must_scrub) { + osd->clog->error() << "osd." << osd->whoami + << " pg " << info.pgid + << " Regular scrub skipped due to deep-scrub errors and nodeep-scrub set"; + clear_scrub_reserved(); + scrub_unreserve_replicas(); + return false; + } else { + osd->clog->error() << "osd." << osd->whoami + << " pg " << info.pgid + << " Regular scrub request, losing deep-scrub details"; + } } queue_scrub(); } else { @@ -4527,7 +4548,7 @@ void PG::scrub_finish() oss << "ok"; if (!deep_scrub && info.stats.stats.sum.num_deep_scrub_errors) oss << " ( " << info.stats.stats.sum.num_deep_scrub_errors - << " remaining deep scrub error(s) )"; + << " remaining deep scrub error details lost)"; if (repair) oss << ", " << scrubber.fixed << " fixed"; oss << "\n"; -- 2.39.5