Skip to content

osd/ECTransaction: truncate padded shards of legacy EC objects - #72853

Merged
tchaikov merged 1 commit into
ceph:mainfrom
tchaikov:wip-ec-truncate-legacy-padding
Nov 24, 2026
Merged

tchaikov merged 1 commit into
ceph:mainfrom
tchaikov:wip-ec-truncate-legacy-padding

Conversation

@tchaikov

@tchaikov tchaikov commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Without EC optimizations, every shard of an EC object is padded to the stripe boundary. After allow_ec_optimizations is set on the pool, truncate() only shrinks the shards whose optimized size, computed from the old object size, is larger than the new one. The other shards keep the legacy padding, so scrub finds them too long and flags the object inconsistent.

With 4+2 and 4K chunks, all six shards of a 20K object are 8K. Truncate it to 16K, and shards 1-3 stay at 8K instead of 4K. RBD hits this when a discard or write-zeroes reaches the end of an object, since librbd sends that as a truncate. With more than m shards flagged, "ceph pg repair" marks them all missing and the object ends up unfound, while its data was fine.

So truncate the remaining shards to their new size as well. Objects written with EC optimizations already have that size. Extending the rollback clone to cover the padding instead doesn't work: the primary doesn't know how long it is, and BlueStore rejects a clone_range past the end of an object.

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

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.

@tchaikov
tchaikov requested a review from a team as a code owner October 20, 2026 03:16
@tchaikov
tchaikov requested a review from aainscow October 20, 2026 03:21
@tchaikov

Copy link
Copy Markdown
Contributor Author

@aainscow hi Alex, do you mind reviewing this change?

@tchaikov
tchaikov requested a balanced review from Copilot October 21, 2026 13:57

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@rzarzynski

Copy link
Copy Markdown
Contributor

I'm not sure / doubt whether there was an intention to allow turning a pool into a FastEC if it already stores data.

@tchaikov

tchaikov commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

I'm not sure / doubt whether there was an intention to allow turning a pool into a FastEC if it already stores data.

neither am i. but from user's perspective, if it's not prohibited, it's allowed. and the most scaring thing is, our (Proxmox) user actually did, and this caused data lost =(

do we have document documenting the constraint in this regards?

@aainscow
aainscow force-pushed the wip-ec-truncate-legacy-padding branch from 6161b33 to 773350d Compare October 23, 2026 15:10
@aainscow

Copy link
Copy Markdown
Contributor

I'm not sure / doubt whether there was an intention to allow turning a pool into a FastEC if it already stores data.

It was intended. The docs say the flag "may be enabled for existing pools" (erasure-code.rst), and the optimized code is meant to tolerate shards that still have the legacy size. Truncate missed a case, so this is a real bug.

The fix looks right to me. We have seen a lot of bugs when truncates are combined with writes, so I wanted to make sure this new kind of truncate doesn't run into any of them. I've pushed three test commits on top; keep them separate or squash them, whichever you prefer:

  • 4183287 moves shard_size_on_disk() and make_legacy_layout() into PGBackendTestFixture, and has the three TruncateLegacyObject* tests share one helper.
  • 96f0ea1 tests a truncate and writes in one op, a truncate within the last stripe, and a legacy object grown with EC optimizations before the truncate.
  • 773350d adds a legacy variant of each truncate test in TestBackendBasics.

Without the fix, 56 of the 86 legacy runs in unittest_backend_basics fail. With it, unittest_backend_basics, unittest_ecfailover_with_peering, unittest_ec_with_crush and unittest_peeringstate all pass.

Some notes, none of them blocking:

  • Cost: the extra truncates only come with a truncate that shrinks the object, not with every write. They add no messages, because every shard already gets a sub-write. On objects written with EC optimizations they truncate to the current size, which BlueStore skips.
  • Rollback: I agree none is needed, but the comment could give the real reason. Nothing reads past a shard's optimized size, and PGBackend::rollback_extents cuts every shard to the optimized size of the old object, so the padding couldn't be restored anyway. With chunks larger than a page, the existing clone path already drops the padding of shard 0 and the parity shards in the same way.
  • Scrub: the size check accepts the optimized or legacy size of the object's current size, so it only flags the padding when the new size falls in an earlier stripe. Within the last stripe, the failure is the ISA deep-scrub assert auth_length >= shard_length instead, when chunks are larger than a page. The commit message could say that.

