Repository navigation
umbrella: crimson/osd: guard recovery clone overlap with try_lock_for_read - #70197
Merged
Merged
Conversation
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)
Contributor
There was a problem hiding this comment.
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
RecoveryCloneLockManagerand wires it through push/pull recovery so clone-overlap candidates are selected only whentry_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. |
Contributor
|
This PR has been added to wip-yuri8-testing-20260721.164157-umbrella. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
backport tracker: https://tracker.ceph.com/issues/78095
backport of #69668
parent tracker: https://tracker.ceph.com/issues/76499
this backport was staged using ceph-backport.sh version 16.0.0.6848
find the latest version at https://github.com/ceph/ceph/blob/main/src/script/ceph-backport.sh