Skip to content

crimson/seastore/rbm: implement capacity gating and resolve OOL write leakage - #69352

Merged
Matan-B merged 3 commits into
ceph:mainfrom
fultheim:seastore-rbm-stability-fixes
Oct 20, 2026
Merged

Matan-B merged 3 commits into
ceph:mainfrom
fultheim:seastore-rbm-stability-fixes

Conversation

@fultheim

@fultheim fultheim commented Jun 9, 2026 •

Copy link
Copy Markdown
Contributor

RBM capacity management and stability fixes. #69275 and #69351, which this PR depended on, have merged; the branch is rebased onto current main. Three commits:

  1. Deferred frees limited to the in-flight write (crimson/seastore/rbm: defer only the in-flight write's extents on conflict): fixes a pre-existing bug on main.

    • When a transaction is conflicted during an RBM OOL write, RandomBlockOolWriter snapshots the whole pre_alloc_list and frees it through its own cleaner once the write completes (829c857).
    • When both tiers are RANDOM_BLOCK (each with its own writer and RBMCleaner since 223dde6), that list holds extents of both tiers. The other tier's extents go to a cleaner that does not own their device; RBMCleaner::mark_space_free() ignores them, and the space is never returned. Measured on unmodified main: 6058 such frees (~258 MiB) in 300s under overwrite load. A SEGMENTED cache tier is not affected (only RBM extents are pre-allocated).
    • Now only the extents of the in-flight write are deferred; the remaining pre-allocated extents are freed immediately through ExtentPlacementManager::mark_space_free(), which routes by device id. Standalone, so it can be backported on its own.
  2. Capacity gating and reservation on the allocator view (crimson/seastore/rbm: gate writes and space reserve on allocator state)

    • stats.used_bytes drifts from the block allocator under overwrites (unmetered paths such as alloc_paddr). get_free_blocks() now reports the AVL allocator's available size, and try_reserve_projected_usage(), get_stat() (hence is_storage_full() and statfs) and the rbm_cleaner metrics read that view.
    • is_storage_full() stays as merged in crimson/osd: gate write ops at OSDOp boundary when local store is full #69351 and keeps tracking osd_failsafe_full_ratio; only its source of used bytes changes.
    • Reservation headroom drops from 5% to 1%, since the allocator view already counts metadata extents. With no in-flight usage to release space, a refused reservation is admitted instead of blocking forever, and the allocator fails a genuinely full device with ENOSPC.
  3. OOL write leakage and backpressure (crimson/seastore/rbm: fix leakage on conflicted OOL writes)

    • Fixes a space leak where t.pending_ool was not cleared after a successful OOL write: a transaction conflicted after its write completed flipped is_conflicted on an already-completed handle and skipped the immediate free path, leaving extents allocated until the allocator was exhausted and the OSD deadlocked.
    • Clears pending_ool in the do_write() completion continuation on every exit path and on transaction reset. Tracks the bytes of conflicted writes still in flight in RBMCleaner and applies backpressure when they exceed 5% of data capacity.
    • The bytes are accounted through the same device-id routing as mark_space_free(), so on a tiered store they land on the cleaner that later subtracts them. Fixes https://tracker.ceph.com/issues/81552 (ceph_assert in RBMCleaner::deaccount_conflict_pending_free on tiered stores, found in QA of the previous revision).

Testing

  • Earlier validation: simulation benchmark with sustained random 1M overwrite over a 70%-full address space, 20x device capacity total IO, completing without aborts or deadlock.
  • Tiered stores (vstart crimson OSD, seastore_lbc_test_stress, 2Q cachepin, seastore_max_concurrent_transactions=8, concurrent rados bench overwrites): the previous revision hit tracker #81552 within ~30s. With this revision the OSD stays up for 480s with a SEGMENTED cache tier (~12k invalidated transactions per 180s) and for 300s with a RANDOM_BLOCK cache tier.
  • unittest-transaction-manager, unittest-seastore and unittest-btree-lba-manager pass at each commit.

Copilot AI review requested due to automatic review settings June 9, 2026 12:15
@fultheim
fultheim requested a review from a team as a code owner June 9, 2026 12:15
@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.

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

Note

Copilot was unable to run its full agentic suite in this review.

Adds near-full/ENOSPC handling and leak prevention in Crimson SeaStore by exposing “storage full” state, gating write-like OSD ops early, and improving cleanup/retirement of extents during OMap node transformations.

Changes:

  • Expose is_storage_full() from RBM cleaner → EPM → TransactionManager → SeaStore/ShardServices and add a best-effort ENOSPC gate in OpsExecuter.
  • Fix/extend OOL write conflict handling with deferred-free backpressure and transaction pending-OOL tracking.
  • Retire old OMap btree nodes’ logical addresses during split/merge/balance to avoid extent leaks.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/crimson/osd/shard_services.h Adds shard-level helper to query local store near-full state.
src/crimson/osd/pg_backend.h Extends write errorator to include enospc.
src/crimson/osd/ops_executer.cc Early ENOSPC gate for data-allocating ops before creating a transaction.
src/crimson/os/seastore/transaction_manager.h Forwards is_storage_full() from EPM.
src/crimson/os/seastore/transaction.h Tracks/clears pending OOL write handle across transaction reuse/conflict.
src/crimson/os/seastore/seastore.h Implements FuturizedStore is_storage_full() via TransactionManager.
src/crimson/os/seastore/random_block_manager/block_rb_manager.h Makes free-blocks reporting reflect allocator state (or 0 pre-init).
src/crimson/os/seastore/random_block_manager/block_rb_manager.cc Moves buffer into device write to avoid extra ref/copy.
src/crimson/os/seastore/omap_manager/btree/omap_btree_node_impl.cc Retires old node logical addresses during node transforms to reclaim space.
src/crimson/os/seastore/extent_placement_manager.h Adds storage-full query and conflict-pending-free accounting forwarding.
src/crimson/os/seastore/extent_placement_manager.cc Wakes blocked IO after background process wake; adds OOL conflict drain gating.
src/crimson/os/seastore/cache.cc Accounts deferred-free bytes when a pending OOL transaction conflicts.
src/crimson/os/seastore/async_cleaner.h Adds RBM-only interfaces: storage-full, deferred-free backpressure/drain.
src/crimson/os/seastore/async_cleaner.cc Implements RBM deferred-free accounting/drain; switches reserve check to allocator view.
src/crimson/os/futurized_store.h Adds is_storage_full() virtual with default false for stores lacking support.

Comment thread src/crimson/osd/shard_services.h Resolved
Comment thread src/crimson/os/seastore/async_cleaner.h Resolved
@Matan-B Matan-B added this to Crimson Jun 9, 2026
@Matan-B Matan-B moved this to Awaits review in Crimson Jun 9, 2026
@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

@Matan-B Matan-B 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.

I'll review this once we agree on #69351 space gating structure.
FWIW, I think we should be able to merge the omap leak commit separately in a standalone PR.

@fultheim

fultheim commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@Matan-B gentle ping on this one. Since your 09-01 review the branch is just the two RBM commits (the #69351 commits dropped out after the rebase). is_storage_full() stays as merged in #69351 and keeps reading osd_failsafe_full_ratio; this PR only changes where get_stat() gets its used bytes from (the allocator instead of stats.used_bytes), and the 1% headroom applies only to try_reserve_projected_usage(). Happy to trim the in-code comments further if they still feel heavy.

Could a maintainer also add ci-approved? Jenkins hasn't run make check on it yet.

@perezjosibm

perezjosibm commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor
PR=wip-perezjos-crimson-only-07-10-2026-PR69352
$ teuthology-suite -m trial  -s crimson-rados -p 101 --force-priority -c $PR  -f debug  --filter=seastore --suite-branch main --suite-repo https://github.com/ceph/ceph.git
2026-10-07 10:58:34,479.479 INFO:teuthology.suite.run:Test results viewable at 

https://pulpito-ng.ceph.com/jjperez-2026-10-07_10:54:03-crimson-rados-wip-perezjos-crimson-only-07-10-2026-PR69352-distro-debug-trial/

  • QA analysis complete: found new defect @fultheim if you could please have a look? Thanks in advance:

    Failures, new:

Jobs Tracker
614031,614012,614042,613942 Bug #81552: ceph_assert_fail seastore::RBMCleaner::deaccount_conflict_pending_free

@fultheim

Copy link
Copy Markdown
Contributor Author

@perezjosibm thanks for the run and the tracker. Bug #81552 was a real bug in this PR; fixed and pushed, rebased onto current main.

Cause. All four failing jobs run a tiered store: seastore_lbc_test_stress auto-creates a cache device in front of the RANDOM_BLOCK data device (segmented_2q, osd_shards/seastore_segmented: SEGMENTED cache tier; rbm, rbm_2q: RANDOM_BLOCK cache tier). On a conflict, Cache::mark_transaction_conflicted() added the deferred-free bytes to BackgroundProcess::main_cleaner, but RandomBlockOolWriter subtracted them on its own rb_cleaner, which for cold-tier writes is the cold cleaner. With a segmented main tier the add was a no-op and the cold RBMCleaner asserted; with an RBM cache tier the main counter grew and never drained.

Reproduced locally with a vstart crimson OSD using the same overrides (seastore_lbc_test_stress, 2Q cachepin, seastore_max_concurrent_transactions=8) and concurrent rados bench overwrites: the previous revision hit the same ceph_assert(conflict_pending_free_bytes >= bytes) within ~30s. With the fix the OSD stays up (480s segmented cache tier, ~12k invalidated transactions in a 180s run; 300s RBM cache tier). unittest-transaction-manager, unittest-seastore and unittest-btree-lba-manager pass.

A second, pre-existing bug surfaced in the same code on main: the writer snapshots the whole pre_alloc_list (since 829c857) and frees it through its own cleaner. When both tiers are RANDOM_BLOCK (each with its own RandomBlockOolWriter since 223dde6), that list holds extents of both tiers, so a conflict frees the other tier's extents through a cleaner that does not own their device. RBMCleaner::mark_space_free() silently ignores an address it does not own, so that space is never returned. It does not crash, which is probably why it went unnoticed. (A SEGMENTED cache tier is not affected: only RBM extents are pre-allocated.)

I confirmed it on unmodified main with a temporary log line in that ignored path, on the rbm-style layout under the same load: 6058 wrong-tier frees (~258 MiB never returned) in 300s. With commit 1 applied, the same run logs zero.

The PR is now three commits:

  1. crimson/seastore/rbm: defer only the in-flight write's extents on conflict: new, fixes the pre-existing bug on main. Standalone, so it can be backported on its own if needed.
  2. crimson/seastore/rbm: gate writes and space reserve on allocator state: unchanged.
  3. crimson/seastore/rbm: fix leakage on conflicted OOL writes: the counter is now accounted through the same device-id routing as mark_space_free(), so it lands on the cleaner that later subtracts it (Fixes: tracker #81552).

@Matan-B the code changed after your approval, so please take another look at commits 1 and 3. @perezjosibm could you re-run the crimson-rados seastore suite on the new head?

…flict

When a transaction is conflicted while an RBM OOL write is in flight,
RandomBlockOolWriter frees the transaction's pre-allocated extents once
the write completes, so the space is not reused under the outstanding
I/O (829c857). It snapshots the whole pre_alloc_list for this and
frees every extent through its own rb_cleaner.

When both tiers of a tiered store are RANDOM_BLOCK, each tier has its
own RandomBlockOolWriter and RBMCleaner (223dde6), and
pre_alloc_list can hold extents of both. A conflict then frees the other
tier's extents through a cleaner that does not own their device;
RBMCleaner::mark_space_free() silently ignores such an address, so that
space is never returned. A SEGMENTED cache tier is not affected, since
only RBM extents are pre-allocated.

Snapshot only the extents of the in-flight write. On conflict, defer
just those; free the remaining pre-allocated extents immediately through
ExtentPlacementManager::mark_space_free(), which routes by device id,
since no I/O is outstanding on them.

Signed-off-by: Shai Fultheim <[email protected]>
stats.used_bytes drifts from the block allocator: alloc_paddr and
mark_space_used from existing_block_list are unmetered, so under
sustained overwrite try_reserve_projected_usage() refuses writes long
before the device is full, or overcommits and crashes the OSD.

Derive used bytes from the AVL allocator instead: get_free_blocks() now
reports the allocator's available size, and try_reserve_projected_usage(),
get_stat() (hence is_storage_full() and statfs) and the rbm_cleaner
metrics all read that view, so admission and operator-visible capacity
agree. stats.used_bytes stays the fallback until the allocator is
populated at mount. The failsafe threshold keeps tracking
osd_failsafe_full_ratio.

Reservation headroom drops from 5% to 1%: the allocator view already
counts metadata extents, so only the in-flight surge before alloc_paddr
commits needs cover.

RBM has no cleaner, so a refused reservation can only be woken by an
in-flight transaction releasing its projected usage. If none exists,
admit the IO instead of blocking (a sole writer on a full device would
otherwise deadlock) and let the allocator fail it with ENOSPC. Zero-usage
reservations are always admitted: they cannot overcommit, and deletes,
the space-releasing transactions, are metadata-only.

Signed-off-by: Shai Fultheim <[email protected]>
A completed out-of-line write left t.pending_ool set. If the transaction
was later marked conflicted, the already-written extents were treated as
still in flight: their space was never freed and the conflict accounting
leaked, eventually exhausting the allocator and deadlocking the OSD.

Add Transaction::clear_pending_ool() and call it from the do_write()
finally continuation, together with the conflict check and the deferred
frees, so it runs on every exit path and is atomic w.r.t. reactor task
interleaving; also clear it in Transaction::reset().

Track the bytes of conflicted OOL writes still in flight in RBMCleaner:
new OOL writes wait (wait_for_conflict_drain) while they exceed 5% of
data capacity, they count as a release source for the reservation gate,
and draining them wakes blocked IO. The bytes are accounted through the
same device-id routing as mark_space_free(), so on a tiered store they
land on the cleaner of the writer that later deaccounts them.

Fixes: https://tracker.ceph.com/issues/81552
Signed-off-by: Shai Fultheim <[email protected]>
@Matan-B

Matan-B commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

@perezjosibm, great catch! Moving back to "Needs QA" as the issues were addressed.

@perezjosibm

perezjosibm commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor
$ PR=wip-perezjos-crimson-only-12-10-2026-PR69352
$ teuthology-suite -s crimson-rados -p 101 --force-priority -c $PR -f debug --filter seastore --suite-branch main --suite-repo https://github.com/ceph/ceph.git
2026-10-12 15:46:44,377.377 INFO:teuthology.suite.run:Test results viewable at 

https://pulpito-ng.ceph.com/jjperez-2026-10-12_15:42:31-crimson-rados-wip-perezjos-crimson-only-12-10-2026-PR69352-distro-debug-trial/

  • Got 43 jobs failures due to infrastructure issue: Command failed on trial150 with status 1: 'sudo yum install -y kernel' 😞 I'll schedule another run later today, hopefully got better results.

@fultheim

Copy link
Copy Markdown
Contributor Author

@perezjosibm thanks for the rerun. The 10-15 crimson-rados seastore run came back with no regressions after the infra failures on 10-12.

@Matan-B your approval is from 10-06, before the 10-10 push that fixed tracker #81552. Since then the PR has three commits:

  1. defer only the in-flight write's extents on conflict: new. It fixes the pre-existing cross-tier free on main.
  2. gate writes and space reserve on allocator state: unchanged.
  3. fix leakage on conflicted OOL writes: account_conflict_pending_free() now routes by device id, the same way mark_space_free() does, so the bytes land on the cleaner that later deaccounts them (Fixes: https://tracker.ceph.com/issues/81552).

Could you re-approve against the current head (62c82d655f8) and merge if you're happy with it?

@Matan-B
Matan-B merged commit 108720b into ceph:main Oct 20, 2026
17 checks passed
@Matan-B Matan-B moved this from Tested to Merged (Main) in Crimson Oct 20, 2026
@github-actions

Copy link
Copy Markdown

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

I found one or more Fixes: tags in the commit messages in

git log 108720b5d5abf2bf783f60b94de0deecdb4e71a1^..108720b5d5abf2bf783f60b94de0deecdb4e71a1

The referenced tickets are:

Those tickets do not reference this merged Pull Request. If this Pull Request merge resolves any of those tickets, please update the "Pull Request ID" field on each ticket. A future run of this script will appropriately update them.

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

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

Projects

Status: Merged (Main)

Development

Successfully merging this pull request may close these issues.

6 participants