Project

General

Profile

Actions

Bug #80962

closed
AA AA

Fast EC: rollback of a non-aligned truncate can restore zeros to data and parity shards (potential corruption)

Bug #80962: Fast EC: rollback of a non-aligned truncate can restore zeros to data and parity shards (potential corruption)

Added by Alex Ainscow 2 months ago. Updated 22 days ago.

Status:
Backporting
Priority:
Urgent
Assignee:
Category:
-
Target version:
-
Due date:
% Done:

0%

Source:
Backport:
umbrella tentacle
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Component(RADOS):
Pull request ID:
Tags (freeform):
Fixed In:
v22.0.0-446-g7323ada574
Released In:
Upkeep Timestamp:
2026-11-04T22:18:23+00:00

Description

When an op shrinks an optimized EC object so that a shard's new end is not 4K-aligned, and the op also writes to the 4K page holding that new end, the rollback stash for that page is overwritten with zeros. If the op is later rolled back (a divergent log entry after an OSD failure), those zeros are restored. The object size is correct, so nothing reports an error.

Transaction on the affected shard:

1. clone_range head -> rollback object, from the new end rounded down to 4K
up to the old end of the shard
2. truncate head to the exact new size
3. truncate head up to the next 4K boundary (zeroes the rest of the page)
4. clone_range head -> rollback object for the range the op writes
5. write

Step 4 copies from the head after steps 2 and 3. Where its range overlaps the range stashed in step 1, it replaces the saved bytes between the new end and the 4K boundary with zeros.

There are two cases:

Case 1: truncate and write to the same page in one op (data shard)

The op truncates and also writes to the page holding the new end on a data shard, whether the write is below, across or above the new end. Only one data shard can be affected: the one holding the new end. Shards before it keep whole chunks, and shards after it end at a stripe boundary. The damageis visible on a normal read after rollback.

Case 2: a truncate on its own (parity shards)

No client write is needed. The op always rewrites the parity of the partial stripe at the new end, and that parity write is the write in step 4. If the new end falls mid-page in the first data chunk of its stripe, the parity shards also end mid-page, and every parity shard is corrupted on rollback. Normal reads do not decode from parity, so this stays hidden until a degraded read, recovery or backfill rebuilds data from the bad parity.

Truncating to 0, or to any 4K-aligned size, is not affected.

Exposure:

CephFS: yes, from ordinary file operations. After a shrinking truncate (ftruncate/setattr) to a size that is not 4K-aligned, the MDS trims the object holding the new EOF with a CEPH_OSD_OP_TRIMTRUNC at the exact new size. That op is case 2, so any such truncate is exposed on the parity shards. Case 1 happens when a client write carrying the newer truncate_seq reaches the object before the MDS trim (the OSD then truncates and writes in one transaction). That is a race, but truncate-then-append at the new EOF is enough to trigger it.

librbd/krbd: With 512-byte sectors, it is possible to hit case 2 with a truncate. Write-zero requests which hit the end of an object will be translated into truncates and so can hit case 2.

librbd: For librbd only, a second more obscure case exists - when an object is being copied up, librbd can batch queued writes, which would lead to case 1.

Every case needs the op to be rolled back, so an OSD failure has to occur while the op is in flight.


Related issues 2 (2 open — 0 closed)

Copied to RADOS - Backport #82693: tentacle: Fast EC: rollback of a non-aligned truncate can restore zeros to data and parity shards (potential corruption)Fix Under ReviewAlex Ainscow

Actions
Copied to RADOS - Backport #82694: umbrella: Fast EC: rollback of a non-aligned truncate can restore zeros to data and parity shards (potential corruption)Fix Under ReviewAlex Ainscow

Actions

AA Updated by Alex Ainscow 2 months ago Actions #1

  • Subject changed from Fast EC: Potential data corruption combining non-aligned truncate with extending write to same page, which is rolled back. to Fast EC: rollback of a non-aligned truncate can restore zeros to data and parity shards (potential corruption)
  • Description updated (diff)

AA Updated by Alex Ainscow 2 months ago Actions #2

  • Description updated (diff)

RZ Updated by Radoslaw Zarzynski 2 months ago Actions #3

Bump up.

RZ Updated by Radoslaw Zarzynski about 2 months ago ยท Edited Actions #4

Hi @Alex Ainscow, what's the status of this?

AA Updated by Alex Ainscow about 2 months ago Actions #5

  • Pull request ID set to 72138

AA Updated by Alex Ainscow about 2 months ago Actions #6

Fix PR attached, sorry I forgot to attach this earlier.

BS Updated by Bill Scales about 2 months ago Actions #7

  • Status changed from New to Fix Under Review
  • Backport set to umbrella tentacle

LF Updated by Laura Flores about 2 months ago Actions #8

  • Assignee set to Alex Ainscow

Fix in QA. Needs reviews.

LF Updated by Laura Flores about 1 month ago Actions #9

Fix still in QA.

KS Updated by Kamoltat (Junior) Sirivadhna about 1 month ago Actions #10

scrub: I will review QA ASAP

KS Updated by Kamoltat (Junior) Sirivadhna 28 days ago Actions #11

  • Status changed from Fix Under Review to Pending Backport

UB Updated by Upkeep Bot 28 days ago Actions #12

  • Copied to Backport #82693: tentacle: Fast EC: rollback of a non-aligned truncate can restore zeros to data and parity shards (potential corruption) added

UB Updated by Upkeep Bot 28 days ago Actions #13

  • Copied to Backport #82694: umbrella: Fast EC: rollback of a non-aligned truncate can restore zeros to data and parity shards (potential corruption) added

UB Updated by Upkeep Bot 28 days ago Actions #14

  • Status changed from Pending Backport to Backporting
  • Merge Commit set to 7323ada57462bac7ce9ee05976d6adad348394c4
  • Fixed In set to v22.0.0-446-g7323ada574
  • Upkeep Timestamp set to 2026-11-04T22:18:23+00:00

SG Updated by Steven Goodliff 22 days ago Actions #15

Hi,

Is this issue relevant in RGW workloads? overwriting a s3 object maybe ?

thanks

Steven

Actions

Also available in: PDF Atom