Skip to content

umbrella: crimson/osd: guard recovery clone overlap with try_lock_for_read - #70197

Merged
batrick merged 1 commit into
ceph:umbrellafrom
knrt10:wip-78095-umbrella
Aug 3, 2026
Merged

batrick merged 1 commit into
ceph:umbrellafrom
knrt10:wip-78095-umbrella

Conversation

@knrt10

@knrt10 knrt10 commented Jul 14, 2026

Copy link
Copy Markdown
Member

Crimson recovery could use a neighbor clone as a clone_subset source
during osd_recover_clone_overlap without checking whether that clone
was safe to read. Classic OSD takes a read lock on the neighbor clone
via try_lock_for_read() before using it.

Under snap trim + recovery stress, recovery could clone_range from a
clone that snap trim was modifying, producing wrong object content
(ceph_test_rados: incorrect buffer at pos 1462272).

calc_clone_subsets() and calc_head_subsets() now return clone overlap
candidates in preference order only. ReplicatedRecoveryBackend locks
the first usable neighbor clone from each list and holds those read
locks until push/pull recovery completes. RecoveryCloneLockManager
releases locks in its destructor so move-assign cannot leak a held
lock and block snap trim.

Fixes: https://tracker.ceph.com/issues/76499
Signed-off-by: Kautilya Tripathi <[email protected]>
(cherry picked from commit 8a73bcf)
Copilot AI review requested due to automatic review settings July 14, 2026 14:42
@knrt10
knrt10 requested a review from a team as a code owner July 14, 2026 14:42
@knrt10 knrt10 added this to the umbrella milestone Jul 14, 2026
@knrt10 knrt10 added the core label Jul 14, 2026
@knrt10
knrt10 requested review from Matan-B and tchaikov July 14, 2026 14:42
@github-actions github-actions Bot added the releng-audit-pass Release engineering: passed backport verification audit. label Jul 14, 2026

Copilot AI 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.

Pull request overview

This backport hardens Crimson replicated recovery’s clone-overlap optimization by ensuring neighbor clones are only used as recovery sources when they can be safely read-locked, preventing races with snap-trim that could otherwise yield incorrect recovered object contents.

Changes:

  • Refactors calc_clone_subsets() / calc_head_subsets() to produce a “clone overlap plan” (ordered candidate lists) rather than directly selecting a clone.
  • Introduces RecoveryCloneLockManager and wires it through push/pull recovery so clone-overlap candidates are selected only when try_lock_for_read() succeeds, and locks are held until recovery completes (or is aborted).
  • Updates existing unit tests to “commit” plans without locking via commit_subsets_unlocked().

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/test/crimson/test_calc_subsets.cc Adapts unit tests to the new “plan + commit” subsets API.
src/crimson/osd/replicated_recovery_backend.h Extends recovery backend interfaces to pass/retain clone-lock state and adds plan-commit hook.
src/crimson/osd/replicated_recovery_backend.cc Implements plan commit with read-lock acquisition, ensures locks are released on completion/error paths, and uses committed subsets for recovery.
src/crimson/osd/recovery_backend.h Adds RecoveryCloneLockManager and stores it in push/pull recovery state.
src/crimson/osd/recovery_backend.cc Releases held clone locks during recovery cleanup.
src/crimson/osd/object_metadata_helper.h Introduces plan/candidate structs and commit_subsets_unlocked(), updates subsets APIs to return plans.
src/crimson/osd/object_metadata_helper.cc Implements plan-building for clone/head subsets and adds unlocked plan commit helper.
src/crimson/osd/object_context.h Adds try_get_read_lock() / put_read_lock() helpers used by the lock manager.

@tchaikov tchaikov 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.

lgtm

@yuriw

yuriw commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to wip-yuri8-testing-20260721.164157-umbrella.

@batrick batrick modified the milestones: umbrella, v21.1.1 Jul 30, 2026
@JonBailey1993

Copy link
Copy Markdown
Contributor

@batrick
batrick merged commit b12c814 into ceph:umbrella Aug 3, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core crimson needs-qa releng-audit-pass Release engineering: passed backport verification audit. tests wip-yuri8-testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants