Skip to content

os/bluestore: add crc64nvme as a data checksum algorithm - #71295

Open
mmgaggle wants to merge 6 commits into
ceph:mainfrom
mmgaggle:wip-bluestore-crc64nvme
Open

mmgaggle wants to merge 6 commits into
ceph:mainfrom
mmgaggle:wip-bluestore-crc64nvme

Conversation

@mmgaggle

Copy link
Copy Markdown
Member

What

BlueStore gains crc64nvme as a first-class data checksum algorithm
(bluestore_csum_type / per-pool csum_type), with the checksum math
hardware-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:

  1. rgw,common: hoist the vendored CRC sources into common. The
    madler/crcany and spdk implementations rgw already vendors for
    x-amz-checksum-crc64nvme move to src/common with a
    ceph::crc64nvme()/crc64nvme_combine() wrapper, so code below
    rgw can use the same canonical convention.

  2. 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::crc64nvme now routes through
    it when WITH_EC_ISA_PLUGIN is on; the portable tables remain the
    fallback 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.

  3. common: add crc64nvme to the Checksummer framework.
    CSUM_CRC64NVME, 8 bytes per csum block like xxhash64. One
    framework 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.

  4. 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.

  5. common: crc64nvme_zeros. O(log n) checksum of a zero run via
    combine doubling — holes read as zeros and need a value.

  6. 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-information
guard 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:

  • the RDMA passthrough path's per-stripe CRCs could be served from
    metadata instead of a second pass over the pushed bytes;
  • an OSD-direct or ordinary PUT carrying x-amz-checksum-crc64nvme
    could be validated at write time and the stored blocks inherit it;
  • a PI-formatted NVMe-oF namespace's 64-bit guard tags are the same
    value family (eight 512 B guards combine into one 4 KiB block value),
    pointing at host-to-media integrity through ceph-nvmeof;
  • KV-cache-style workloads get corruption detection on every block
    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 crc64nvme read as -EOPNOTSUPP on
older 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_type
fails cleanly.

Validation

  • unittest_crc64nvme (7/7): canonical NVMe check value, isa-l-vs-portable
    agreement across lengths/alignments/chaining seeds, combine property,
    zero-run identity, Checksummer per-block canonical values + combine +
    bad-block pinpointing.
  • ceph_test_objectstore: SyntheticMatrixCsumAlgorithm passes with
    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.
  • unittest_rgw_cksum (22/22) on this branch, confirming the hoist
    against stock rgw.
  • Live vstart: pool csum_type crc64nvme accepted (bogus names
    EINVAL), 8 MiB written and read back intact, deep scrub clean,
    offline ceph-bluestore-tool fsck --deep success, and
    ceph-objectstore-tool onode dump shows csum_type 7 on every blob.

🤖 Generated with Claude Code

https://claude.ai/code/session_018HHHYTuCZTJKuDc4KWMAo6

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
@github-actions

github-actions Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

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.
Ignore this comment if docs are already updated. To make the "Check ceph config changes" CI check pass, please comment /config check ok and re-run the test.

@markhpc

markhpc commented Aug 27, 2026

Copy link
Copy Markdown
Member

@aclamk Sounds like this could be a foundation for some more useful things. What do you think?

@aclamk

aclamk commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

@aclamk Sounds like this could be a foundation for some more useful things. What do you think?

@markhpc Indeed it does!
Possible uses for exposing crc checksum for data:

  1. RDMA message checksum (this code)
  2. faster messenger checksum
    Possible, but discouraged uses:
  3. Deep scrub

@aclamk

aclamk commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

@mmgaggle
I read the code, but I am not reviewing it yet.

The ability to "chain" is common to all CRC algorithms.
I propose to upgrade implementation to perform the read_checksum_range() for all checksums except for XXH64.

I assume that value of the NVME checksum is required. Should read_range_checksum() be unable to calculate it, the caller would need to calculate the checksum himself. I also assume that it will be done by the same code checksummer is using.

Possibly better alternative to read_range_checksum() logic would be to pass to BlueStore a) oid, b) range, c) bufferlist and ask it to calculate the desired checksum. Where possible the checksum will be constructed from metadata, where not bufferlist will be read directly.

Though it seems a perfect place for the feature, I do not want to modify existing ObjectStore::read() interface.

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).

@markhpc

markhpc commented Sep 3, 2026

Copy link
Copy Markdown
Member

@mmgaggle Do you think it might be worth incorporating @aclamk's feedback and taking this one out of draft?

@mmgaggle

mmgaggle commented Sep 4, 2026 •

Copy link
Copy Markdown
Member Author

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

read(oid,range,bufferlist)
checksum(oid,range,bufferlist)

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
@mmgaggle
mmgaggle force-pushed the wip-bluestore-crc64nvme branch from 155ae5e to df63244 Compare September 4, 2026 22:41
@mmgaggle

mmgaggle commented Sep 4, 2026 •

Copy link
Copy Markdown
Member Author

@aclamk @markhpc Pushed an update incorporating the feedback.

read_range_checksum now serves crc32c too. Same extent-map walk; stored per-block values fold with the identity bufferlist's cached-crc combine already uses (stored ^ zeros(running ^ -1, len)), holes
via ceph_crc32c_zeros. Values follow the Checksummer convention (seed -1). That's where the derivable set ends: xxhash32/64 aren't linear, crc32c_16/_8 store only the low bits, and the requested type has to
match what the blob stores — there's no converting between checksum families from metadata.

The fused shape is layered on the probe. The method now takes an optional bufferlist — the bytes a preceding read(offset, len) returned, so nothing is copied or reread — and when the range isn't derivable
from metadata the checksum is computed over them in the ObjectStore base implementation, so every backend gets that behavior for free. The return value reports the source (0 = derived from metadata, 1 =
computed over the caller's data), and errors like ENOENT propagate rather than being papered over by hashing stale bytes. Called without data it stays a pure metadata probe: -EOPNOTSUPP leaves the fallback
choice with the caller, which matters for the RDMA path — on a derivation miss the cheapest fallback there isn't necessarily software, it's the NIC computing the CRC in flight during the push.
ObjectStore::read() remains untouched.

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;
per-pool csum_min_block is the lever for metadata-sensitive pools, trading coarser derivation granularity. The default stays crc32c — this is opt-in.

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.

@mmgaggle
mmgaggle marked this pull request as ready for review September 4, 2026 22:49
@mmgaggle
mmgaggle requested review from a team as code owners September 4, 2026 22:49

@anthonyeleven anthonyeleven 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.

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

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.

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

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.

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.

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.

I’d drop the parenthetical

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@aclamk

aclamk commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

@mmgaggle
I just realized that there is a significant problem with read_range_checksum() logic.
In most cases there is no way to know if the bufferlist does represent actual value in the object.
It obviously did when it was obtained from read(), but the content of the object could be modified later, so CRCs from the metadata will not match bufferlist content.

I see 2 solution:
a) make returning CRC a part of compound read_and_crc() .
b) make sure OSD is not modifying the object in the window between read() and read_range_checksum().

@github-actions

Copy link
Copy Markdown

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.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions Bot added the stale label Nov 16, 2026
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.

4 participants