Skip to content

mon: fix validation of fingerprint_algorithm and dedup_chunk_algorithm - #74038

Open
yulongshi0816 wants to merge 1 commit into
ceph:mainfrom
yulongshi0816:wip-mon-pool-dedup-algo-none
Open

yulongshi0816 wants to merge 1 commit into
ceph:mainfrom
yulongshi0816:wip-mon-pool-dedup-algo-none

Conversation

@yulongshi0816

Copy link
Copy Markdown
Contributor

pg_pool_t::get_fingerprint_from_str() and pg_pool_t::get_dedup_chunk_algorithm_from_str() return 0 (TYPE_FINGERPRINT_NONE / TYPE_DEDUP_CHUNK_NONE) for none and -1 for an unknown value. OSDMonitor::prepare_command_pool_set() checked the result with if (!alg), so the check was inverted:

  • ceph osd pool set <pool> fingerprint_algorithm none fails with unrecognized fingerprint_algorithm 'none';
  • ceph osd pool set <pool> fingerprint_algorithm foo succeeds and stores foo in the pool. get_fingerprint_type() then returns -1, which PrimaryLogPG::get_fpoid_from_chunk() does not treat as TYPE_FINGERPRINT_NONE, so it reaches assert(0) in the default: branch of its switch.

dedup_chunk_algorithm has the same problem, and its error message named fingerprint_algorithm.

Since -1 is outside the range of values of both enums (neither has a fixed underlying type), casting it to them is undefined behaviour. This change adds TYPE_FINGERPRINT_INVALID and TYPE_DEDUP_CHUNK_INVALID (-1), returns them from the parsers for unknown values, and makes the monitor compare against them. All existing switch statements on these enums already have a default: case, so they are not affected.

It also fixes the error message, and adds cases to test_mon_osd_pool_set in qa/workunits/cephtool/test.sh: for both options, none and a valid value are accepted, foo is rejected and leaves the value unchanged, and unset clears it.

This replaces #66696, which was closed as stale.

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

Testing

On a vstart cluster (1 mon, 1 mgr, 3 memstore OSDs) built from main (46873b8) with this change applied, qa/workunits/cephtool/test.sh -t mon_osd_pool_set passes. With the unpatched ceph-mon, the same test fails at the first new case (fingerprint_algorithm none).

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.

pg_pool_t::get_fingerprint_from_str() and
get_dedup_chunk_algorithm_from_str() return 0 for "none" and -1 for an
unknown value, but prepare_command_pool_set() checked the result with
"!alg". So "ceph osd pool set <pool> fingerprint_algorithm none" was
rejected, while any unknown string was accepted and stored in the pool.
The OSD then treats the stored value as an unknown fingerprint type.

-1 is also outside the range of values of both enums, so casting it to
them is undefined behaviour. Add TYPE_FINGERPRINT_INVALID and
TYPE_DEDUP_CHUNK_INVALID (-1), return them for unknown values, and
compare with them in the monitor. Also fix the error message for
dedup_chunk_algorithm, and add tests to cephtool.

Fixes: https://tracker.ceph.com/issues/83301
Signed-off-by: yulong Shi <[email protected]>
@yulongshi0816
yulongshi0816 requested a review from a team as a code owner November 19, 2026 01:53
@github-actions

Copy link
Copy Markdown

Thank you for your contribution. Since you are not yet a member of the Ceph organization with write permissions on ceph/ceph.git, our CI will not automatically run. Any member of the Ceph organization may label this PR ci-approved to allow Jenkins CI jobs to run.

@kamoltat kamoltat 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, change is simple with test script to validate the change, no encoding bumps needed.

@kamoltat

Copy link
Copy Markdown
Member

@yulongshi0816 thank you for your contribution!

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath3-testing-20261127.055027-main.

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