Repository navigation
erasure-code/clay: decode sub-chunks in place - #72056
Conversation
Since 216eb26 raised ErasureCode::SIMD_ALIGN from 32 to 64, CLAY realigns sub-chunk views that are smaller than SIMD_ALIGN (32 bytes for k=12 m=4 d=15) before decoding into them. The realign copies the view, the inner decode writes into the copy and the result is lost. Encode goes through the same path, so parity is written wrong, and degraded reads return uninitialised memory. Don't realign the sub-chunk views that are written in place; assert that they are contiguous instead. The repair path still realigns its inputs, which come from the read reply and may be misaligned. Add an enabled round-trip test with 32-byte sub-chunks. Fixes: https://tracker.ceph.com/issues/80848 Reported-by: Michal Strnad Signed-off-by: Lumir Sliva <[email protected]>
|
Thank you for your contribution. Since you are not yet a member of the Ceph organization with write permissions on ceph/ceph.git, our CI will not automatically run. Any member of the Ceph organization may label this PR |
|
Related #71927 |
Thanks, I went through it, they don't overlap:
On whether CLAY is still worth fixing, this is how I read the code and docs:
So CLAY is on its way out, but it's there today, and public telemetry still shows CLAY pools (https://telemetry-public.ceph.com/d/b5664aff-721e-4c8a-b79a-7d3e2a8eaf07/ec-plugin). Anyone on tentacle with 12+4, 10+4, 16+4 or 6+3 is writing bad parity right now, and a lost data shard means lost data, so this needs to reach them in a tentacle point release. It's also worth a line in the tentacle release notes telling those users to migrate to a supported profile, since they'll have to move off CLAY before Vampire anyway and have to rewrite that data regardless. |
jamiepryde
left a comment
There was a problem hiding this comment.
The fix looks good.
Any CLAY profile with a sub chunk size that isn't a multiple of SIMD_ALIGN will copy the parity/decode output buffers, write the result into the copy, and then discard it. So encode produces the wrong parity, and decode returns garbage. At SIMD_ALIGN=32, the realign on those buffers was a no-op, which is why this has only been exposed now. These buffers don't actually need alignment. The fix correctly stops realigning them and keeps alignment only for the helper data, which I think is the only input that can arrive misaligned.
I've run the new unit test with and without the fix and confirmed it fails without the fix, and passes with it.
|
This PR has been added to wip-bharath15-testing-20260929.043152-main. |
Since tentacle, CLAY computes wrong parity and returns garbage whenever it has to rebuild a
lost data shard, for profiles where the sub-chunk size isn't a multiple of 64 bytes (12+4,
10+4, 16+4 and 6+3 with the default stripe unit). Reproducer, harness and raw output are on
the tracker, so the reasoning can be checked independently.
Fixes: https://tracker.ceph.com/issues/80848
What's wrong
216eb26 ("erasure-code: Increase SIMD_ALIGN from 32 to 64", #60246) is in every tentacle
release. CLAY works plane by plane on sub-chunks, which are
substr_of()views intoU_bufand the coupled chunks, and before every inner jerasure call it runs
rebuild_aligned[_size_and_memory](..., SIMD_ALIGN)on those views. A sub-chunk is onlyaligned to its own size: for k=12 m=4 d=15 there are 256 sub-chunks in an 8192 byte chunk, so
each one is 32 bytes. With
SIMD_ALIGN=32those views stayed in place. With 64, every oddsub-chunk gets silently copied, the inner decode writes into the copy and the result is lost.
Parity is computed through the same
decode_layered()path (the parity shards are theerasures), so both directions break:
shards and all of the other two). Data shards are fine, so healthy reads look fine, and
deep-scrub can't tell because hinfo is computed over the wrong parity
return uninitialised memory plus stale
U_bufplanes. The CRC changes on every read of thesame object. With a data digest that's EIO (
full-object read crc ... != expected), withoutone (after partial writes, e.g. RBD) the client gets the garbage
the rest of the stripe from parity and write it back as data
Reported against a production 19.2.3 -> 20.2.4 upgrade with CLAY 12+4 RGW and RBD pools. The
mon doesn't allow
allow_ec_optimizationson a CLAY profile, so this is the legacy EC path.squid is unaffected.
Fix
Stop realigning the sub-chunk views that the inner decode writes into; they get a contiguity
assert instead. In the normal decode/encode path the inputs are views into buffers that are
already aligned at chunk level, so they are left alone as well, which is exactly what squid did
with
SIMD_ALIGN=32. Inrepair_one_lost_chunk()the inputs come from the read reply and maybe misaligned, so those are still realigned (copying an input is harmless). That path is
currently unreachable because
is_repair()always returns 0, but it keeps the right behaviourfor when it comes back.
Reverting
SIMD_ALIGNisn't an option: it was raised on purpose, and existing pools have the32-byte sub-chunk baked into their
stripe_width, so CLAY has to cope with it.Side note: the old loops only realigned indices 0..2 and never 3, which is why only part of
the output was lost.
This does not repair data already written by an affected OSD. Objects written or modified on
20.x with an affected profile have bad parity and need a whole-object rewrite once the fix is
in. Worth a release note, happy to add one here or separately.
How to check it yourself
Reproducer, harness and raw output are attached to the tracker.
ErasureCodeClay.encode_decode_small_subchunkstest fails on main (98fb1cf) onevery erasure pattern and passes with this change:
unittest_erasure_code_clay --gtest_filter='*small_subchunks*'DISABLED_since0a9e718 and only used k=2..4 (sub-chunks of 256+ bytes, still 64-aligned), and
ceph-erasure-code-corpus has no CLAY entries
SIMD_ALIGN = 32makesencode and decode correct again
Also verified on vstart (17 OSDs, CLAY 12+4):
jerasure and ISA 12+4 fine on both
ceph-objectstore-toolmatch what the plugincomputes outside the OSD, wrong sub-chunks at exactly the misaligned offsets
libec_clay.so: degraded reads correct with up to 3 shards down, backfillplus deep-scrub clean, and rewritten objects clean
Will backport to tentacle once this is reviewed.
Checklist