Skip to content

Commit 569c07f

Browse files
committed
osd/scrub: manage queue registration lifetime in the FSM
As the state of 'being registered in the OSDs scrub queue' corresponds to the PrimaryActive FSM state. Signed-off-by: Ronen Friedman <[email protected]>
1 parent bde52eb commit 569c07f

File tree

7 files changed

+23
-32
lines changed

7 files changed

+23
-32
lines changed

src/osd/PG.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1847,7 +1847,6 @@ void PG::on_activate(interval_set<snapid_t> snaps)
18471847
snap_trimq = snaps;
18481848
release_pg_backoffs();
18491849
projected_last_update = info.last_update;
1850-
m_scrubber->on_pg_activate(m_planned_scrub);
18511850
}
18521851

18531852
void PG::on_replica_activate()

src/osd/PrimaryLogPG.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12879,8 +12879,7 @@ void PrimaryLogPG::on_shutdown()
1287912879
osd->clear_queued_recovery(this);
1288012880
}
1288112881

12882-
m_scrubber->scrub_clear_state();
12883-
m_scrubber->rm_from_osd_scrubbing();
12882+
m_scrubber->on_new_interval();
1288412883

1288512884
vector<ceph_tid_t> tids;
1288612885
cancel_copy_ops(false, &tids);

src/osd/scrubber/pg_scrubber.cc

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -460,14 +460,12 @@ void PgScrubber::on_new_interval()
460460
(is_primary() ? "Primary" : "Replica/other"),
461461
is_scrub_active(), is_queued_or_active())
462462
<< dendl;
463-
464463
m_fsm->process_event(IntervalChanged{});
465464
// the following asserts were added due to a past bug, where PG flags were
466465
// left set in some scenarios.
467466
ceph_assert(!is_queued_or_active());
468467
ceph_assert(!state_test(PG_STATE_SCRUBBING));
469468
ceph_assert(!state_test(PG_STATE_DEEP_SCRUB));
470-
rm_from_osd_scrubbing();
471469
}
472470

473471
bool PgScrubber::is_scrub_registered() const
@@ -493,35 +491,31 @@ void PgScrubber::rm_from_osd_scrubbing()
493491
}
494492
}
495493

496-
void PgScrubber::on_pg_activate(const requested_scrub_t& request_flags)
494+
/*
495+
* Note: referring to m_planned_scrub here is temporary, as this set of
496+
* scheduling flags will be removed in a followup PR.
497+
*/
498+
void PgScrubber::schedule_scrub_with_osd()
497499
{
498500
ceph_assert(is_primary());
499-
if (!m_scrub_job) {
500-
// we won't have a chance to see more logs from this function, thus:
501-
dout(2) << fmt::format(
502-
"{}: flags:<{}> {}.Reg-state:{:.7}. No scrub-job", __func__,
503-
request_flags, (is_primary() ? "Primary" : "Replica/other"),
504-
registration_state())
505-
<< dendl;
506-
return;
507-
}
501+
ceph_assert(m_scrub_job);
508502

509-
ceph_assert(!is_queued_or_active());
510503
auto pre_state = m_scrub_job->state_desc();
511504
auto pre_reg = registration_state();
512505

513506
auto suggested = m_osds->get_scrub_services().determine_scrub_time(
514-
request_flags, m_pg->info, m_pg->get_pgpool().info.opts);
507+
m_planned_scrub, m_pg->info, m_pg->get_pgpool().info.opts);
515508
m_osds->get_scrub_services().register_with_osd(m_scrub_job, suggested);
516509

517510
dout(10) << fmt::format(
518511
"{}: <flags:{}> {} <{:.5}>&<{:.10}> --> <{:.5}>&<{:.14}>",
519-
__func__, request_flags,
512+
__func__, m_planned_scrub,
520513
(is_primary() ? "Primary" : "Replica/other"), pre_reg,
521514
pre_state, registration_state(), m_scrub_job->state_desc())
522515
<< dendl;
523516
}
524517

518+
525519
void PgScrubber::on_primary_active_clean()
526520
{
527521
dout(10) << fmt::format(
@@ -2177,11 +2171,7 @@ void PgScrubber::handle_query_state(ceph::Formatter* f)
21772171
PgScrubber::~PgScrubber()
21782172
{
21792173
m_fsm->process_event(IntervalChanged{});
2180-
if (m_scrub_job) {
2181-
// make sure the OSD won't try to scrub this one just now
2182-
rm_from_osd_scrubbing();
2183-
m_scrub_job.reset();
2184-
}
2174+
m_scrub_job.reset();
21852175
}
21862176

21872177
PgScrubber::PgScrubber(PG* pg)

src/osd/scrubber/pg_scrubber.h

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

253253
void rm_from_osd_scrubbing() final;
254254

255-
void on_pg_activate(const requested_scrub_t& request_flags) final;
255+
void schedule_scrub_with_osd() final;
256256

257257
scrub_level_t scrub_requested(
258258
scrub_level_t scrub_level,

src/osd/scrubber/scrub_machine.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ PrimaryActive::PrimaryActive(my_context ctx)
123123
{
124124
DECLARE_LOCALS; // 'scrbr' & 'pg_id' aliases
125125
dout(10) << "-- state -->> PrimaryActive" << dendl;
126+
// insert this PG into the OSD scrub queue. Calculate initial schedule
127+
scrbr->schedule_scrub_with_osd();
126128
}
127129

128130
PrimaryActive::~PrimaryActive()

src/osd/scrubber/scrub_machine_lstnr.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ struct ScrubMachineListener {
107107

108108
[[nodiscard]] virtual bool is_primary() const = 0;
109109

110+
/// dequeue this PG from the OSD's scrub-queue
111+
virtual void rm_from_osd_scrubbing() = 0;
112+
113+
/**
114+
* the FSM has entered the PrimaryActive state. That happens when
115+
* peered as a Primary, and achieving the 'active' state.
116+
*/
117+
virtual void schedule_scrub_with_osd() = 0;
118+
110119
virtual void select_range_n_notify() = 0;
111120

112121
/// walk the log to find the latest update that affects our chunk

src/osd/scrubber_common.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -409,12 +409,6 @@ struct ScrubPgIF {
409409
*/
410410
virtual bool reserve_local() = 0;
411411

412-
/**
413-
* if activated as a Primary - register the scrub job with the OSD
414-
* scrub queue
415-
*/
416-
virtual void on_pg_activate(const requested_scrub_t& request_flags) = 0;
417-
418412
/**
419413
* Recalculate the required scrub time.
420414
*
@@ -431,8 +425,6 @@ struct ScrubPgIF {
431425
*/
432426
virtual void handle_scrub_reserve_msgs(OpRequestRef op) = 0;
433427

434-
virtual void rm_from_osd_scrubbing() = 0;
435-
436428
virtual scrub_level_t scrub_requested(
437429
scrub_level_t scrub_level,
438430
scrub_type_t scrub_type,

0 commit comments

Comments
 (0)