Skip to content

crimson scrub scheduling - #67806

Merged
liu-chunmei merged 31 commits into
ceph:mainfrom
liu-chunmei:scrub-fsm
Nov 18, 2026
Merged

liu-chunmei merged 31 commits into
ceph:mainfrom
liu-chunmei:scrub-fsm

Conversation

@liu-chunmei

@liu-chunmei liu-chunmei commented Mar 16, 2026 •

Copy link
Copy Markdown
Contributor

crimson: scrub scheduling, reservation and repair

Brings the crimson OSD's scrub up to parity with the classic OSD: periodic
and operator-initiated scheduling, local/remote resource reservation, a full
chunked scrub with the classic error reporting, and repair. Most of the
shared scheduling code under src/osd/scrubber/ is reused rather than
duplicated.

Scrub (core of this PR)

  • Shared code (osd/scrub: make scrub_job, scrubber_common and queue entry
    crimson-aware): scrub_job, scrub_queue_entry and scrub_resources build for
    crimson behind WITH_CRIMSON; scrubber_common.h drops its "#define Scrub"
    macro in favour of namespace usings; not_before_queue_t gets a destructor
    and clear(). scrub_reservations is not shared - crimson has its own
    implementation under src/crimson/osd/scrub/, leaving the classic file
    untouched.
  • Scheduling: per-shard ScrubQueue/ScrubScheduler; osd_max_scrubs is
    enforced OSD-wide, not per shard.
  • Reservations: primary-side replica reservation and release.
  • State machine: inter-chunk PendingTimer (honours osd_scrub_sleep), abort
    on noscrub/nodeep-scrub, WaitDigestUpdate, stale-event discard.
  • Validator: snapset, digest and per-replica evaluation matching classic
    ScrubBackend, with error counts and log lines that match classic.
  • PGScrubber: chunk scan, error store (keyed by full object id), SCRUBLS
    (rados list-inconsistent-*), stat-mismatch accounting ordered as in
    classic _scrub_finish(), repair, snap-mapper validation.
  • Write/scan races: the scrubber is notified only when a write is durable;
    out-of-order commits on multi-shard OSDs are handled.
  • Admin/metrics: scrub, deep-scrub, schedule-*, scrub_metrics, dump_scrubs,
    dump_scrub_reservations; Seastar metrics rather than perf counters.

Known limitation

Erasure-coded pools are not scrubbed. chunk_validation_policy_t still
hardwires is_ec() to false and logical_to_ondisk_size() to the identity,
where classic derives the on-disk size from the pool's stripe info. On an EC
pool each shard holds a chunk whose size is unrelated to the object's
logical size, so every object is reported as damaged. Until the validator
understands EC geometry, EC PGs are not registered for scrubbing at all.

Test support

  • qa/standalone/crimson-scrub/: crimson variants of the scrub standalone
    suites (the classic suites are untouched); ceph-helpers.sh crimson
    support.
  • crimson_scrub_test / crimson_repair_test teuthology tasks;
    test_crimson_scrub unit tests.
  • seastore read-error / EIO injection (seastore_debug_inject_read_err),
    crimson-objectstore-tool omap/snapset ops, admin truncobj/setomap*.

Not scrub-specific, but relative to scrub test case or found scrub-error report.

  • crimson/common/errorator: assert_failure redesign
  • crimson/os: shard::stat returns stat_ertr
  • crimson/os/seastore: four correctness fixes
  • crimson/osd: backfill/recovery durability, pgnls fix, remove_pg_mapping
    crash with smp > store shards
  • classic osd/PeeringState: clamp trim_to to the local log head

Testing

  • make check, unittest_crimson_scrub
  • crimson-scrub standalone suites on seastore
  • teuthology: crimson-rados/basic scrub and repair tasks

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@ronen-fr ronen-fr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some notes and comments.
Essentially - looks good.

