Skip to content

Commit fe0dd36

Browse files
committed
osd/scrub: reuse populate_config_params() in is_time_for_deep(),
avoiding code duplication. Signed-off-by: Ronen Friedman <[email protected]>
1 parent ca4dab3 commit fe0dd36

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/osd/scrubber/pg_scrubber.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,10 +2562,10 @@ bool PgScrubber::is_time_for_deep(
25622562
Scrub::ScrubPGPreconds pg_cond,
25632563
const requested_scrub_t& planned) const
25642564
{
2565+
const auto last_deep = m_pg->info.history.last_deep_scrub_stamp; // shorthand
25652566
dout(10) << fmt::format(
25662567
"{}: pg_cond:({}) need-auto?{} last_deep_scrub_stamp:{}",
2567-
__func__, pg_cond, planned.need_auto,
2568-
m_pg->info.history.last_deep_scrub_stamp)
2568+
__func__, pg_cond, planned.need_auto, last_deep)
25692569
<< dendl;
25702570

25712571
if (!pg_cond.allow_deep)
@@ -2576,20 +2576,21 @@ bool PgScrubber::is_time_for_deep(
25762576
return true;
25772577
}
25782578

2579-
auto next_deep = m_pg->next_deepscrub_interval();
2580-
if (ceph_clock_now() >= next_deep) {
2579+
const auto sched_conf = populate_config_params();
2580+
const auto next_deep = last_deep + sched_conf.deep_interval;
2581+
const auto timenow = ceph_clock_now();
2582+
if (timenow >= next_deep) {
25812583
dout(20) << fmt::format(
2582-
"{}: now ({}) >= time for deep ({})", __func__,
2583-
ceph_clock_now(), next_deep)
2584+
"{}: now ({}) >= time for deep ({})", __func__, timenow,
2585+
next_deep)
25842586
<< dendl;
25852587
return true;
25862588
}
25872589

25882590
if (pg_cond.has_deep_errors) {
25892591
// note: the text below is matched by 'standalone' tests
25902592
get_clog()->info() << fmt::format(
2591-
"osd.{} pg {} Deep scrub errors, "
2592-
"upgrading scrub to deep-scrub",
2593+
"osd.{} pg {} Deep scrub errors, upgrading scrub to deep-scrub",
25932594
get_whoami(), m_pg_id);
25942595
return true;
25952596
}
@@ -2598,9 +2599,8 @@ bool PgScrubber::is_time_for_deep(
25982599
// this function is called often, we will probably be deep-scrubbing most of
25992600
// the time.
26002601
if (pg_cond.allow_shallow) {
2601-
// RRR we have the conf already
2602-
const bool deep_coin_flip = random_bool_with_probability(
2603-
get_pg_cct()->_conf->osd_deep_scrub_randomize_ratio);
2602+
const bool deep_coin_flip =
2603+
random_bool_with_probability(sched_conf.deep_randomize_ratio);
26042604
if (deep_coin_flip) {
26052605
dout(10) << fmt::format(
26062606
"{}: scrub upgraded to deep (coin flip)", __func__)

0 commit comments

Comments
 (0)