Skip to content

remove the wildcard ref used by cls_refcount - #66009

Closed
benhanokh wants to merge 1 commit into
ceph:mainfrom
benhanokh:no_wildcard_copy
Closed

benhanokh wants to merge 1 commit into
ceph:mainfrom
benhanokh:no_wildcard_copy

Conversation

@benhanokh

@benhanokh benhanokh commented Oct 21, 2025 •

Copy link
Copy Markdown
Contributor

This PR removes the wildcard reference mechanism from the refcount system, replacing it with explicit source object references. The change affects server-side copy and deduplication operations by requiring both source and target tags to be specified when managing object reference counts.

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.

@benhanokh
benhanokh requested a review from a team as a code owner October 21, 2025 21:05
@benhanokh
benhanokh requested review from Copilot and removed request for a team October 21, 2025 21:05
@benhanokh
benhanokh marked this pull request as draft October 21, 2025 21:05

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.

Pull Request Overview

This PR removes the wildcard reference mechanism from the refcount system, replacing it with explicit source object references. The change affects server-side copy and deduplication operations by requiring both source and target tags to be specified when managing object reference counts.

Key changes:

  • Modified cls_refcount_get() to require a src_tag parameter instead of an implicit_ref boolean flag
  • Updated cls_refcount_put() to remove the implicit_ref parameter
  • Changed cls_refcount_read() to remove the implicit_ref parameter

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/cls/refcount/cls_refcount.cc Core refcount logic updated to use src_tag instead of wildcard references
src/cls/refcount/cls_refcount_client.h API signatures changed to add src_tag parameter and remove implicit_ref
src/cls/refcount/cls_refcount_client.cc Client implementation updated with validation for non-empty tags
src/cls/refcount/cls_refcount_ops.h Operation structures modified to replace implicit_ref with src_tag
src/cls/refcount/cls_refcount_ops.cc Encoding/decoding updated for new src_tag field
src/rgw/driver/rados/rgw_rados.cc Server-side copy updated to use actual source tag instead of wildcard
src/rgw/driver/rados/rgw_gc.cc Garbage collection updated to use new put API without implicit_ref
src/rgw/driver/rados/rgw_dedup.h Dedup interface updated to accept both src_tag and tgt_tag
src/rgw/driver/rados/rgw_dedup.cc Dedup implementation updated to pass source and target tags explicitly
src/test/cls_refcount/test_cls_refcount.cc Test suite completely rewritten to test new src_tag functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/cls/refcount/cls_refcount_ops.cc Outdated
@@ -19,15 +19,15 @@ list<cls_refcount_get_op> cls_refcount_get_op::generate_test_instances()
ls.emplace_back();
ls.emplace_back();
ls.back().tag = "foo";
ls.back().implicit_ref = true;
// TBD: we can't pass paramters here so there is no way to get the src_tag ???

Copilot AI Oct 21, 2025

Copy link

Choose a reason for hiding this comment

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

Corrected spelling of 'paramters' to 'parameters'.

Suggested change
// TBD: we can't pass paramters here so there is no way to get the src_tag ???
// TBD: we can't pass parameters here so there is no way to get the src_tag ???

