Skip to content

interval_map: Add non-const iterators - #63844

Merged
aainscow merged 2 commits into
ceph:mainfrom
aainscow:internal_map_non_const_iters
Jul 10, 2025
Merged

aainscow merged 2 commits into
ceph:mainfrom
aainscow:internal_map_non_const_iters

Conversation

@aainscow

@aainscow aainscow commented Jun 10, 2025 •

Copy link
Copy Markdown
Contributor

The interval_map code cannot cope with iterators which change the size of an interval. Due to this, they use const iterators. However, many other modifications to intervals ARE ok and more efficient, nicer looking code can be written with them.

This PR adds non-const iterators, but adds some policing that the size of the bufferlist has not changed over the interval.

Everything is hidden behind a template, as this changes the behaviour of interval map in a way that we don't want to use without careful testing of each instance.

Tracker: https://tracker.ceph.com/issues/72366

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

@aainscow
aainscow requested a review from aclamk June 10, 2025 12:46
@aainscow aainscow changed the title interval_map: Add non_const iterators interval_map: Add non-const iterators Jun 10, 2025
@aainscow
aainscow requested a review from a team as a code owner June 10, 2025 12:48
@github-actions github-actions Bot added the core label Jun 10, 2025
aainscow added 2 commits June 13, 2025 15:34
The interval_map code cannot cope with iterators which change the size
of an interval. Due to this, they use const iterators. However, many
other modifications to intervals ARE ok and more efficient, nicer
looking code can be written with them.

This PR adds non-const iterators, but also adds some policing that the
size of the bufferlist has not changed over the interval.

Everything is hidden behind a template, as this changes the behaviour of interval map in a way that we don't want to use without careful testing of each instance.

Signed-off-by: Alex Ainscow <[email protected]>
@aainscow
aainscow force-pushed the internal_map_non_const_iters branch from e2983b8 to 9859e8d Compare June 13, 2025 14:35
Comment thread src/common/interval_map.h
* behaviour.
*/
if (!end && get_val().length() != get_len()) {
throw std::out_of_range("buffer length has changed");

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.

Do we really envision recovery from such an situation.
If not, then perhaps ceph_abort_msg() would be simpler.

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.

ceph aborts and asserts are hard to unit test, which is why this is an exception. I don't really expect anyone to handle this.

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.

I am open to suggestions of how to handle abort, while keeping the unit tests which check that this exception fires.

Comment thread src/common/interval_map.h
* to be merged into the next one, which would allow for unexpected
* behaviour.
*/
if (!end && get_val().length() != get_len()) {

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.

IIUC this is supposed to detect change in the size of the previous element (the one the iterator leaves).

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.

Correct. The idea is that when the client increments the iterator, that the length of the bufferlist has not changed. All other aspects of the bufferlist can be changed (contents, internal structure, zeros, etc... )

@yuriw

yuriw commented Jul 9, 2025

Copy link
Copy Markdown
Contributor

jenkins test api

@yuriw

yuriw commented Jul 9, 2025

Copy link
Copy Markdown
Contributor

@aainscow

aainscow commented Jul 9, 2025

Copy link
Copy Markdown
Contributor Author

Jenkins test api

@aainscow
aainscow merged commit 649f11d into ceph:main Jul 10, 2025
@aainscow

aainscow commented Aug 1, 2025

Copy link
Copy Markdown
Contributor Author

This is a pre-req for the zero-detect work.

@aainscow aainscow added the no-backport-required Label that can be optionally added to show that we do not need to backport. label May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common core needs-qa no-backport-required Label that can be optionally added to show that we do not need to backport. ready-to-merge TESTED tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants