Skip to content

os/bluestore: tolerate corrupted onodes during fsck/repair - #69756

Merged
SrinivasaBharath merged 8 commits into
ceph:mainfrom
emilytl:wip-77325-fsck-corrupted-onode
Aug 22, 2026
Merged

SrinivasaBharath merged 8 commits into
ceph:mainfrom
emilytl:wip-77325-fsck-corrupted-onode

Conversation

@emilytl

@emilytl emilytl commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

BlueStore fsck aborts on the first corrupted onode because decode validation uses ceph_assert. This makes decode failures recoverable for fsck only, leaving the regular I/O path unchanged.

Design: ceph_assert_decode() behaves exactly like ceph_assert by default and only diverges when fsck opts in via an RAII throwing_guard, throwing ceph::buffer::malformed_input so corruption is reported and skipped. Only asserts validating on-disk data were converted; program invariants stay fatal. fsck catches ceph::buffer::error at the object-walk sites, and exception safety was fixed for the newly throwable paths.

Allocation recovery: the post-crash rebuild that scans onodes (read_allocation_from_onodes and its multithreaded OnodeScanMT variant) also tolerates corruption, since that is where a crash-on-corrupt-onode lands at next mount. Tolerance requires an explicit caller opt-in that only read-only fsck requests; mount, repair, and trim stay fatal, because they either persist the rebuilt allocation or use it destructively. The new bluestore_accept_corrupted_onode_recovery option (never / read-only, default read-only) lets an operator disable tolerance entirely.

Unbounded allocations: a corrupt on-disk count can drive an allocation throwing std::bad_alloc/length_error, which slips past the fsck catches. These are now bounds-checked against the remaining buffer.

