Skip to content

wip, Introduce LBAOverlayManager - #67755

Closed
Matan-B wants to merge 7 commits into
ceph:mainfrom
Matan-B:wip-matanb-seastore-conflict-v5
Closed

Matan-B wants to merge 7 commits into
ceph:mainfrom
Matan-B:wip-matanb-seastore-conflict-v5

Conversation

@Matan-B

@Matan-B Matan-B commented Mar 12, 2026

Copy link
Copy Markdown
Contributor
/**
 * LBAOverlayManager
 * A projection layer over LBAManager for transactions.
 * Users (e.g. TransactionManager) only see overlaid (cached) mapping changes.
 * Cursors returned here are LBAOverlayCursor and reflect uncommitted updates.
 * LBAOverlayManager records ops to let the underlying
 * LBAManager replay them at commit time.
 *
 * Main path:
 * - get_cursor() -     return an LBAOverlayCursor created from the
 *                      overlay (if any) or the base LBAManager view.
 *
 * - mutations    -     store a deferred op via apply_overlay_op()
 *                      and update/return the overlay view via
 *                      apply_transaction_overlay().
 *                      Examples: alloc_extent(s), update_mapping_refcount..
 *
 * - commit_overlay() - traverse over the per-txn deferred ops in a serilzed order
 *                      and call the matching LBAManager ops.
 *                      (alloc_* / update_mapping* / remap_mappings / remove),
 *                      then clear the overlay state.
*
 * Notes:
 * - Overlay is txn-local, base LBA tree is *unchanged* until commit.
 * - This goal here is to avoid conflicts from shared LBA nodes.
 *
 * See: revised conflict-handling design paper.
 */

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.

Matan-B added 4 commits March 12, 2026 13:08
Would be cleaned up entirely once the pr undrafted.

Signed-off-by: Matan Breizman <[email protected]>
The change in this commit would probably deserve a *separate PR*

We should break the relation between btree/btree_types
to types such as:
 * BtreeCursor
 * lba_map_val_t

As they should be flexible independent types.

The removed lba_map_val_t which is removed in this commit
will be moved to new lba_types file in the next commits
(until a proper PR is out).

Signed-off-by: Matan Breizman <[email protected]>
* include the moved lba_map_val_t
* include LBAOverlayCursor and the releated data types needed.

Signed-off-by: Matan Breizman <[email protected]>
LogicalChildNode shouldn't be aware of the underlying btree relation.

Signed-off-by: Matan Breizman <[email protected]>
@Matan-B Matan-B added this to Crimson Mar 12, 2026
@Matan-B Matan-B moved this to Unassigned / Drafts / Discussion in Crimson Mar 12, 2026
Matan-B added 3 commits March 12, 2026 13:14
```
/**
 * LBAOverlayManager
 * A projection layer over LBAManager for transactions.
 * Users (e.g. TransactionManager) only see overlaid (cached) mapping changes.
 * Cursors returned here are LBAOverlayCursor and reflect uncommitted updates.
 * LBAOverlayManager records ops to let the underlying
 * LBAManager replay then at commit time.
 *
 * Main path:
 * - get_cursor() -     return an LBAOverlayCursor composed from the
 *                      overlay (if any) or the base LBAManager view.
 *
 * - mutations    -     enqueue a deferred op via apply_overlay_op()
 *                      and update/return the overlay view via
 *                      apply_transaction_overlay().
 *                      Example: alloc_extent(s), update_mapping_refcount..
 *
 * - commit_overlay() - walk the per-txn queued ops in a serilzed order
 *                      and call the matching LBAManager ops.
 *                      (alloc_* / update_mapping* / remap_mappings / remove),
 *                      then clear the overlay state.
*
 * Notes:
 * - Overlay is txn-local, base LBA tree is *unchanged* until commit.
 * - This goal here is to avoid conflicts from shared LBA nodes.
 *
 * See: revised conflict-handling design paper.
 */
```

Signed-off-by: Matan Breizman <[email protected]>
@Matan-B
Matan-B force-pushed the wip-matanb-seastore-conflict-v5 branch from 54e377c to 4ca162f Compare March 12, 2026 11:15
@xxhdx1985126

xxhdx1985126 commented Mar 13, 2026 •

Copy link
Copy Markdown
Member

As mentioned in https://docs.google.com/document/d/1wsKJ3i-9O9_xRxWQOCDjpUoxv3I6rFr2vvAwbmpAgb8/edit?disco=AAAB1tSUueQ.

My concern is mainly about how we'd deal with lba mapping removal, which may need extra disk reads to load nodes to be merged, which wouldn't be known until we actually do the removal.

My suggestion for now is that, maybe we can do the modifications in the lba overlay just like the current implementation, and rely on the ExtentCommitter to merge pending lba nodes with the stable ones and the ones in other transaction's views at commit time.

What do you think? @Matan-B @athanatos

@athanatos

Copy link
Copy Markdown
Contributor

As mentioned in https://docs.google.com/document/d/1wsKJ3i-9O9_xRxWQOCDjpUoxv3I6rFr2vvAwbmpAgb8/edit?disco=AAAB1tSUueQ.

My concern is mainly about how we'd deal with lba mapping removal, which may need extra disk reads to load nodes to be merged, which wouldn't be known until we actually do the removal.