I've also run this on top of the other open truncate fixes (#72138, #72140, #72683 and #72684), with legacy variants of their tests, including the rollback tests and the truncate matrix. They all pass, and when I put back the truncate bugs fixed earlier, the legacy variants catch every one that the original tests catch. Those tests need the other PRs, so they will follow there.

@aainscow aainscow 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 (I have done quite a bit of extra testing here, due to paranoia).

@tchaikov

tchaikov commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@tchaikov

tchaikov commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@tchaikov

tchaikov commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test make check

ProxBot pushed a commit to proxmox/ceph that referenced this pull request Nov 2, 2026
Without EC optimizations, every shard of an EC object is padded to the
stripe boundary. Once allow_ec_optimizations is set on the pool, a
truncate shrinks only some of the shards. The rest keep their padding.

For the user this means deep scrub reports the object inconsistent,
and "ceph pg repair" makes it worse. If more than m shards are too
long, repair marks them all missing and the object ends up unfound,
even though its data is intact. To get the PG clean again, the
operator is likely to run "ceph pg mark_unfound_lost delete", and that
does lose the object. RBD hits this most often, as librbd sends a
discard or write-zeroes at the end of an object as a truncate
(https://tracker.ceph.com/issues/81915).

The fix is under review for main
(ceph/ceph#72853) and has no tentacle backport
yet, so no point release carries it. Carry my cherry-pick until then.
It leaves out the new unit tests, which tentacle cannot build, and
drops out on the next rebase.

Signed-off-by: Kefu Chai <[email protected]>
Link: https://lore.proxmox.com/[email protected]
@tchaikov

tchaikov commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

i think the test failure of unittest_backend_basics is addressed by #72683

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath10-testing-20261109.054620-main.

@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

@ljflores

Copy link
Copy Markdown
Member

@tchaikov JFYI needs a rebase

@tchaikov
tchaikov force-pushed the wip-ec-truncate-legacy-padding branch from 773350d to f2ccc27 Compare November 20, 2026 08:29
@tchaikov

Copy link
Copy Markdown
Contributor Author

@tchaikov JFYI needs a rebase

thanks. rebased.

Without EC optimizations, every shard of an EC object is padded to the
stripe boundary. After allow_ec_optimizations is set on the pool,
truncate() only shrinks the shards whose optimized size, computed from
the old object size, is larger than the new one. The other shards keep
the legacy padding, so scrub finds them too long and flags the object
inconsistent.

With 4+2 and 4K chunks, all six shards of a 20K object are 8K.
Truncate it to 16K, and shards 1-3 stay at 8K instead of 4K. RBD hits
this when a discard or write-zeroes reaches the end of an object,
since librbd sends that as a truncate. With more than m shards
flagged, "ceph pg repair" marks them all missing and the object ends
up unfound, while its data was fine.

So truncate the remaining shards to their new size as well. Objects
written with EC optimizations already have that size. Extending the
rollback clone to cover the padding instead doesn't work: the primary
doesn't know how long it is, and BlueStore rejects a clone_range past
the end of an object.

Fixes: https://tracker.ceph.com/issues/81915
Signed-off-by: Kefu Chai <[email protected]>
@tchaikov
tchaikov force-pushed the wip-ec-truncate-legacy-padding branch from f2ccc27 to 4674973 Compare November 21, 2026 14:06
ProxBot pushed a commit to proxmox/ceph that referenced this pull request Nov 21, 2026
Umbrella 21.2.0 still has the EC truncate bug that tentacle-stable-9
already carries a fix for. On pools with allow_ec_optimizations set, a
truncate leaves the legacy stripe padding on some shards. Deep scrub
then flags the object inconsistent, and a repair can leave it unfound
although its data is intact.

The fix is still under review upstream
(ceph/ceph#72853), so carry its current
version. Like the Tentacle backport, it leaves out the new unit tests,
which build on test fixture helpers that only exist on main.

Signed-off-by: Thomas Lamprecht <[email protected]>
@lee-j-sanders

Copy link
Copy Markdown
Member

@tchaikov
tchaikov merged commit 0a4cf3c into ceph:main Nov 24, 2026
14 checks passed
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.

7 participants