Repository navigation
Conversation
The OSD needs CRC64-NVME to checksum out-of-band deliveries at the storage node, and the client side needs the same convention to combine per-stripe values, so move the vendored implementations (madler/crcany compute+combine, spdk tables) from src/rgw into src/common and compile them once into ceph-common; rgw picks them up through its existing ceph-common linkage. Add ceph::crc64nvme()/crc64nvme_combine() wrappers exposing the canonical checksum convention (seed 0; byte order is adapted only at rgw's at-rest digest boundary) and a unit test pinning the NVMe check value, madler/spdk agreement, the combine property against whole-buffer checksums, and multi-segment bufferlists. Signed-off-by: Kyle Bader <[email protected]> Assisted-by: claude:claude-fable-5
The vendored isa-l already carries CRC-64/NVME ("rocksoft") kernels for
x86 (PCLMULQDQ/AVX2/AVX512) and aarch64 (PMULL, incl. SVE) behind a
runtime-dispatch multibinary, and ceph already builds all of isa-l as
the ISAL::ISAL target for the EC plugin. Route ceph::crc64nvme through
crc64_rocksoft_refl whenever WITH_EC_ISA_PLUGIN is on: same convention
as the madler tables (seed 0 canonical, inversion internal), so it is a
drop-in backend. The madler tables remain the portable fallback and
still provide the combine math, which isa-l does not implement.
On one Zen 5 core (Ryzen AI MAX+ 395) this takes a 4 MiB-buffer
checksum loop from 2.45 GB/s (tables) to 78 GB/s, which matters once
every BlueStore write can be checksumming 4K blocks with it.
A new unit test pins the isa-l backend against the portable tables
across lengths, alignments and chaining seeds (and degrades to a
tables-vs-tables identity when isa-l is not built).
Signed-off-by: Kyle Bader <[email protected]>
Assisted-by: claude:claude-fable-5
New CSumType CSUM_CRC64NVME (=7, appended before CSUM_MAX so existing on-disk values are untouched) with the usual Alg struct and cases in the four helper switches. Values are 8 bytes per csum block, like xxhash64. The one framework change: calculate()'s default-init overload and verify() hardcoded an init value of -1, which every existing algorithm wants but crc64nvme must not use - its canonical convention seeds with 0 so that each stored block value equals the standard CRC-64/NVME of that block. Each Alg now declares its default_init (unchanged -1 for the existing five) and the framework uses it. Keeping the stored values canonical is the point of the type: they combine linearly across blocks and match the checksum family used end to end by S3 x-amz-checksum-crc64nvme, the RDMA passthrough path and NVMe's 64-bit protection-information guard tags. Unit tests cover the helper mappings, canonical per-block values, the block-to-whole combine property, and bad-block pinpointing in verify. Signed-off-by: Kyle Bader <[email protected]> Assisted-by: claude:claude-fable-5
Config Diff Tool Output! changed: bluestore_csum_type: old: ['none', 'crc32c', 'crc32c_16', 'crc32c_8', 'xxhash32', 'xxhash64'] (global.yaml.in)
! changed: bluestore_csum_type: new: ['none', 'crc32c', 'crc32c_16', 'crc32c_8', 'xxhash32', 'xxhash64', 'crc64nvme'] (global.yaml.in)
! changed: bluestore_csum_type: old: Algorithms crc32c, xxhash32, and xxhash64 are available. The _16 and _8 variants use only a subset of the bits for more compact (but less reliable) checksumming. (global.yaml.in)
! changed: bluestore_csum_type: new: Algorithms crc32c, xxhash32, xxhash64, and crc64nvme are available. The _16 and _8 variants use only a subset of the bits for more compact (but less reliable) checksumming. crc64nvme stores the canonical CRC-64/NVME value of each block (8 bytes), the checksum family used by S3 full-object checksums and NVMe protection information; adjacent block values can be combined without rereading data. (global.yaml.in)
The above configuration changes are found in the PR. Please update the relevant release documentation if necessary. |
|
@aclamk Sounds like this could be a foundation for some more useful things. What do you think? |
|
@mmgaggle The ability to "chain" is common to all CRC algorithms. I assume that value of the NVME checksum is required. Should Possibly better alternative to Though it seems a perfect place for the feature, I do not want to modify existing Also worth mentioning is that there is a performance cost for upgrading default 4 byte crc into 8 byte crc. Currently about half of Onode metadata is checkums. With 4->8 it will become 2/3. Checksums do not compress, so I expect even more expansion on RocksDB side. Also, Onode cache capacity will be slightly reduced (expanded Onodes are significantly larger, so metadata change 4->8 does not matter much). |
|
I think it only applies to crc64nvme and crc32c, it wouldn't apply to the truncated crc types like crc32c_16 / crc32c_8, or xxhash32 / xxhash64. I think what you're getting at is If the bufferlist is the same you avoid both a memcpy and re-reading the data from disk. This also would allow the caller to conditionally do the checksum, it could choose not do it in bluestore and instead have it be generated by ConnectX in hardware as it does the RDMA write into the client buffer. There is definitely a performance and space tradeoff, but it would be user selectable and not the default. An operator could choose to use it for an RGW data pool, if they know ahead of time they're going to have cuObject clients with OSDs writing directly into GPU memory, and they want a way to verify that what is in memory is what they asked for, at least to the extent that crc64nvme can provide. I think there is also potential where bluestore could push this work down to NVMe devices that support protection information, such that some of the data integrity work that are currently covered in software can be delegated down to hardware. |
Wire CSUM_CRC64NVME through blob checksum calculation and verification, the bluestore_csum_type enum values, and the pool csum_type path (which validates through Checksummer's string mapping and needed no change). Costs 8 bytes per csum block like xxhash64. The draw is not the wider checksum so much as what the value is: each block's stored checksum is the canonical CRC-64/NVME of that block, the same family as S3's x-amz-checksum-crc64nvme and NVMe's 64-bit PI guard tag, and values combine linearly. That makes the on-disk checksum metadata a source higher layers can derive range checksums from without rereading data - e.g. serving the RDMA passthrough path's per-stripe CRCs from metadata instead of a second data pass, or matching guard tags on a PI-formatted NVMe-oF namespace. Those consumers need a range-checksum read API, which is left for the ObjectStore read-interface work; this commit makes the stored values the right ones so that data written now benefits later. The synthetic-workload csum matrix in ceph_test_objectstore gains the new algorithm (passes along with the existing six permutations). Blobs written with crc64nvme read as -EOPNOTSUPP on older OSDs, so enabling it is a commitment against downgrade; noted in the release notes. Signed-off-by: Kyle Bader <[email protected]> Assisted-by: claude:claude-fable-5
Deriving a range checksum from stored per-block values needs the checksum of unwritten (hole) bytes, which read as zeros. Zero runs are order-independent, so fold in one 2^k-byte run per set bit of the length using the existing combine math - no zero buffer, no O(n) pass. Signed-off-by: Kyle Bader <[email protected]> Assisted-by: claude:claude-fable-5
New ObjectStore method: return the checksum of an object range, equal to what checksumming the bytes of read(offset, len) would produce (clamped at object size, holes as zeros). BlueStore derives it purely from stored checksum metadata - no data read - when the blobs store combinable full-width values of the requested type: crc64nvme (canonical values, combined with the carry-less-multiply math) and crc32c (seeded -1, folded with the same zeros-operator identity bufferlist's cached-crc combine uses). xxhash does not combine and the truncated crc32c variants store too little state, so those types are never derived. When the range is not derivable (compressed blobs, another stored csum type, csum-less blobs, partially covered csum blocks), the caller may pass the bytes it already read - the same bufferlist a preceding read() filled, so nothing is copied or reread - and the checksum is computed over them by the base implementation. The return value reports which happened: 0 derived from metadata, 1 computed over the caller's data. With no data supplied the call remains a pure metadata probe returning -EOPNOTSUPP, leaving the fallback strategy with the caller: compute in software over bytes in hand, or let transport hardware (e.g. RDMA NIC signature offload) produce the value in flight. This is the metadata-read seam the RDMA passthrough path and an NVMe-oF 64-bit-PI gateway can serve range checksums from; it is deliberately narrow so the broader ObjectStore read-interface rework can absorb or replace it. The store_test covers whole-object, sub-range, hole, straddling and past-eof ranges for both algorithms against checksums of the actually-read data, the refusal cases, the data fallback (including that derivable ranges still prefer metadata and that errors like ENOENT are not papered over), and that in-place overwrites keep deriving correctly (an existing blob recalculates under its own csum type even when the store default has changed). Signed-off-by: Kyle Bader <[email protected]> Assisted-by: claude:claude-fable-5
155ae5e to
df63244
Compare
|
@aclamk @markhpc Pushed an update incorporating the feedback.
The fused shape is layered on the probe. The method now takes an optional bufferlist — the bytes a preceding The metadata cost is now stated in the docs. bluestore-config-ref and the release note carry the numbers: 8 B vs 4 B per csum block, roughly a one-third onode growth, and checksum bytes don't compress; store_test now covers the crc32c derivation matrix (holes, straddles, EOF clamp), the fallback returns (derivable ranges still prefer metadata), and error propagation. @markhpc taking this out of draft. |
anthonyeleven
left a comment
There was a problem hiding this comment.
Several suggestions
| contrast, data checksumming is handled by BlueStore and can use either | ||
| `crc32c`, `xxhash32`, or `xxhash64`. Nonetheless, `crc32c` is the default | ||
| contrast, data checksumming is handled by BlueStore and can use `crc32c`, | ||
| `xxhash32`, `xxhash64`, or `crc64nvme`. Nonetheless, `crc32c` is the default |
There was a problem hiding this comment.
The default is crc32c.
| as the checksum algorithm. | ||
|
|
||
| Conversely, `crc64nvme` stores a larger 8-byte value per block: the canonical | ||
| CRC-64/NVME checksum, the same algorithm used by S3 full-object checksums |
There was a problem hiding this comment.
This sentence is a bit awkward, I’d split it.
| tags. Its values combine linearly, so the checksum of a range of blocks can be | ||
| derived from the stored per-block values without rereading the data, which | ||
| lets higher layers reuse BlueStore's checksums end to end. Checksumming is | ||
| hardware-accelerated (carry-less multiply) on x86-64 and aarch64. |
There was a problem hiding this comment.
I’d drop the parenthetical
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
|
@mmgaggle I see 2 solution: |
|
This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days. |
What
BlueStore gains
crc64nvmeas a first-class data checksum algorithm(
bluestore_csum_type/ per-poolcsum_type), with the checksum mathhardware-accelerated via the vendored isa-l. Independent of, and
parallel to, the S3-over-RDMA work in #71209: the first commit
(hoisting the vendored CRC sources from src/rgw into src/common) is
shared with that PR - whichever lands second rebases it away.
Six commits:
rgw,common: hoist the vendored CRC sources into common. The
madler/crcany and spdk implementations rgw already vendors for
x-amz-checksum-crc64nvmemove to src/common with aceph::crc64nvme()/crc64nvme_combine()wrapper, so code belowrgw can use the same canonical convention.
common: back crc64nvme with isa-l's carry-less-multiply
implementation. isa-l already carries CRC-64/NVME ("rocksoft")
kernels for x86 (PCLMULQDQ/AVX2/AVX512) and aarch64 (PMULL/SVE)
behind a runtime-dispatch multibinary, and ceph already builds isa-l
as a target for the EC plugin.
ceph::crc64nvmenow routes throughit when
WITH_EC_ISA_PLUGINis on; the portable tables remain thefallback and the combine math. One core goes from 2.45 GB/s to
78 GB/s on a Zen 5 laptop part, so per-4K-block checksumming on the
write path is effectively free.
common: add crc64nvme to the Checksummer framework.
CSUM_CRC64NVME, 8 bytes per csum block like xxhash64. Oneframework change: the default init value (-1, hardcoded twice) is
now a per-algorithm constant, because crc64nvme must seed with 0 so
that each stored block value is the canonical CRC-64/NVME of that
block. Existing algorithms keep -1; no stored value changes.
os/bluestore: wire it up. calc/verify dispatch, option enum,
docs, release note. The synthetic csum matrix in
ceph_test_objectstore runs the new algorithm alongside the existing
six.
common: crc64nvme_zeros. O(log n) checksum of a zero run via
combine doubling — holes read as zeros and need a value.
os: ObjectStore::read_range_checksum. The first consumer seam:
derive the checksum of an object range purely from stored per-block
metadata (default -EOPNOTSUPP; BlueStore walks the extent map and
folds stored values, holes included). Compressed blobs, other csum
types and partially covered csum blocks refuse, so callers fall
back to computing over data. Deliberately narrow — meant to be
absorbed by the ObjectStore read-interface rework.
(A sixth commit — serving the RDMA passthrough per-stripe CRCs of
#71209 from this metadata instead of re-hashing the pushed buffer —
depends on the cuobj code and will be appended to #71209 once this
series lands.)
Why canonical values matter
CRC-64/NVME is the checksum family used by S3 full-object checksums
(
x-amz-checksum-crc64nvme), NVMe's 64-bit protection-informationguard tags, and the OSD-direct RDMA path in #71209 — and it combines
linearly: the checksum of a range of blocks is derivable from the
stored per-block values and their lengths, no data read required.
Storing canonical values makes BlueStore's checksum metadata a source
other layers can consume rather than a private detail:
metadata instead of a second pass over the pushed bytes;
x-amz-checksum-crc64nvmecould be validated at write time and the stored blocks inherit it;
value family (eight 512 B guards combine into one 4 KiB block value),
pointing at host-to-media integrity through ceph-nvmeof;
read with an 8-byte-per-4K overhead and a combinable value they can
also verify client-side.
Commit 5 includes a first, deliberately narrow range-checksum read
seam; the broader ObjectStore read-interface work can absorb or
replace it.
Compatibility
Enum value appended before CSUM_MAX; existing on-disk values are
untouched. Blobs written with
crc64nvmeread as-EOPNOTSUPPonolder OSDs, so enabling it is a commitment against downgrade (release
note included). Older mons reject the string via the existing
Checksummer validation, so mixed-version
osd pool set csum_typefails cleanly.
Validation
agreement across lengths/alignments/chaining seeds, combine property,
zero-run identity, Checksummer per-block canonical values + combine +
bad-block pinpointing.
crc64nvme added to the permutation set, and a new ReadRangeChecksum
test covers whole-object/sub-range/hole/EOF-clamp ranges against
checksums of the actually-read data plus all refusal cases.
against stock rgw.
csum_type crc64nvmeaccepted (bogus namesEINVAL), 8 MiB written and read back intact, deep scrub clean,
offline
ceph-bluestore-tool fsck --deepsuccess, andceph-objectstore-toolonode dump shows csum_type 7 on every blob.🤖 Generated with Claude Code
https://claude.ai/code/session_018HHHYTuCZTJKuDc4KWMAo6