Skip to content

rgw/dedup: support server-side compressed object deduplication - #68965

Merged
benhanokh merged 3 commits into
ceph:mainfrom
benhanokh:dedup_compressed_objs
Sep 12, 2026
Merged

benhanokh merged 3 commits into
ceph:mainfrom
benhanokh:dedup_compressed_objs

Conversation

@benhanokh

@benhanokh benhanokh commented May 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR enables full RGW object dedup for server-side compressed objects.

Compressed objects were previously excluded from dedup.
Supporting them unlocks storage savings in deployments with placement compression enabled, while placement-aware SRC selection ensures post-dedup objects align with current zone compression policy.

  • Compressed object dedup:

    • Dedup keys use logical (accounted_size) rather than on-disk size so compressed and uncompressed objects with the same data will show the same size in dedup-table.
    • Strong Hash (BLAKE3) is computed on-the-fly over uncompressed data via streaming decompression.
    • Compression attributes are mirrored from dedup source onto dedup targets.
    • SRC selection prefers objects whose compression matches the current placement rule, while shared-manifest SRC from prior cycles remains authoritative.
  • Large disk records:

    • When serialized manifest/compression attrs exceed disk record capacity, they are stored out-of-line and fetched from the RADOS head object at dedup time via remote_attrs, with new stats for visibility.
  • New option:

    • rgw_dedup_skip_compressed (default false) preserves legacy skip behavior.

Fixes: https://tracker.ceph.com/issues/80319

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

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)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@github-actions

Copy link
Copy Markdown

Config Diff Tool Output