Copilot uses AI. Check for mistakes.
Comment thread src/cls/refcount/cls_refcount.cc Outdated
return -EINVAL;
// if refcount was not set on this object it can remove with no further checks
if (objr.refs.empty()) {
CLS_LOG(20, "cls_rc_refcount_put() tag=%s was called without any references\n",

Copilot AI Oct 21, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] The log level 20 is inconsistent with the log level 10 used for the entry log at line 111. Consider using log level 10 for consistency, or document why a higher verbosity level is needed for this particular case.

Suggested change
CLS_LOG(20, "cls_rc_refcount_put() tag=%s was called without any references\n",
CLS_LOG(10, "cls_rc_refcount_put() tag=%s was called without any references\n",

Copilot uses AI. Check for mistakes.
Comment thread src/rgw/driver/rados/rgw_dedup.cc Resolved
@benhanokh benhanokh changed the title remove the wildcard ref used by server-side-copy and dedup replacing it remove the wildcard ref used by cls_refcount Oct 22, 2025
@benhanokh
benhanokh requested a review from Copilot October 22, 2025 10:43

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.

Pull Request Overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

…placing it with explicit source object references.

The change affects server-side copy and deduplication operations by requiring both source and target tags to be specified when managing object reference counts.

Signed-off-by: Gabriel BenHanokh <[email protected]>
@benhanokh

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

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.

Pull Request Overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 10 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/cls/refcount/cls_refcount_client.cc Resolved
Comment thread src/cls/refcount/cls_refcount_client.cc Resolved
Comment thread src/cls/refcount/cls_refcount_client.cc Resolved
Comment thread src/cls/refcount/cls_refcount_client.cc Resolved
Comment thread src/cls/refcount/cls_refcount.cc Resolved
Comment thread src/cls/refcount/cls_refcount.cc Resolved
Comment thread src/cls/refcount/cls_refcount.cc Resolved
Comment thread src/cls/refcount/cls_refcount.cc Resolved
Comment thread src/cls/refcount/cls_refcount.cc Resolved
Comment thread src/cls/refcount/cls_refcount.cc Resolved
@benhanokh

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

1 similar comment
@benhanokh

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@benhanokh benhanokh self-assigned this Oct 23, 2025
@benhanokh
benhanokh marked this pull request as ready for review October 23, 2025 05:55
@benhanokh

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@benhanokh
benhanokh requested a review from Copilot October 23, 2025 05:57

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.

Pull Request Overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

void cls_refcount_read_op::dump(ceph::Formatter *f) const
{
f->dump_int("implicit_ref", (int)implicit_ref);
// there are no data members to dump

Copilot AI Oct 23, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] This comment is now accurate but could be more informative. Consider updating to explain why there are no data members (e.g., 'cls_refcount_read_op has no parameters; it reads all references unconditionally').

Suggested change
// there are no data members to dump
// cls_refcount_read_op has no parameters; it reads all references unconditionally, so there are no data members to dump

Copilot uses AI. Check for mistakes.
@cbodley

cbodley commented Oct 23, 2025

Copy link
Copy Markdown
Contributor

This PR removes the wildcard reference mechanism from the refcount system, replacing it with explicit source object references.

why?

what effect does this have on existing objects?

@cbodley
cbodley requested a review from a team October 23, 2025 13:13
@benhanokh

benhanokh commented Oct 23, 2025 •

Copy link
Copy Markdown
Contributor Author

jenkins test make check

This PR removes the wildcard reference mechanism from the refcount system, replacing it with explicit source object references.

why?

what effect does this have on existing objects?

The current cls_refcount implementation uses an implicit "wildcard" reference for the source object. This means that any reference can be used to remove the "wildcard" reference of the source object, which could lead to an object being lost if the incorrect reference is used.

When we increment the references, we always know the correct reference of the source object, so there is no reason to use a wildcard.

Initially, I anticipated this change would be trivial, but it has resulted in nearly 1000 lines of code modification, with the majority being a rewrite of the unit tests. I still need to implement backward compatibility for existing messages, which will further increase the scope of this change.

@cbodley

cbodley commented Oct 23, 2025

Copy link
Copy Markdown
Contributor

This means that any reference can be used to remove the "wildcard" reference of the source object, which could lead to an object being lost if the incorrect reference is used.

thanks @benhanokh. is this an issue specific to dedup, or is there a way for s3 operations accidentally lose tail objects?

@benhanokh

Copy link
Copy Markdown
Contributor Author

This means that any reference can be used to remove the "wildcard" reference of the source object, which could lead to an object being lost if the incorrect reference is used.

thanks @benhanokh. is this an issue specific to dedup, or is there a way for s3 operations accidentally lose tail objects?

This issue exists today with server-side copy.
Say you have an 8MB SRC-OBJ with SRC-TAIL, you used server -side copy to TGT-OBJ and now both share the SRC-TAIL.
The Copy set 2 refs on SRC-TAIL, a wildcard ref (for the SRC) and tgt-obj-ref
When you remove the TGT-OBJ it will move the tag-obj-ref to "retired" and we will be left with a single active "wildcard" ref.

If some broken code will send cls_refcount_put() request to the SRC-TAIL object it will be removed evenso the SRC-HEAD still exists.

@cbodley

cbodley commented Oct 23, 2025

Copy link
Copy Markdown
Contributor

This issue exists today with server-side copy.
If some broken code ...

i understand the risk, but i don't think this has come up since 2017 in https://tracker.ceph.com/issues/20107#note-10

Initially, I anticipated this change would be trivial, but it has resulted in nearly 1000 lines of code modification, with the majority being a rewrite of the unit tests. I still need to implement backward compatibility for existing messages, which will further increase the scope of this change.

to me, the churn from this would present a greater risk that doesn't feel well-motivated

@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 Dec 22, 2025
@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no activity for 90 days. Please feel free to reopen this pull request (or open a new one) if the proposed change is still appropriate. Thank you for your contribution!

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.

3 participants