Tests: CorruptedOnodesTest covers truncated headers, bad struct_v, dangling blob indexes, and missing spanning blobs, with a death test confirming the regular path still crashes. Leak-safety verified under ASan; the decode-count guards have unit tests on a reusable expect_decode_tolerated() helper so bit-flip fuzzing can drop in later. Allocation recovery is covered end to end, single- and multi-threaded, via bluestore_debug_enforce_settings=ssd to reach NCB mode, plus a test that cold_open() (trim's entry point) still aborts where read-only fsck skips.

Out of scope (follow-ups): -EIO removal of unrecoverable objects, framework-wide denc reserve(num) hardening, and two-phase repair.

Fixes: https://tracker.ceph.com/issues/77325

Signed-off-by: Emily Leson [email protected]

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.

@emilytl
emilytl requested a review from a team as a code owner June 26, 2026 01:00
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

16 similar comments
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@timqn22

timqn22 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

ok to test

@ifed01
ifed01 self-requested a review June 29, 2026 11:14
@ifed01

ifed01 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

jenkins test make check

@aclamk

aclamk commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

The problem of decoding has 2 sides:

  1. When the decoding process runs out of data in buffer, it will throw exceptions, specializations of ``ceph::buffer::error`.
  2. When decoding process does see data that it does not expect, it will abort the OSD process.
    https://github.com/ceph/ceph/blob/main/src/os/bluestore/BlueStore.cc#L4163
    https://github.com/ceph/ceph/blob/main/src/os/bluestore/BlueStore.cc#L4172

The solution has to convert asserts to something that will allow either to continue decoding (I discourage that) or abort decoding.
There is a reason why its only fsck that is covered by this feature.
Decoding errors in BlueStore are very infrequent. Adding code to handle errors is relatively doable, but proper testing would be borderline impossible.
Restricting "skipping broken objects" to fsck has the benefit that it will be observed that an OSD crashed and later one can see if fsck was able to repair it.

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

The failure of Onode decoding should be captured and handled in fsck case.
In regular operation case decoding failure should be considered fatal. That is, until we modify the code to handle error cases. The rationale is that we have redundancy; crashed OSD is not a problem, but OSD reporting incorrect state is.

@emilytl

emilytl commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @aclamk, that clarified the intended behavior. I've updated the patch accordingly: extent-map decode asserts now throw buffer::malformed_input, and fsck/repair catches buffer::error during onode decode to log/skip (or remove in repair) and continue. I also added tests covering both truncated-buffer and invalid extent-map version cases.

@emilytl
emilytl requested a review from aclamk June 30, 2026 21:21
@timqn22

timqn22 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

jenkins test api

@emilytl
emilytl force-pushed the wip-77325-fsck-corrupted-onode branch from d37f0b0 to 578564b Compare July 30, 2026 16:51
@emilytl
emilytl requested a review from a team as a code owner July 30, 2026 16:51
@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath5-testing-20260804.033808-main.

@vumrao

vumrao commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

cc @vumrao

@NitzanMordhai

Copy link
Copy Markdown
Contributor

@emilytl can you please check the following test results? /a/skanta-2026-08-05_08:59:01-rados-wip-bharath5-testing-20260804.033808-main-distro-default-trial/432997/teuthology.log

2026-08-05T09:24:29.747 INFO:teuthology.orchestra.run.trial119.stdout:[ RUN ] BlueStore/CorruptedOnodesTest.ColdOpen_StillAssertsOnCorruptOnode/0 2026-08-05T09:24:30.069 INFO:teuthology.orchestra.run.trial119.stdout:/ceph/rpmbuild/BUILD/ceph-21.3.0-1720-g46658843/src/test/objectstore/store_test.cc:12087: Failure 2026-08-05T09:24:30.070 INFO:teuthology.orchestra.run.trial119.stdout:Death test: bs->cold_open() 2026-08-05T09:24:30.070 INFO:teuthology.orchestra.run.trial119.stdout: Result: died but not with expected error. 2026-08-05T09:24:30.070 INFO:teuthology.orchestra.run.trial119.stdout: Expected: contains regular expression "FAILED ceph_assert" 2026-08-05T09:24:30.070 INFO:teuthology.orchestra.run.trial119.stdout:Actual msg: 2026-08-05T09:24:30.070 INFO:teuthology.orchestra.run.trial119.stdout:[ DEATH ] execv(ceph_test_objectstore, ...) in /home/ubuntu/cephtest/archive/ostest failed: No such file or directory 2026-08-05T09:24:30.070 INFO:teuthology.orchestra.run.trial119.stdout: 2026-08-05T09:24:30.070 INFO:teuthology.orchestra.run.trial119.stdout:==> rm -r bluestore.test_temp_dir.ZxlHbU 2026-08-05T09:24:30.071 INFO:teuthology.orchestra.run.trial119.stdout:[ FAILED ] BlueStore/CorruptedOnodesTest.ColdOpen_StillAssertsOnCorruptOnode/0, where GetParam() = "bluestore" (324 ms)

i'll ask to remove that pr from that batch, please re-add needs-qa when the fix ready

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been removed from wip-bharath5-testing-20260804.033808-main.

@emilytl

emilytl commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Fixed the death test failure

@pdvian

pdvian commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

ok to test

@timqn22

timqn22 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

jenkins test make check

@timqn22

timqn22 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

jenkins test make check arm64

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath7-testing-20260811.152323-main.

@ljflores

Copy link
Copy Markdown
Member

@vumrao

vumrao commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

@aclamk @ljflores - let us go ahead and merge it? and I hope we considering it for vampire?

@vumrao

vumrao commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Looks like this one still in @SrinivasaBharath testing?

@Jayaprakash-ibm

Copy link
Copy Markdown
Contributor

@anthonyeleven

Copy link
Copy Markdown
Contributor

/config check ok

@anthonyeleven

Copy link
Copy Markdown
Contributor

The comment above plus directing the config check to re-run cleared that check.

@SrinivasaBharath
SrinivasaBharath merged commit 1efc209 into ceph:main Aug 22, 2026
7 of 8 checks passed
@github-actions

Copy link
Copy Markdown

This is an automated message by src/script/redmine-upkeep.py.

I have resolved the following tracker ticket due to the merge of this PR:

No backports are pending for the ticket. If this is incorrect, please update the tracker
ticket and reset to Pending Backport state.

Update Log: https://github.com/ceph/ceph/actions/runs/32567375514

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.