+ added: rgw_dedup_skip_compressed (rgw.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.

@benhanokh

Copy link
Copy Markdown
Contributor Author

/config check ok

@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

This comment was marked as outdated.

This comment was marked as outdated.

@benhanokh benhanokh changed the title Dedup compressed objs rgw/dedup: support server-side compressed object deduplication May 30, 2026
@benhanokh
benhanokh force-pushed the dedup_compressed_objs branch from 921f43e to dc2db25 Compare June 1, 2026 06:14
@benhanokh
benhanokh requested a review from Copilot June 1, 2026 13:13

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@benhanokh
benhanokh requested a review from Copilot June 1, 2026 15:31
@benhanokh
benhanokh force-pushed the dedup_compressed_objs branch 2 times, most recently from e358f00 to 8d857c3 Compare June 9, 2026 13:55
@benhanokh benhanokh self-assigned this Jun 9, 2026
@benhanokh
benhanokh marked this pull request as ready for review June 9, 2026 13:56
@benhanokh
benhanokh requested review from a team as code owners June 9, 2026 13:56
@benhanokh
benhanokh requested a review from mattbenjamin June 9, 2026 13:56
@benhanokh benhanokh added the needs-umbrella-backport This PR should be backported to Umbrella label Jul 8, 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

@benhanokh
benhanokh force-pushed the dedup_compressed_objs branch from 8d857c3 to b40fd15 Compare July 15, 2026 05:50
@benhanokh
benhanokh requested a review from anthonyeleven July 15, 2026 05:51
@benhanokh

Copy link
Copy Markdown
Contributor Author

@anthonyeleven, I merged your PR (#70138).
Please review the merge as doc/radosgw/s3_objects_dedup.rst has significant changes

@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

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

I believe this work is of high quality, I did not spot discrete fixable issues. My primary observation is that while dedup process/workflow are described in some detail, I didn't have a super clear picture of the evolving deduplication serialized state--how it's structured, &c, and if that's not already described in the prior PR, we should maybe add something to help developers get a feel for what i/o work dedup broadly does (beyond computing checksums and remote stats, which I think is very clear).


- Increment the reference count on the source tail objects one by one.
- Copy the manifest from the source to the target.
- Mirror the compression attribute (``RGW_ATTR_COMPRESSION``) from source to

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.

ok

// write-path computes it (see RGWRados::Object::Write::_do_write_meta):
// compressed -> RGWCompressionInfo::orig_size (stable, not patched)
// uncompressed -> physical object size
// We cannot use p_obj->get_accounted_size() because the stat path patches

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.

should this be normalized in the api too?

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 function name and comment do what they can, but e.g. the function signature is almost magically generic

Comment thread src/rgw/driver/rados/rgw_dedup.cc Outdated
// Set RGW_ATTR_COMPRESSION on TGT unconditionally from SRC state.
// TGT now shares SRC's tail objects so its compression state must match.
bool src_compressed = (p_src_rec->compression_bl.length() > 0);
bool tgt_compressed = (p_tgt_rec->compression_bl.length() > 0);

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.

it looks like at l. 1125 the values might not match? i.e., if they don't you're going to coerce them to

if (!p_pre_calc_hmac) {
blake3_hasher_init(&_hmac);
p_hmac = &_hmac;
if (p_rec->compression_bl.length() > 0) {

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.

what does this actually mean? apparently p_rec could point to something not compressed, but it would still have a compression_bl of non-zero length?

//
// Always fetched:
// RGW_ATTR_MANIFEST -- required; returns -ENOENT if missing.
// RGW_ATTR_BLAKE3 -- if present, populates p_rec->s.hash and sets

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 duplicates an S3 additional checksum of type Blake3--an RGW extension, but AWS just added a bunch of new types, including 2 kinds of XXHash and SHA-512 (which we already supported). The additional checksum is a serialized structure and stored as RGW_ATTR_CKSUM.

I think in a future change we should define a pattern for storing multiple checksums, and computing them once.

const std::string &instance,
uint64_t obj_size,
const std::string &storage_class);
const std::string &storage_class,

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 really wish you and jesse could agree (whith Bjarne Stroustrup), that in C++, the correct notation for pointers and references is:
T& ref;
T* ptr;

  1. make them consistent--C programmers carry over T *ptr, but the resulting /type/ is "pointer to T"
  2. most people including Jesse have been typing "T& ref" but now it's inconsistent with the pointer type.

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.

Our clang_format uses T* p and T& r, so it's ideally what everyone should be doing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Too late for this code; there are 1000's instances of this style in my code.
I can try and confirm to this style, but changing it now means creating a diff covering the full dedup code :-(

encode(w.ingress_skip_filtered_bucket, bl);
encode(w.ingress_skip_filtered_storage_class, bl);

encode(w.max_bidx_record_length, bl);

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.

just randomly, does the original PR contain a doc that describes the structure of the dedup schema objects--the dedup table, and so on? I assume so, but this is a large and complex artifact.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

do you mean a proper design doc?
https://docs.google.com/document/d/152VyCTR2NlZ6ongbe6-CJfP4qxr1_zH83FB_WukWD7c/edit?tab=t.0

I need to update this when I find the time , but it gives a good overview of design

Comment thread doc/radosgw/s3_objects_dedup.rst Outdated
Next, we iterate through these dedup candidate objects, reading their complete
information from the object metadata (a per-object RADOS operation). During
this step, we filter out **user-encrypted** objects.
>>>>>>> 4322f69d777 (qa/rgw: fix dedup teuthology zone setup and dedup tests refactoring)

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.

is this a conflict marker?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is a map-reduce pattern

decode(m.failed_rec_load, bl);
decode(m.failed_block_load, bl);
decode(m.failed_rec_overflow, bl);
decode(m.failed_wrong_ver, bl);

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.

is there validity to this trivial observation by copilot @benhanokh ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

do you mean the need for version on each struct?
The code is not production yet so the answer is no;
after 9.2 is out it will be used as version-1 and every change past it will require new verison

@adamemerson

Copy link
Copy Markdown
Contributor

@benhanokh Please open an Enhancement tracker for this feature and set 'umbrella' in the backports. The 'needs-umbrella-backport' label doesn't really do anything.

@anrao19 anrao19 added needs-qa and removed needs-qa labels Aug 20, 2026
Extend full RGW object dedup to handle objects written with RGW
server-side compression. Previously compressed objects were skipped
entirely; they can now participate in dedup when rgw_dedup_skip_compressed
is false (the default).

Key changes:

- Use bucket-index accounted_size (logical/uncompressed size) instead of
  raw object size when building dedup keys, so compressed and
  uncompressed copies of identical content hash to the same table entry.

- Derive logical size from RGW_ATTR_COMPRESSION (orig_size) during the
  attribute-read phase, matching RGWRados::Object::Write::_do_write_meta.

- Compute BLAKE3 over uncompressed bytes via streaming_decompressor_t,
  which decompresses RGW compression blocks incrementally and feeds the
  hasher without loading full decompressed objects into memory.

- Persist RGW_ATTR_COMPRESSION in disk_record_t and mirror compression
  state on dedup targets (setxattr or rmxattr) so TGT tail objects remain
  consistent with SRC.

- Prefer dedup SRC candidates whose compression algorithm matches the
  current placement rule (COMPRESSION_MATCH_EXACT > PARTIAL > NONE),
  while preserving shared-manifest SRC priority from prior dedup cycles.

- Add rgw_dedup_skip_compressed (default false) to optionally retain
  legacy skip behavior.

- Extend dedup stats and documentation for compressed-object ingress,
  dedup success, and compression attr updates.

- Add integration tests for compression mode switches, compressed MD5
  collision rejection, and incremental shared-manifest vs compression
  priority.

Signed-off-by: benhanokh <[email protected]>
…k records

Disk records must fit within MAX_REC_SIZE (~8 KiB minus block header).
Large RGW_ATTR_MANIFEST and RGW_ATTR_COMPRESSION values can exceed this
limit when serialized alongside object metadata.

When a record would overflow:

- Drop manifest_bl and compression_bl from the in-memory/disk record.
- Set RGW_RECORD_FLAG_REMOTE_ATTRS on the record.
- Refetch manifest, optional BLAKE3, and compression from the RADOS head
  object via a single getxattrs() in STEP_REMOVE_DUPLICATES
  (fetch_head_obj_attrs, renamed from read_hash_and_manifest).

This avoids record overflow failures for multipart or heavily manifest-
encoded objects while keeping the common case (small attrs) on the fast
inline path.

Also adds observability for record sizes and remote-attr handling:

- Track max/avg bucket-index and attrs record lengths.
- Counters for remote_attrs_records, failed_remote_attrs_fetch,
  failed_rec_overflow, failed_wrong_ver, write_slab_failure.
- Wire stats through add_record() and flush paths for aggregation.

Signed-off-by: benhanokh <[email protected]>
Teuthology dedup suite:

- Configure realm/zonegroup/zone in qa/suites/rgw/dedup/overrides.yaml.
- Pass cluster, zonegroup, and zone from teuthology context into
  qa/tasks/dedup_tests.py config for multisite-aware tests.
- Set zone and zonegroup HTTP endpoints after realm creation in
  qa/tasks/rgw.py so mdlog trim passes sanity_check_endpoints.

Tests:
- Updated all tests to work with zone/zonegroup
- Extend src/test/rgw/dedup/__init__.py with zone/cluster config helpers.
- Update deduptests.conf.SAMPLE for multisite fields.
- Refactor test_dedup.py layout while retaining compressed-object and
  mode-switch coverage.

Signed-off-by: Gabriel BenHanokh <[email protected]>
@benhanokh
benhanokh merged commit 017d107 into ceph:main Sep 12, 2026
14 checks passed
aainscow pushed a commit to aainscow/ceph that referenced this pull request Sep 18, 2026
rgw/dedup: support server-side compressed object deduplication
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.

5 participants