Comment thread src/crimson/osd/scrub/pg_scrubber.cc Resolved
DEBUGDPP("scheduling scrub job with OSD {}", pg, *m_scrub_job);
pg.shard_services.get_scrub_scheduler().enqueue_scrub_job(*m_scrub_job);
m_scrub_job->set_both_targets_queued();
pg.publish_stats_to_osd();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this line, as Sam had redesign the updates. A point to verify.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please point out where is Sam's redesign for updates?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sam has explicitly divided the stats into two groups: the ones validated by the scrubber, and the ones that are only computed and updated. See foreach_scrub_maintained_stat().
And - not sure if relevant here. Let me see further.

@liu-chunmei liu-chunmei Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Crimson splits the stats into two disjoint groups, and each group is updated at a different time and place.
Checked: foreach_scrub_checked_stat
Maintained: foreach_scrub_maintained_stat

Checked stats: kept up to date online by the I/O path, and only verified by scrub
Maintained stats: written only by scrub
PG::publish_stats_to_osd() publishes both groups. It doesn't select between them, and it doesn't compute or update either one.


// The publishing here is required for tests synchronization.
// The PG state flags were modified.
pg.publish_stats_to_osd();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here. Need to understand this better.

Comment thread src/crimson/osd/scrub/pg_scrubber.cc Resolved
Comment thread src/common/not_before_queue.h Resolved
Comment thread src/crimson/osd/scrub/pg_scrubber.h Outdated
@@ -105,9 +160,20 @@ class PGScrubber : public crimson::BlockerT<PGScrubber>, ScrubContext {
private:
DoutPrefixProvider &get_dpp() final { return dpp; }

void schedule_scrub_with_osd() final;

@ronen-fr ronen-fr Apr 5, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use 'final override'.

My mistake. Following discussions with Kefu:

  • make sure derivative member functions do not have 'virtual' specification;
  • if the class itself is 'final' - mark the member functions as either 'override' (my pref, as this is what you are trying to convey) or 'final' (less optimal to my taste).
  • otherwise - if the member function itself should be 'final' - mark it so. 'override' in the general case.

Comment thread src/crimson/osd/scrub/pg_scrubber.h Outdated
};

} // namespace crimson::osd::scrub
#include <fmt/format.h>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move upward?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

Comment thread src/crimson/osd/scrub/scrub_machine.h Outdated
get_scrub_context().schedule_scrub_with_osd();
}
~PrimaryActive() {
//get_scrub_context().rm_from_osd_scrubbing();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

}
return false;
}
//adjust this part

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the reactor busy checking is so simple, I am thinking to adjust it later but seems not needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove busy checking.

@github-actions github-actions Bot added the tests label Apr 6, 2026
@liu-chunmei
liu-chunmei force-pushed the scrub-fsm branch 3 times, most recently from c75248b to e69197f Compare April 7, 2026 10:51
@liu-chunmei
liu-chunmei force-pushed the scrub-fsm branch 5 times, most recently from a2772e2 to eeba657 Compare April 10, 2026 04:37
@liu-chunmei
liu-chunmei requested a review from a team as a code owner April 16, 2026 13:39
@Matan-B Matan-B mentioned this pull request May 3, 2026
14 tasks
@liu-chunmei

Copy link
Copy Markdown
Contributor Author

teuthology test :
https://pulpito.ceph.com/liucm-2026-04-16_22:28:24-crimson-rados-wip-liucm-scrub-fsm-rebase-crimson-only-distro-default-trial/
there are some known issues, see below:

156528 156549 156577 156699 abort(seastore device size setting is too small) https://tracker.ceph.com/issues/75599
156578 journal::RecordSubmitter::wait_available()
156582 156636 abort() unexpected enospc: No space left on device  https://tracker.ceph.com/issues/75598
156620 156622 156651 156652 156668 156682 ceph_assert(!ps->needs_recovery()) https://tracker.ceph.com/issues/70501
156662 abort(unexpected enoent error)  https://tracker.ceph.com/issues/74982

156552 156650 mon.a (mon.0) 206 : cluster [ERR] Health check failed: 1 scrub errors (OSD_SCRUB_ERRORS)" in cluster log osd_pg_splitting. fixed and retest: https://pulpito.ceph.com/liucm-2026-04-23_04:10:39-crimson-rados-wip-liucm-scrub-fix-test-crimson-only-distro-default-trial/

