Skip to content

osd,rgw,cls,cephfs: use fixed-width types where the encoding depends on them - #71884

Merged
idryomov merged 10 commits into
ceph:mainfrom
dvanders:wip-macos-2-inttypes
Oct 13, 2026
Merged

idryomov merged 10 commits into
ceph:mainfrom
dvanders:wip-macos-2-inttypes

Conversation

@dvanders

Copy link
Copy Markdown
Contributor

Split out of #71232, which reviewers asked to see in smaller batches.
Based on main; independent of the other six.

Places where a type is written as long, size_t, time_t or a bare
integer literal, but the value is encoded, compared or passed to an
overload that resolves on its exact width. Those all have the same size on
LP64 Linux, so nothing shows; they do not elsewhere, and encode() then
either fails to compile or picks a different width.

  • osd,osdc,tools: std::min/std::max and p2roundup called with
    arguments that deduce to different types
  • cephfs, cls/rgw, rgw/dedup, rbd-mirror: encoded members given a
    fixed-width type
  • rgw: multipart part lengths spelled uint64_t; TDigest::Update
    matching the signature it overrides; two literals spelled so they deduce
    the same everywhere

The last two commits extend ceph_test_encoding — one fixes the nohead
length in the test itself, and one pins the wire format of a 64-bit
integer vector so a future change of this kind is caught.

The encodings were checked against Linux with ceph-dencoder; no wire
format changes.

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)

🤖 Generated with Claude Code

@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

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

Ack from the RBD perspective

@xiubli xiubli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM from cephfs.

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

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

@anrao19

anrao19 commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by anuchaithra started 2026-09-24-06:02.

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

RGW Approved.

@anrao19

anrao19 commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by anuchaithra started 2026-09-24-06:02.

RGW pr testing is completed and approved by @ivancich, more details in : https://tracker.ceph.com/issues/80827
@dvanders , ACK from RGW

@anrao19 anrao19 added RGW-TESTED testing from rgw completed and removed wip-anrao1-testing labels Sep 28, 2026
@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

@dvanders

dvanders commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Rebased for a conflict in src/osdc/SplitOp.cc. The only change is the same cast applied to main's rewritten init_read(), so the RGW results should still apply.

Comment thread src/rgw/rgw_crypt.h Resolved
Comment thread src/rgw/rgw_crypt.cc Resolved
Comment thread src/rgw/rgw_crypt.cc Resolved
Comment thread src/rgw/rgw_op.cc Resolved
Comment thread src/rgw/driver/d4n/rgw_sal_d4n.cc Resolved
Comment thread src/rgw/driver/d4n/rgw_sal_d4n.cc Resolved
Comment thread src/rgw/driver/rados/rgw_dedup_utils.cc Resolved
Comment thread src/osd/OSDMap.cc Resolved
std::min(), std::max() and p2roundup() deduce a single type from all of
their arguments, so mixing size_t or uintptr_t with uint64_t fails to compile
wherever those are distinct types - that is, anywhere uint64_t is unsigned
long long rather than unsigned long.

Name the type explicitly, or give the operands a matching type.  No
behavioural change: every one of these widens an unsigned value to the same
width it already had.

Assisted-by: claude-code:claude-opus-5
Signed-off-by: Dan van der Ster <[email protected]>
encode() was called with the result of std::vector::size(), i.e. size_t.
There is no exact ceph::encode() overload for size_t on platforms where
uint64_t is unsigned long long rather than unsigned long, so the call is
ambiguous there.

Encode uint64_t explicitly.  That is byte for byte what LP64 platforms were
already putting on the wire, so the encoding is unchanged.

Assisted-by: claude-code:claude-opus-5
Signed-off-by: Dan van der Ster <[email protected]>
json_spirit::mValue can be constructed from bool, int, int64_t, uint64_t and
double, so assigning a time_t to one is ambiguous on platforms where time_t is
long, matching none of those exactly.

utime_t::sec() returns time_t, so name the target type at the call site.

Assisted-by: claude-code:claude-opus-5
Signed-off-by: Dan van der Ster <[email protected]>
cls_rgw_lc_obj_head::encode() copies start_date into a uint64_t before
encoding it, and the decoder reads both dates back through a uint64_t, but
shard_rollover_date is encoded straight from its time_t.

The integer encoders are defined for the fixed-width types only.  On LP64
Linux time_t is long, and so is int64_t, so the call resolves and writes eight
little-endian bytes.  On Darwin int64_t is long long, so time_t matches no
encoder and every candidate is ambiguous - the file does not compile.

Copy through a uint64_t, as the field above it already does and as the
decoder already expects.  The encoding is unchanged: both spellings go
through the same le64 encoder.  The one archived object in
ceph-object-corpus is struct_v 2 and carries the field, and it still
round-trips byte for byte.

