Skip to content

osd/ECTransaction: do not re-clone data a truncate has already backed up - #72138

Merged
kamoltat merged 1 commit into
ceph:mainfrom
aainscow:wip-ec-truncate-rollback-stash-fix
Nov 4, 2026
Merged

kamoltat merged 1 commit into
ceph:mainfrom
aainscow:wip-ec-truncate-rollback-stash-fix

Conversation

@aainscow

@aainscow aainscow commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

An op on a Fast EC, that does both the following:

  1. Truncates the object to a size that is not 4K-aligned on some shard, and
  2. Writes to the same 4k page that involved the truncate.

This generates the following transaction on the shard:

  1. clone_range head -> rollback object, from the truncate point (rounded
    down to 4K) to the old end of the shard
  2. truncate head to the exact new size
  3. truncate head up to the next 4K boundary (logically a zero-write)
  4. clone_range head -> rollback object for the range being written
  5. write

Step 4 copies from the head after steps 2 and 3, so where its range overlaps step 1's it replaces the saved data between the truncate point and the 4K boundary with the zeros from step 3.

If the op is rolled back (a divergent log entry after an OSD failure), those bytes are restored as zeros. The object size is correct. Damage on a data shard shows on read; damage on a parity shard only on scrub, a
degraded read or recovery.

This can be exposed in CephFS and RBD, the latter only if sub-4k block sizes are used (e.g. 512b).

For CephFS, this can be hit directly from a file operation.

For RBD, it much more unlikely, but theoretically can be hit if:

512b blocks
Snapshot copy-on-write queues writes
Queued write contains trim operation that happens to be at end of object and is misaligned. (Turns into truncate)
Queued write contains an over-lapping write.
In practice, RBD scenario may be vanishingly rare when combined with the need for a rollback.

Tests: #72140 (test/osd: Add new EC Truncate tests) demonstrates this defect, rolling back truncate-then-write ops through the PG's backend, and depends on this PR.

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

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.

@aainscow
aainscow requested a review from a team as a code owner September 28, 2026 11:02
@github-actions github-actions Bot added the core label Sep 28, 2026
@aainscow
aainscow force-pushed the wip-ec-truncate-rollback-stash-fix branch from ff3c1c5 to 300724a Compare September 28, 2026 11:04
@aainscow aainscow mentioned this pull request Sep 28, 2026
4 of 14 tasks
@aainscow aainscow changed the title Wip ec truncate rollback stash fix osd/ECTransaction: do not re-clone data a truncate has already backed up Sep 28, 2026
@aainscow
aainscow force-pushed the wip-ec-truncate-rollback-stash-fix branch from 300724a to 163126c Compare September 28, 2026 12:42
@aainscow
aainscow force-pushed the wip-ec-truncate-rollback-stash-fix branch from 163126c to ab8442a Compare September 28, 2026 15:18
Problem: when an op shrinks a Fast EC object to a size that is not
page aligned, truncate() does a clone_range of the page holding the new
end to the backup object, then truncates the head, zeroing the rest of
that page. appends_and_clone_ranges() then clones each written range
from the truncated head into the same backup object. Where a range
covers that page, this overwrites the backup with zeros, so rolling
back the entry restores zeros instead of the original data. This hits
the data shard if the op also writes to that page, and the parity
shards (which are always rewritten for the new partial stripe) if the
new end falls in the first data chunk of its stripe.

Fix: record the offset from which truncate() cloned each shard, and
limit the clones in appends_and_clone_ranges() to below that offset.
The truncate's rollback extent already restores everything above it.

Fixes: https://tracker.ceph.com/issues/80962
Assisted-by: Claude Code
Signed-off-by: Alex Ainscow <[email protected]>
@SrinivasaBharath

Copy link
Copy Markdown
Contributor

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

@bill-scales bill-scales 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

@kamoltat kamoltat added needs-umbrella-backport This PR should be backported to Umbrella needs-tentacle-backport PRs that need tentacle back-port labels Nov 4, 2026
@kamoltat

kamoltat commented Nov 4, 2026

Copy link
Copy Markdown
Member

@kamoltat
kamoltat merged commit 7323ada into ceph:main Nov 4, 2026
25 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core needs-qa needs-tentacle-backport PRs that need tentacle back-port needs-umbrella-backport This PR should be backported to Umbrella wip-bharath5-testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants