Skip to content

Commit 479d6bb

Browse files
authored
Merge pull request ceph#62769 from ronen-fr/wip-rf-delayready
osd/scrub: discard delay_ready_t Reviewed-by: Matan Breizman <[email protected]>
2 parents 5ff2eb5 + c374280 commit 479d6bb

File tree

8 files changed

+40
-69
lines changed

8 files changed

+40
-69
lines changed

src/osd/PG.cc

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,16 +1298,12 @@ double PG::next_deepscrub_interval() const
12981298
return info.history.last_deep_scrub_stamp + deep_scrub_interval;
12991299
}
13001300

1301-
void PG::on_scrub_schedule_input_change(Scrub::delay_ready_t delay_ready)
1301+
void PG::on_scrub_schedule_input_change()
13021302
{
13031303
if (is_active() && is_primary() && !is_scrub_queued_or_active()) {
1304-
dout(10) << fmt::format(
1305-
"{}: active/primary. delay_ready={:c}", __func__,
1306-
(delay_ready == Scrub::delay_ready_t::delay_ready) ? 't'
1307-
: 'f')
1308-
<< dendl;
1304+
dout(10) << fmt::format("{}: active/primary", __func__) << dendl;
13091305
ceph_assert(m_scrubber);
1310-
m_scrubber->update_scrub_job(delay_ready);
1306+
m_scrubber->update_scrub_job();
13111307
} else {
13121308
dout(10) << fmt::format(
13131309
"{}: inactive, non-primary - or already scrubbing",
@@ -2210,7 +2206,7 @@ void PG::handle_activate_map(PeeringCtx &rctx, epoch_t range_starts_at)
22102206
// on_scrub_schedule_input_change() as pool.info contains scrub scheduling
22112207
// parameters.
22122208
if (pool.info.last_change >= range_starts_at) {
2213-
on_scrub_schedule_input_change(Scrub::delay_ready_t::delay_ready);
2209+
on_scrub_schedule_input_change();
22142210
}
22152211
}
22162212

src/osd/PG.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ class PG : public DoutPrefixProvider,
262262
set_last_scrub_stamp(t, history, stats);
263263
return true;
264264
});
265-
on_scrub_schedule_input_change(Scrub::delay_ready_t::delay_ready);
265+
on_scrub_schedule_input_change();
266266
}
267267

268268
static void set_last_deep_scrub_stamp(
@@ -278,7 +278,7 @@ class PG : public DoutPrefixProvider,
278278
set_last_scrub_stamp(t, history, stats);
279279
return true;
280280
});
281-
on_scrub_schedule_input_change(Scrub::delay_ready_t::delay_ready);
281+
on_scrub_schedule_input_change();
282282
}
283283

284284
static void add_objects_scrubbed_count(
@@ -511,7 +511,7 @@ class PG : public DoutPrefixProvider,
511511
* - pg stat scrub timestamps
512512
* - etc
513513
*/
514-
void on_scrub_schedule_input_change(Scrub::delay_ready_t delay_ready);
514+
void on_scrub_schedule_input_change();
515515

516516
void scrub_requested(scrub_level_t scrub_level, scrub_type_t scrub_type) override;
517517

src/osd/scrubber/osd_scrub.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,7 @@ void OsdScrub::on_config_change()
259259
"updating scrub schedule on {}",
260260
(locked_pg->pg())->get_pgid())
261261
<< dendl;
262-
locked_pg->pg()->on_scrub_schedule_input_change(
263-
Scrub::delay_ready_t::no_delay);
262+
locked_pg->pg()->on_scrub_schedule_input_change();
264263
}
265264
}
266265

src/osd/scrubber/pg_scrubber.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -480,11 +480,10 @@ void PgScrubber::update_targets(utime_t scrub_clock_now)
480480

481481
// the next periodic scrubs:
482482
m_scrub_job->adjust_shallow_schedule(
483-
m_pg->info.history.last_scrub_stamp, applicable_conf, scrub_clock_now,
484-
delay_ready_t::delay_ready);
483+
m_pg->info.history.last_scrub_stamp, applicable_conf, scrub_clock_now);
485484
m_scrub_job->adjust_deep_schedule(
486485
m_pg->info.history.last_deep_scrub_stamp, applicable_conf,
487-
scrub_clock_now, delay_ready_t::delay_ready);
486+
scrub_clock_now);
488487