@Matan-B Matan-B added this to Crimson May 5, 2026
@Matan-B Matan-B moved this to Awaits review in Crimson May 5, 2026
@Matan-B
Matan-B requested a review from ronen-fr May 5, 2026 10:26
@Matan-B

Matan-B commented May 5, 2026

Copy link
Copy Markdown
Contributor

@ronen-fr, I think latest comments were addressed, could you please take another look? Thanks!

@ronen-fr ronen-fr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost done. One issue that remains is that of the 'scrub-resource' allocation.
(and some nits / taste notes)

Comment thread src/common/not_before_queue.h Resolved
Comment thread src/osd/scrubber/scrub_job.cc Resolved
Comment thread src/osd/scrubber/scrub_resources.cc Resolved
Comment thread src/osd/scrubber/scrub_job.cc Resolved
Comment thread src/osd/scrubber_common.h
} // namespace Scrub


#ifndef WITH_CRIMSON
/**
* The interface used by the PG when requesting scrub-related info or services

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder about this design decision. Why not leave the separation between the two? theoretically - it helps with unit-testing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ronen-fr could you please explain more? I am not very understanding of it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have removed ScrubPgIF - which was an opaque interface between the PG and the Scrubber.
Its utility may be debated - but it is easier to write unit-tests when you can easily mock one side of an interface by just mocking the published API.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have removed ScrubPgIF - which was an opaque interface between the PG and the Scrubber. Its utility may be debated - but it is easier to write unit-tests when you can easily mock one side of an interface by just mocking the published API.

Sam doesn't use ScrubPgIF for PgScrubber class, so I comment it out. could you show me which Unit-test use it? I didn't meet this problem for crimson test. Thanks!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None, I think. It was always on the to-do list. But without it - no chance of ever separating the unit-testing of the two. And - it's a good design decision.
Anyway - I do not wish to postpone the merging of this PR any longer. We can re-instate it later on, if we consider it important enough.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, keep it as it now.

Comment thread src/crimson/osd/scrub/pg_scrubber.cc Resolved
Comment thread src/crimson/osd/scrub/pg_scrubber.cc Resolved
Comment thread src/crimson/osd/shard_services.h Resolved
Comment thread src/osd/scrubber/scrub_job.cc Resolved
Comment thread src/osd/scrubber/scrub_job.cc Resolved
Add the crimson side of scrub scheduling.

ScrubQueue keeps the per-PG scrub jobs in a not_before_queue_t ordered by
their next scheduled time, and ScrubScheduler picks the next eligible PG
and hands it to that PG's scrub state machine.  ShardServices owns the
scheduler and exposes it to the PGs, which register and unregister their
scrub job over the PG lifecycle.

common/not_before_queue frees the dynamically allocated entries in its
destructor and gains a clear() method, so tearing down a queue that still
holds jobs no longer leaks them.

Unit tests for the scheduling logic are included.

Signed-off-by: chunmei liu <[email protected]>
Implement the primary side reservation of replica scrub resources.

The scrub state machine asks every acting-set replica for a scrub
reservation before a chunk is scanned, and releases the reservations when
the scrub ends or is aborted.  ShardServices tracks the local reservation
budget through the shared scrub_reservations/scrub_resources code, so a
crimson OSD honours osd_max_scrubs the same way the classic OSD does.

Signed-off-by: chunmei liu <[email protected]>
Add a ScrubMetrics class built on Seastar native metrics to replace the
classic OSD perf counters, wire it into scrub_reservations.cc, and add the
DumpScrubsHook and DumpScrubReservationsHook admin-socket commands.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
Teach the standalone test helpers to bring up a crimson-osd/seastore
cluster and to drive crimson-objectstore-tool instead of the classic
ceph-objectstore-tool.

- add crimson_standard_scrub_cluster next to standard_scrub_cluster.
- retry 'ceph tell osd.N flush_pg_stats': after objectstore_tool()
  restarts a crimson OSD, wait_for_osd only checks that the osdmap lists
  it as up, which happens as soon as the OSD sends its boot message.  The
  OSD may refuse 'ceph tell' for a short while after that, and
  flush_pg_stats() would silently skip it and clobber the caller's $osd.
- fix a stray '>&2 &' that backgrounded a diagnostic.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
…ndalone tests

Add qa/standalone/crimson-scrub/ holding crimson/seastore variants of the
classic scrub standalone suites: osd-scrub-test, osd-recovery-scrub,
osd-scrub-repair, osd-scrub-snaps, osd-unexpected-clone, osd-scrub-dump
and osd-mapper.

They live in their own directory rather than next to the classic scripts
so that the classic standalone suite is unaffected.
README-crimson-vs-classic.md records where crimson behaviour intentionally
differs from the classic OSD and why.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
clone_range() and remove_mappings_in_range() are C++20 coroutines.  When
they are defined inline in transaction_manager.h the compiler generated
coroutine frames need external linkage so they can be deduplicated across
translation units, which the previous assert_failure formulation did not
allow.  Redesign assert_failure along the same lines as assert_all so the
coroutine frames keep external linkage, and update the seastore and tools
call sites accordingly.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
…tion tests

Add the seastore_debug_inject_read_err option and make seastore honour
debug_data_eio, so that the standalone scrub and repair tests can inject
read errors and exercise the corrupted-object paths without having to
physically damage the store.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
Extend crimson-objectstore-tool with the omap and snapset operations the
scrub standalone tests rely on, so they can inspect and corrupt objects on
a seastore OSD the way ceph-objectstore-tool does on a classic one.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
Return an errorated future from FuturizedStore::Shard::stat() instead of
asserting internally, so callers - and in particular the scrub tests - can
see which error actually occurred.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
Add per-PG 'scrub', 'deep-scrub', 'schedule-scrub', 'schedule-deep-scrub'
and 'scrub_metrics' admin socket commands, so a scrub can be triggered on
demand and the scrub metrics dumped, mirroring what the classic OSD
exposes.

Also watch the scrub related config options at runtime: when one of them
changes, the change is broadcast to every shard and the scheduling targets
of the already registered scrub jobs are recomputed.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
…gestUpdate states

Restructure the crimson scrub state machine.

- Introduce a PendingTimer state between chunks so osd_scrub_sleep is
  honoured.
- Add abort_t and internal_sched_scrub_t events so a scrub can be aborted
  mid-flight when the noscrub / nodeep-scrub flags are set.
- Add a WaitDigestUpdate state, remove notify_scrub_end() and add
  clear_pgscrub_state() to the scrub context.
- Discard stale async completions: when on_interval_change() fires reset_t
  and the machine falls back to Inactive, in-flight async operations
  (ScrubSleep, ScrubFindRange, ScrubReserveRange, ScrubScan,
  ScrubDigestUpdate and the replica ScrubScan) may still complete and post
  their events into a machine that has moved on.  Drop those events in
  Inactive and PrimaryActive instead of acting on them.
- Serialize replacement scrub reservations, and stop calling
  get_scrub_context() from destructors run during machine teardown.
- Run the scrub async operations through the mclock scheduler.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
…lica evaluation

Bring the crimson scrub validator up to parity with the classic
ScrubBackend.

- Evaluate SnapSet consistency and emit classic-compatible log lines,
  collected in snapset_log_messages so pg_scrubber can replay them in the
  same order as the classic scrubber.
- Evaluate non-primary shards separately: replica SnapSet corruptions are
  reported for visibility but are not counted twice, as they are already
  captured as SNAPSET_INCONSISTENCY on the object.
- Digest handling: distinguish "object_info has no digest at all", where
  the digest is always written back, from "object_info records a different
  digest", where it is only written back during repair.  Only fix digests
  of objects that are otherwise consistent, and implement the classic
  fix_digest (ROBJ17) path where every replica agrees on the data digest
  but object_info disagrees.
- Report a cluster-log WARN for large omap objects.
- Count deep errors before shallow ones when tallying
  num_shallow_scrub_errors / num_deep_scrub_errors, so an entry carrying
  both is attributed the way the classic OSD attributes it.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
Fill in the parts of PGScrubber that were still stubs, so that a crimson
OSD can run a full scrub, report the result and repair what it found.

- Chunk scanning, result emission and the store of scrub errors, keyed and
  sorted by full object key (pool, hash, snap) as the classic scrubber
  does, so get_store_errors() and emit_scrub_result() agree with classic
  output.
- Repair: pick an authoritative shard, and cope with the case where the
  validator flagged OMAP_DIGEST_MISMATCH_INFO or DATA_DIGEST_MISMATCH_INFO
  on that very shard after it had been chosen.  Gate recovery and repair
  completion on the number of objects actually repaired, and correct the
  repair condition check so that an after-repair scrub is only scheduled
  when there were repairable errors.
- Stat mismatches: do the stat-mismatch accounting before the repair
  reconciliation check, as PrimaryLogScrub::_scrub_finish() does, and stop
  reporting a pure stat mismatch as a scrub error raising
  OSD_SCRUB_ERRORS.
- In recovery_completed(), replace only the deep target in the scrub queue
  instead of resetting the queue flags.
- Populate pg_stat_t::scrub_sched_status from PG::publish_stats_to_osd().
- Add the scrubdebug admin socket command and a sessions counter.
- Terminate the scrub state machine in ~PGScrubber() to avoid a
  use-after-free during PG teardown, and use override rather than final.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
…est tracking

Validate and repair the snap mapper during scrub, and add the object
inspection paths the snap tests need.

- Introduce the ScrubSnapMapperRepair async operation, spawned by
  scan_snaps().  All blocking KV I/O runs inside interruptor::async, off
  the reactor thread.  ScrubScan::run() calls scan_snaps() on every shard.
- Implement CEPH_OSD_OP_SCRUBLS so that 'rados list-inconsistent-obj' and
  'rados list-inconsistent-snapset' work: PG::do_scrub_ls() decodes
  scrub_ls_arg_t, calls get_store_errors() and encodes scrub_ls_result_t.
- Track FLAG_DIRTY and the CRC-32c data/omap digests on write, writefull,
  write_same and append, matching how the classic OSD populates
  object_info_t, and fix apply_stats() ordering.
- Handle a corrupted object gracefully during snap trim: set
  PG_STATE_SNAPTRIM_ERROR and stop trimming rather than crashing.
- object_context_loader: detect obcs whose load previously failed
  (loading_started set but is_loaded() false) and obcs with a null ssc,
  and return object_corrupted instead of proceeding.
- Use with_store() for the cross-shard store calls on these paths.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
…very

In PeeringState::Backfilling::react(const Backfilled&), if ps->needs_recovery()
is true, transit to WaitLocalRecoveryReserved to resume log recovery for any
remaining missing objects rather than transitioning directly to Recovered.

For classic OSD, PrimaryLogPG only posts Backfilled after checking that
needs_recovery() is false, making this a no-op there.  For Crimson (and any
engine where backfill and log recovery are separate asynchronous processes),
backfill may complete while log recovery is still required, so PeeringState
must verify needs_recovery() before marking the PG Recovered.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
… scrubber

A scrub chunk scan must not run against objects whose writes are still in
flight, and the recovery paths were not feeding the scrubber the
information it needs.

- Propagate is_repair through recovery: on_local_recover() takes it as a
  parameter, on_global_recover() increments num_objects_repaired, and
  all_replicas_recovered() notifies the scrubber so an after-repair deep
  scrub can be scheduled.  PGRecoveryListener gains inc_osd_stat_repaired().
- Notify the scrubber once backfill and recovery writes are durable, not
  when they are merely queued, so await_update() can rely on
  last_applied_durable.
- Do not ship a real repop to a backfill target until the corresponding
  push has actually landed: last_backfill_started is advanced when a push
  is enqueued, not when it has been received.
- Do not ship a real repop carrying a new clone to a peer that is still
  missing the head object.
- Initialize split statistics before activating the child PGs, so a scrub
  can never observe partially initialized stats.
- Discard stale logmissing requests and preserve their ordering with the
  throttle.
- Fix a dangling hoid reference captured by the submit_transaction
  continuation: hoid is bound to obc->obs.oi.soid and obc only lives
  inside the coroutine frame.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
prepare_stats_for_publish() can dirty the PeeringState (the
vulnerability/rebuild latch transitions mark info dirty), but crimson's
PG::publish_stats_to_osd() never flushed it.  The change then sat in
memory until some unrelated write_if_dirty() happened to run, so it
could be lost across a restart.

Mirror classic PG::publish_stats_to_osd():

 - If this call did not newly dirty the state, return as before.
 - If a peering event is being dispatched, defer to it.  The dispatch
   calls write_if_dirty() on rctx.transaction, which complete_rctx()
   submits.  A new PG's collection-creation transaction can still be
   pending in that rctx, so a standalone transaction issued here could
   reach the store before it and hit a missing collection.
 - Otherwise (e.g. an op completion callback, which has no transaction
   in flight) call write_if_dirty() on a fresh transaction and submit
   it.  The write is fire-and-forget, as in classic and as
   do_delete_work() already does in crimson.

Crimson never set PeeringState's dispatching_peering_event flag, so set
it around the dispatch points that flush through rctx:
PG::do_peering_event() and PG::handle_initialize() (which is followed
by handle_activate_map() in the same rctx).  PeeringState::advance_map()
and activate_map() already set it themselves.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
…og tests

Refactor test_crimson_scrub around the reworked validator and state
machine, and add coverage for the missing-digest write-back and for the
classic-compatible snapset log messages.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
…commands

Add the truncobj, setomapval, rmomapkey and setomapheader OSD admin socket
commands, so the standalone scrub tests can mutate objects on a running
crimson OSD the way they do through ceph-objectstore-tool on a classic one.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
Fix the namespace comparison in the PGNLS handler, which made the listing
skip or include the wrong objects.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
Add the crimson_scrub_test and crimson_repair_test teuthology tasks, the
yaml files that drive them under qa/suites/crimson-rados/basic/tasks, and
a crimson-rados/standalone suite that runs the crimson scrub standalone
scripts.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
Three related races between a scrub chunk scan and concurrent writes.

- PG::log_operation() signalled scrubber.on_log_update() as soon as the
  log entries were appended to the in-memory and projected pg log, before
  the ObjectStore transaction had been submitted and committed.  A scan
  could then read an object whose write was not on disk yet and report a
  spurious OSD_SCRUB_ERRORS.
- ScrubReserveRange reported the newest update in the reserved range, but
  the primary never waited for it: search the projected log first, as
  classic search_log_for_updates() does, fall back to the committed log,
  and await_update() that version before scanning.
- In a multi-shard OSD (crimson_cpu_num > 1) rep-op transactions for the
  same PG are submitted from different fibers and can commit out of
  version order, so a higher-versioned transaction completing first could
  release an await_update() waiting on a lower version.  Track the
  committed versions rather than assuming monotonic completion.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
When emit_scrub_result() finds a mismatch between the stats scrub
recomputed and the ones the PG maintains, it repairs (or silently
fixes) pg_stats by assigning the whole object_stat_sum_t:

    pg_stats.stats.sum = in_stats;

Classic does the same with m_scrub_cstat, but there the collection only
ever holds the checked stats.  In crimson in_stats is the whole
Scrubbing::stats, which also carries the scrub-maintained members, and
the assignment replaces everything in pg_stats:

 - num_rd, num_wr, num_rd_kb, num_wr_kb and the other counters that
   scrub does not track are reset to zero.
 - On a shallow scrub, in_stats has num_deep_scrub_errors, num_omap_*
   and num_large_omap_objects at zero because only a deep scrub
   computes them.  Step 2 skips those members for shallow scrubs
   (skip_for_shallow), so the zeros stay and the values recorded by the
   last deep scrub are lost.  Only the deep_errors_cleared path is
   supposed to clear the deep error count.

Copy only the members visited by foreach_scrub_checked_stat() and clear
the *_invalid flags, via a local helper used by both the repair and the
no-object-errors paths.  The scrub-maintained group continues to be
updated solely by foreach_scrub_maintained_stat() in step 2.

The pg_stats.stats_invalid branch at the top of emit_scrub_result() is
left alone; it mirrors classic's replacement of stats on an invalid PG.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
Four independent seastore bugs that the crimson scrub and repair testing
exposed.

- Advance the iterator past the current mapping in the demote loop.  It
  re-processed the same LBA mapping indefinitely, a plausible contributor
  to the corrupted cold-tier space accounting that tripped a ceph_assert.
- rewrite_extents() asserted that an extent is not mid-IO right after
  fetching its transactional view; wait for the in-flight IO instead.
- Make the SETALLOCHINT log-omap initialization idempotent.
- Maintain coll_map in SeaStore::Shard.  _get_collection(cid) used to
  return a freshly allocated SeastoreCollection on every call, so separate
  instances for the same coll_t bypassed the pending_txns FIFO and the
  collection_in_flight gate, letting transactions for one collection run
  run_one_batch() concurrently and commit to the journal out of order.
  Look up the canonical collection instead, route
  do_transaction_no_callbacks() through it, and drop it from coll_map in
  _remove_collection().
- test_seastore: treat ENOENT as an expected error.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
When the OSD runs with more reactor shards than store shards,
get_or_create_pg_mapping() assigns PGs to 'alien' cores whose IDs exceed
store_shard_nums - 1.  remove_pg_mapping() did not apply the same
assignment formula and looked the PG up on the wrong core, crashing.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
handle_pull_response() treats a push op with version == eversion_t() as
"the replica doesn't have the object", calls on_failed_recover() and then
throws std::runtime_error.

RecoverySubRequest::with_pg() wraps the call in with_interruption(), whose
handler is installed via handle_interruption() and therefore only sees
interruption exceptions.  A std::runtime_error escapes it and kills the
recovery operation with an unhandled exception.

Classic ReplicatedBackend::handle_pull_response() calls _failed_pull() and
simply returns; recovery then retries the object from another shard or
eventually marks it unfound.  Do the same: log the failure, call
on_failed_recover() to mark the object missing on the sending peer, and
co_return.

on_failed_recover() does not resolve the 'pulled' promise that
maybe_pull_missing_obj() is waiting on, so also call repeat_pull() on the
recovery waiter.  It completes that wait with eagain, so the puller retries
(picking another shard, since the peer is now marked missing) instead of
hanging until the next peering interval.  Classic gets the same effect via
_failed_pull() -> on_failed_pull() + clear_pull().

This matters now that the crimson pull path answers a failed stat with a
blank push op, as classic does, rather than asserting: the blank op is the
normal way to say "I no longer have this object", and must not take the
recovery operation down on the receiving side.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: Claude code
repeat_pull() fails the 'pulled' shared_promise with eagain but leaves
it in place.  The retry in maybe_pull_missing_obj() then calls
wait_for_pull(), which only creates a new promise when 'pulled' is
empty, so it gets back the already-failed future and immediately fails
with eagain again.  repeat_eagain spins, sending a new MOSDPGPull on
every pass, and is_pulling() stays true.

Reset the promise after failing it, as interrupt() and stop() do, so
the retry waits on a fresh one.

This affects both callers: check_recovery_sources() when the pull
source OSD goes down, and handle_pull_response() when the source
reports it does not have the object.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
ScrubContext::notify_scrub_end() is a defaulted no-op and PGScrubber no
longer overrides it, so the call from Scrubbing::exit() does nothing.

PG::initiate_snap_trim() refuses to start while PG_STATE_SCRUBBING is set,
and the only kick_snap_trim() left is at the end of emit_scrub_result() -
the success path.  A scrub that ends any other way (noscrub set mid-scrub,
a replica rejecting its reservation, verify_against_abort(), an interval
change) therefore leaves a non-empty snap_trimq with nothing to restart it,
stalling snap trim until the next on_active_actmap().

clear_pgscrub_state() also clears the scrub-state flags without publishing,
so they stay visible to mgr and mon until some unrelated publish happens.

Restore the override: clear PG_STATE_SCRUBBING and PG_STATE_DEEP_SCRUB,
publish the stats and kick snap trim.  Scrubbing::exit() runs on the success
path too, where kicking twice is harmless.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: Claude code
…spended

PGScrubber::start_scrub() suspends in reserve_local() while it asks every
shard for the current scrub count.  If an interval change followed by
re-activation to active+clean completes in that window, then
PrimaryActive::exit() unregisters the PG (rm_from_osd_scrubbing()) and the
new PrimaryActive constructor registers it again
(schedule_scrub_with_osd() -> update_scrub_job() ->
set_both_targets_queued()), so both targets are already queued with fresh
schedules.

When start_scrub() resumes, the PG is registered, so the is_registered()
check in requeue_penalized() passes, and the call then trips
ceph_assert(!trgt.queued).  Both the "failed to reserve locally" path and
the "interval/state changed across suspension" path are affected.

Make requeue_penalized() return early if the target of the requested level
is already queued.  The fresh targets keep the schedule given to them by
the re-registration instead of being penalized, and the sister target is
left alone as well.  Callers that do not suspend always see queued == false
(start_scrub() clears it on entry), so their behaviour is unchanged.

In start_scrub() itself, also sample whether the interval changed right
after reserve_local() resumes, and skip requeue_penalized() in both
affected paths when it did: the target we popped is then no longer ours
to requeue.  Without an interval change the job was not re-registered,
so the target is still ours and is requeued with a penalty as before.
The state-changed path therefore always uses delay_cause_t::pg_state.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: IBM Bob
…nings

Two related changes to crimson_fio_restart and the crimson overrides.

1. Assert that the PGs actually re-peer.

ceph.restart only used wait-for-osds-up, which checks the osdmap marks the
OSDs up - it says nothing about the PGs.  A run showed 18 PGs reported
"stuck inactive since forever, last acting []" shortly after a restart, and
the only reason we know they recovered is that the following fio wrote
382MiB with err=0 and 73 PGs later reported fresh scrub stamps.  That is
circumstantial.

Add "ceph.healthy: {wait-for-healthy: false}" after each restart.  It waits
for every PG to reach active+clean and dumps the ones that do not before
failing, so a peering regression is caught directly instead of being
inferred.  wait-for-healthy is left off on purpose: wait_until_healthy()
does not honour log-ignorelist - it only tolerates muted checks and
expected_checks - so requiring HEALTH_OK would trip over unrelated warnings
such as POOL_APP_NOT_ENABLED.

2. Stop ignoring scrub-overdue warnings.

d98e84a ("qa/crimson: ignore PG_NOT_DEEP_SCRUBBED in all crimson
tests") added that entry because crimson had no scrub scheduling, so
last_deep_scrub_stamp stayed at epoch 0 for every PG.  It carried a \todo
to delete it once scrub scheduling was enabled, which is what this series
does, and the premise no longer holds: the mon now reports real stamps for
every PG it has stats for, and 0.000000 only for PGs whose state it does
not know.

What remains is that crimson_fio_restart queries health while the OSDs are
still coming back, when the mon has no stats for most PGs (that run
reported 87.671% pgs unknown) and logs both PG_NOT_SCRUBBED and
PG_NOT_DEEP_SCRUBBED; one job failed on the former.  ceph.restart already
wraps the restart in suppress_mon_health_to_clog but only when the task
asks, so set mon-health-to-clog there and drop the blanket ignorelist
entry.  A PG that genuinely stops being scrubbed now fails the job.

Signed-off-by: chunmei liu <[email protected]>
Assisted-by: Claude code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Awaits review

Development

Successfully merging this pull request may close these issues.

4 participants