My suggestion for now is that, maybe we can do the modifications in the lba overlay just like the current implementation, and rely on the ExtentCommitter to merge pending lba nodes with the stable ones and the ones in other transaction's views at commit time.

What do you think? @Matan-B @athanatos

That case should be rare. We could make it even more rare by caching the next node whenever a cached LBANode is relatively empty.

As you suggest, the alternative would be merging those node updates and merges at commit time as in the current implementation. That strikes me as pretty complicated since transaction 1 might split or merge a node mutated by transaction 2, but it's probably worth considering since a lot of it already exists. @Matan-B Going that direction would generally avoid the need for the overlay structure, it would probably be worth it for you to read through how that mechanism currently works in detail.

@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 commented Mar 24, 2026

Copy link
Copy Markdown
Contributor Author

Looking into extending merging extents at commit time. Similarly to #67589 merges on TRIM/DIRTY* txns.

@Matan-B

Matan-B commented Mar 26, 2026

Copy link
Copy Markdown
Contributor Author

The best approach here seems to be dropping the Overlay proposal and extend ExtentCommitter instead.
CC: @jdurgin, @xxhdx1985126 - WDYT?

Overlay culprits

  • (Main reason) Commit‑time tree dependencies:
    Deletes/splits/merges depend on neighboring leaves and sibling/parent context,
    which can only be known after loading those nodes.
    Deferring these decisions to commit time requires extra reads in the critical
    path and complicates ordering/recovery.

  • Existing logic (i.e crimson/os/seastore/cache: TRIM_DIRTY/CLEANER_* transactions won't invalidate other transactions anymore #67589):
    We would still need to update other in‑flight transaction views of the same
    LBA leaf and rebase their deltas.
    The ExtentCommitter already does this (copy prior’s updated content into
    pending views and adjust their deltas commit_and_share_paddr), so an overlay would duplicate that mechanism.

  • Journaling/replay might need an intent format:
    We’ll need to encode the overlaid ops into the journal so they are durable
    (before complete_commit()). Otherwise, a crash after the journal ack
    but before we “apply intents” would drop them.

Missing bits (to remove conflicts altogether)

  • Publish‑after‑commit for user (i.e TransactionManager) txns:
    commit_state() currently runs pre‑commit for rewrite/cleaner transactions.
    For user updates, we’ll publish after commit, inside complete_commit().
    Then we could run commit_and_share_paddr() to hand off addresses to all live transactions.

  • Onode/OMAP ExtentCommitter helpers:
    LBA/backref nodes already have the helpers the committer uses (merge content, reapply deltas).
    Backref currently uses them. Applying the same pattern to the LBA tree should be ~similar.
    Onode/OMAP need the corresponding on_state_commit / on_data_commit and
    merge/reapply helpers to handle conflicts the same way.

  • Pipeline guard remains:
    need_wait_rewrite already gates the Cache::prepare_record stage so we don’t build a record
    for another transaction while a publish is in flight.
    In other words, txn B prepare_record() only runs after txn A pre/post paddr helpers and
    maybe_update_pending_paddr() have completed.


the alternative would be merging those node updates and merges at commit time as in the current implementation
That strikes me as pretty complicated since transaction 1 might split or merge a node mutated by transaction 2, but it's probably worth considering since a lot of it already exists.

Most of the complexity seems to be rather solved, @xxhdx1985126 please correct me if I'm wrong:
Splits/merges happen on the mutation path (Cache::prepare_record), not at commit.
Commit only does after‑commit visibility:

  • update the shared prior (via ExtentCommitter::commit_state() / ExtentCommitter::commit_data())
  • hand off paddr so all live txns follow the new address (via ExtentCommitter::commit_and_share_paddr())

If txn B has a pending prior_instance extent, we copy the committed content into txn B view and re‑apply its deltas via commit_data().
need_wait_rewrite gates other prepares so we don’t race the hand‑off.

@xxhdx1985126

xxhdx1985126 commented Mar 27, 2026 •

Copy link
Copy Markdown
Member

The best approach here seems to be dropping the Overlay proposal and extend ExtentCommitter instead.
CC: @jdurgin, @xxhdx1985126 - WDYT?

Yes, I think so, too:-)

Journaling/replay might need an intent format:
We’ll need to encode the overlaid ops into the journal so they are durable
(before complete_commit()). Otherwise, a crash after the journal ack
but before we “apply intents” would drop them.

I don't quite follow this part, it looks to me that we don't need to record extra information in the journal as the actual modifications already happen in Cache::prepare_record and all the deltas and fresh extents are created, which are recorded in the journal. But I may be missing something, could you please elaborate about it a little bit more?

@jdurgin

jdurgin commented Mar 27, 2026

Copy link
Copy Markdown
Member

The best approach here seems to be dropping the Overlay proposal and extend ExtentCommitter instead.
CC: @jdurgin, @xxhdx1985126 - WDYT?

Yes, I think so, too:-)

I agree, nice detailed analysis and future steps!

@Matan-B

Matan-B commented Mar 31, 2026

Copy link
Copy Markdown
Contributor Author

Closing for #68127

@Matan-B Matan-B closed this Mar 31, 2026
@Matan-B Matan-B removed this from Crimson Mar 31, 2026
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.

4 participants