489488
dout(10) << fmt::format("{}: adjusted:{}", __func__, *m_scrub_job) << dendl;
490489
}
@@ -499,7 +498,7 @@ void PgScrubber::schedule_scrub_with_osd()
499498
"{}: state at entry: {}", __func__, m_scrub_job->state_desc())
500499
<< dendl;
501500
m_scrub_job->registered = true;
502-
update_scrub_job(delay_ready_t::delay_ready);
501+
update_scrub_job();
503502
}
504503

505504

@@ -523,7 +522,7 @@ void PgScrubber::on_primary_active_clean()
523522
* - in the 2nd case - we know the PG state and we know we are only called
524523
* for a Primary.
525524
*/
526-
void PgScrubber::update_scrub_job(Scrub::delay_ready_t delay_ready)
525+
void PgScrubber::update_scrub_job()
527526
{
528527
if (!is_primary() || !m_scrub_job) {
529528
dout(10) << fmt::format(
@@ -2036,7 +2035,7 @@ void PgScrubber::scrub_finish()
20362035
request_rescrubbing();
20372036
}
20382037
// determine the next scrub time
2039-
update_scrub_job(delay_ready_t::delay_ready);
2038+
update_scrub_job();
20402039

20412040
if (m_pg->is_active() && m_pg->is_primary()) {
20422041
m_pg->recovery_state.share_pg_info();

src/osd/scrubber/pg_scrubber.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ class PgScrubber : public ScrubPgIF,
326326

327327
// managing scrub op registration
328328

329-
void update_scrub_job(Scrub::delay_ready_t delay_ready) final;
329+
void update_scrub_job() final;
330330

331331
void rm_from_osd_scrubbing() final;
332332

src/osd/scrubber/scrub_job.cc

Lines changed: 23 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ using OSDRestrictions = Scrub::OSDRestrictions;
1313
using sched_conf_t = Scrub::sched_conf_t;
1414
using scrub_schedule_t = Scrub::scrub_schedule_t;
1515
using ScrubJob = Scrub::ScrubJob;
16-
using delay_ready_t = Scrub::delay_ready_t;
1716
using namespace std::chrono;
1817

1918
using SchedEntry = Scrub::SchedEntry;
@@ -99,15 +98,11 @@ void ScrubJob::set_both_targets_queued()
9998
void ScrubJob::adjust_shallow_schedule(
10099
utime_t last_scrub,
101100
const Scrub::sched_conf_t& app_conf,
102-
utime_t scrub_clock_now,
103-
delay_ready_t modify_ready_targets)
101+
utime_t scrub_clock_now)
104102
{
105103
dout(10) << fmt::format(
106-
"at entry: shallow target:{}, conf:{}, last-stamp:{:s} "
107-
"also-ready?{:c}",
108-
shallow_target, app_conf, last_scrub,
109-
(modify_ready_targets == delay_ready_t::delay_ready) ? 'y'
110-
: 'n')
104+
"at entry: shallow target:{}, conf:{}, last-stamp:{:s}",
105+
shallow_target, app_conf, last_scrub)
111106
<< dendl;
112107

113108
auto& sh_times = shallow_target.sched_info.schedule; // shorthand
@@ -117,15 +112,11 @@ void ScrubJob::adjust_shallow_schedule(
117112
utime_t adj_target = last_scrub;
118113
sh_times.deadline = adj_target;
119114

120-
// add a random delay to the proposed scheduled time - but only for periodic
121-
// scrubs that are not already eligible for scrubbing.
122-
if ((modify_ready_targets == delay_ready_t::delay_ready) ||
123-
adj_not_before > scrub_clock_now) {
124-
adj_target += app_conf.shallow_interval;
125-
double r = rand() / (double)RAND_MAX;
126-
adj_target +=
115+
// add a random delay to the proposed scheduled time
116+
adj_target += app_conf.shallow_interval;
117+
double r = rand() / (double)RAND_MAX;
118+
adj_target +=
127119
app_conf.shallow_interval * app_conf.interval_randomize_ratio * r;
128-
}
129120

130121
// the deadline can be updated directly into the scrub-job
131122
if (app_conf.max_shallow) {
@@ -238,15 +229,11 @@ utime_t ScrubJob::get_sched_time() const
238229
void ScrubJob::adjust_deep_schedule(
239230
utime_t last_deep,
240231
const Scrub::sched_conf_t& app_conf,
241-
utime_t scrub_clock_now,
242-
delay_ready_t modify_ready_targets)
232+
utime_t scrub_clock_now)
243233
{
244234
dout(10) << fmt::format(
245-
"at entry: deep target:{}, conf:{}, last-stamp:{:s} "
246-
"also-ready?{:c}",
247-
deep_target, app_conf, last_deep,
248-
(modify_ready_targets == delay_ready_t::delay_ready) ? 'y'
249-
: 'n')
235+
"at entry: deep target:{}, conf:{}, last-stamp:{:s}",
236+
deep_target, app_conf, last_deep)
250237
<< dendl;
251238

252239
auto& dp_times = deep_target.sched_info.schedule; // shorthand
@@ -256,23 +243,19 @@ void ScrubJob::adjust_deep_schedule(
256243
utime_t adj_target = last_deep;
257244
dp_times.deadline = adj_target;
258245

259-
// add a random delay to the proposed scheduled time - but only for periodic
260-
// scrubs that are not already eligible for scrubbing.
261-
if ((modify_ready_targets == delay_ready_t::delay_ready) ||
262-
adj_not_before > scrub_clock_now) {
263-
double sdv = app_conf.deep_interval * app_conf.deep_randomize_ratio;
264-
std::normal_distribution<double> normal_dist{app_conf.deep_interval, sdv};
265-
auto next_delay = std::clamp(
266-
normal_dist(random_gen), app_conf.deep_interval - 2 * sdv,
267-
app_conf.deep_interval + 2 * sdv);
268-
adj_target += next_delay;
269-
dout(20) << fmt::format(
270-
"deep scrubbing: next_delay={:.0f} (interval={:.0f}, "
271-
"ratio={:.3f}), adjusted:{:s}",
272-
next_delay, app_conf.deep_interval,
273-
app_conf.deep_randomize_ratio, adj_target)
274-
<< dendl;
275-
}
246+
// add a random delay to the proposed scheduled time
247+
const double sdv = app_conf.deep_interval * app_conf.deep_randomize_ratio;
248+
std::normal_distribution<double> normal_dist{app_conf.deep_interval, sdv};
249+
auto next_delay =
250+
std::clamp(normal_dist(random_gen), app_conf.deep_interval - 2 * sdv,
251+
app_conf.deep_interval + 2 * sdv);
252+
adj_target += next_delay;
253+
dout(20) << fmt::format(
254+
"deep scrubbing: next_delay={:.0f} (interval={:.0f}, "
255+
"ratio={:.3f}), adjusted:{:s}",
256+
next_delay, app_conf.deep_interval,
257+
app_conf.deep_randomize_ratio, adj_target)
258+
<< dendl;
276259

277260
// the deadline can be updated directly into the scrub-job
278261
if (app_conf.max_shallow) {

src/osd/scrubber/scrub_job.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,12 @@ class ScrubJob {
235235
void adjust_shallow_schedule(
236236
utime_t last_scrub,
237237
const Scrub::sched_conf_t& app_conf,
238-
utime_t scrub_clock_now,
239-
delay_ready_t modify_ready_targets);
238+
utime_t scrub_clock_now);
240239

241240
void adjust_deep_schedule(
242241
utime_t last_deep,
243242
const Scrub::sched_conf_t& app_conf,
244-
utime_t scrub_clock_now,
245-
delay_ready_t modify_ready_targets);
243+
utime_t scrub_clock_now);
246244

247245
/**
248246
* For the level specified, set the 'not-before' time to 'now+delay',

src/osd/scrubber_common.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,6 @@ struct scrub_schedule_t {
168168
bool operator==(const scrub_schedule_t& rhs) const = default;
169169
};
170170

171-
172-
/// rescheduling param: should we delay jobs already ready to execute?
173-
enum class delay_ready_t : bool { delay_ready = true, no_delay = false };
174-
175171
} // namespace Scrub
176172

177173
namespace fmt {
@@ -522,7 +518,7 @@ struct ScrubPgIF {
522518
*
523519
* Dequeues the scrub job, and re-queues it with the new schedule.
524520
*/
525-
virtual void update_scrub_job(Scrub::delay_ready_t delay_ready) = 0;
521+
virtual void update_scrub_job() = 0;
526522

527523
virtual scrub_level_t scrub_requested(
528524
scrub_level_t scrub_level,

0 commit comments

Comments
 (0)