Repository navigation
mon: fix validation of fingerprint_algorithm and dedup_chunk_algorithm - #74038
Open
yulongshi0816 wants to merge 1 commit into
Open
yulongshi0816 wants to merge 1 commit into
yulongshi0816 wants to merge 1 commit into
Conversation
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]>
|
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 |
kamoltat
approved these changes
Nov 25, 2026
kamoltat
left a comment
Member
There was a problem hiding this comment.
LGTM, change is simple with test script to validate the change, no encoding bumps needed.
Member
|
@yulongshi0816 thank you for your contribution! |
Contributor
|
This PR has been added to wip-bharath3-testing-20261127.055027-main. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pg_pool_t::get_fingerprint_from_str()andpg_pool_t::get_dedup_chunk_algorithm_from_str()return 0 (TYPE_FINGERPRINT_NONE/TYPE_DEDUP_CHUNK_NONE) fornoneand -1 for an unknown value.OSDMonitor::prepare_command_pool_set()checked the result withif (!alg), so the check was inverted:ceph osd pool set <pool> fingerprint_algorithm nonefails withunrecognized fingerprint_algorithm 'none';ceph osd pool set <pool> fingerprint_algorithm foosucceeds and storesfooin the pool.get_fingerprint_type()then returns -1, whichPrimaryLogPG::get_fpoid_from_chunk()does not treat asTYPE_FINGERPRINT_NONE, so it reachesassert(0)in thedefault:branch of its switch.dedup_chunk_algorithmhas the same problem, and its error message namedfingerprint_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_INVALIDandTYPE_DEDUP_CHUNK_INVALID(-1), returns them from the parsers for unknown values, and makes the monitor compare against them. All existingswitchstatements on these enums already have adefault:case, so they are not affected.It also fixes the error message, and adds cases to
test_mon_osd_pool_setinqa/workunits/cephtool/test.sh: for both options,noneand a valid value are accepted,foois rejected and leaves the value unchanged, andunsetclears 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_setpasses. With the unpatchedceph-mon, the same test fails at the first new case (fingerprint_algorithm none).Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.