Repository navigation
osd,rgw,cls,cephfs: use fixed-width types where the encoding depends on them - #71884
Conversation
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
360ccaf to
4ceea6a
Compare
idryomov
left a comment
There was a problem hiding this comment.
Ack from the RBD perspective
|
This PR has been added to wip-bharath10-testing-20260924.010810-main. |
|
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 |
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
4ceea6a to
31178d0
Compare
|
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. |
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]>
31178d0 to
1d6bfd2
Compare
@SrinivasaBharath i pushed some type-only follow-ups from tchaikov's review (size_t → uint64_t/uint32_t); no behaviour or encoding change. |
|
jenkins test windows |
|
@SrinivasaBharath thanks for running this through QA. It's now Rados-Tested and RGW-TESTED, and approved. Could you (or another maintainer) merge it? |
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_tor a bareinteger 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()theneither fails to compile or picks a different width.
osd,osdc,tools:std::min/std::maxandp2roundupcalled witharguments that deduce to different types
cephfs,cls/rgw,rgw/dedup,rbd-mirror: encoded members given afixed-width type
rgw: multipart part lengths spelleduint64_t;TDigest::Updatematching the signature it overrides; two literals spelled so they deduce
the same everywhere
The last two commits extend
ceph_test_encoding— one fixes the noheadlength 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 wireformat changes.
Checklist
🤖 Generated with Claude Code