Assisted-by: claude-code:claude-opus-5
Signed-off-by: Dan van der Ster <[email protected]>
Throttle's encoder passes get_max_calls_per_second(), which returned
size_t, and its decoder reads into a size_t.  Neither compiles on Darwin,
where size_t is unsigned long and uint64_t is unsigned long long, so
size_t matches none of the fixed-width integer encoders.

The rate is held in a uint32_t (paired with tokens for an aligned 8 byte
reset) and set from a uint32_t, so make the constructor and the getter
uint32_t as well.  Encode it as uint64_t: size_t is uint64_t on LP64
Linux, where this format was established, so the eight little-endian
bytes are unchanged.

Assisted-by: claude-code:claude-opus-5
Signed-off-by: Dan van der Ster <[email protected]>
The vector of part lengths that carries the multipart layout - through
rgw_crypt, the range projection, the compression pipe and the rados and d4n
drivers - is a std::vector<size_t>, and one of them is persisted as the
CRYPT_PARTS attribute.

The integer encoders cover the fixed-width types only, so a container of
size_t is encodable on LP64 Linux, where size_t and uint64_t are both
unsigned long, and nowhere else: on Darwin uint64_t is unsigned long long and
size_t matches no encoder.

Name the type uint64_t throughout, including the loops over the vector, the
lengths the d4n driver builds it from, and the unit tests that construct one,
which is what size_t already resolved to where the attribute's format was
established, so the bytes are unchanged - a u32 element count followed by
little-endian 64-bit elements, as EncodingGolden.Vector64 now asserts.

Assisted-by: claude-code:claude-opus-5
Signed-off-by: Dan van der Ster <[email protected]>
Digest declares Update(const unsigned char*, size_t); TDigest spells the
second parameter uint64_t.  On LP64 Linux those name the same type and the
override takes effect.  On Darwin uint64_t is unsigned long long while size_t
is unsigned long, so it overrides nothing: TDigest stays abstract, and the
first diagnostic - a non-virtual member marked override - is followed by a
dozen more about Blake3*, SHA256* and the rest not converting to Digest*.

Name the type the base names.  The wrapped digests take either spelling, and
size_t converts to the uint64_t ones without loss.

Assisted-by: claude-code:claude-opus-5
Signed-off-by: Dan van der Ster <[email protected]>
get_shard_names() builds views::iota(0ul, num_shards), where num_shards is
uint64_t, and returns it as ShardNamesView - an iota_view<uint64_t, uint64_t>.
On Darwin 0ul is unsigned long and uint64_t is unsigned long long, so the
expression has type iota_view<unsigned long, unsigned long long> and does not
convert.

std::min(sem_max_keys, keys.size()) in the datalog is the same story from the
other side: uint64_t against size_type, and template deduction has nothing to
pick.

Say uint64_t in both places.

Assisted-by: claude-code:claude-opus-5
Signed-off-by: Dan van der Ster <[email protected]>
encoding.h defines its integer encoders for the fixed width types only.  On
LP64 Linux size_t and uint64_t are both unsigned long, so a size_t argument
resolves to the uint64_t encoder; on Darwin uint64_t is unsigned long long,
so size_t is a distinct type with no encoder and the call does not compile.

Name uint64_t directly, which is the type the case was there to cover.

Assisted-by: claude-code:claude-opus-5
Signed-off-by: Dan van der Ster <[email protected]>
The integer encoders cover the fixed-width types only, so a container of
size_t encodes on LP64 Linux - where size_t and uint64_t are both unsigned
long - and nowhere else; on Darwin uint64_t is unsigned long long, so size_t
is a distinct type with no encoder.

Code using size_t therefore has to be respelled as uint64_t to build off
Linux, and that respelling has to be format-preserving, because some of these
containers are persisted - the rgw CRYPT_PARTS attribute among them.  Nothing
was checking that, and the equivalence is invisible on the platform where the
format was established.

Assert the bytes: a u32 element count followed by little-endian 64-bit
elements, and the bare zero count that CRYPT_PARTS uses as its sentinel.

Assisted-by: claude-code:claude-opus-5
Signed-off-by: Dan van der Ster <[email protected]>
@dvanders
dvanders force-pushed the wip-macos-2-inttypes branch from 31178d0 to 1d6bfd2 Compare October 5, 2026 22:25
@dvanders

dvanders commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

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

@SrinivasaBharath i pushed some type-only follow-ups from tchaikov's review (size_t → uint64_t/uint32_t); no behaviour or encoding change.

@dvanders

dvanders commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test windows

@tchaikov tchaikov 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

@JonBailey1993

Copy link
Copy Markdown
Contributor

@dvanders

Copy link
Copy Markdown
Contributor Author

@SrinivasaBharath thanks for running this through QA. It's now Rados-Tested and RGW-TESTED, and approved. Could you (or another maintainer) merge it?

@idryomov
idryomov merged commit 04ba07e into ceph:main Oct 13, 2026
15 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.

8 participants