Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] include/interval_set: iterate until p->first < start #53063

Closed

Conversation

dparmar18
Copy link
Contributor

Contribution Guidelines

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
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows

@dparmar18
Copy link
Contributor Author

there are a couple of crash trackers where assertion fails at ceph_assert(p->first <= start); in void erase(). The places are different but the assertion failure is same. Failures at these places will definitely be addressed but I feel these helpers need some changes too.

Existing code does decrement by one in case the key is gt than start but only once and so the decremented element's key should still be gt than start. I.e. the single decrement might not be enough, therefore keep decrementing until p->first is less than start; break and return.

https://tracker.ceph.com/issues/62356
https://tracker.ceph.com/issues/54943
https://tracker.ceph.com/issues/60241

@dparmar18
Copy link
Contributor Author

@lxbsz

if (p->first + p->second <= start)
++p; // it doesn't.
while (p != m.begin()) {
if (p->first <= start) {
Copy link
Member

Choose a reason for hiding this comment

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

This is buggy. Old code will make sure that the p won't be .end(), but yours seems will crash ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so if we dont hit this if {} then it assume either p->first > start or p==m.end(), so in this case we decrement --p

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i.e. it wont hit end() here either

Copy link
Member

Choose a reason for hiding this comment

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

Won't the m.lower_bound() return .end() if it couldn't find any item ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay so you're implying that we should just return directly in case we dont find anything in the map, right? you're correct, i need to handle this edge case. decrementing in case there is nothing would be disastrous

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, the corner edge case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

check now

Copy link
Member

Choose a reason for hiding this comment

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

In erase() it will check ceph_assert(p != m.end()); . Your above change could return .end().

@vshankar vshankar requested a review from a team August 21, 2023 12:37
@vshankar vshankar added the cephfs Ceph File System label Aug 21, 2023
Signed-off-by: Dhairya Parmar <dparmar@redhat.com>
@dparmar18 dparmar18 force-pushed the iterate_instead_of_single_decrement branch from 60ddf0c to 0a5d593 Compare August 21, 2023 15:13
@dparmar18
Copy link
Contributor Author

This PR doesn't make sense now, the working of lower_bound is such that it will return an iterator pointing to an element that is just greater than the start, so the p doesn't need to be iterated through the entire map; just a single decrement is enough.

This doesn't mean the interval_set code is entirely perfect, the lower_bound() code has to do the adjustments --p / ++p to make sure that element the iterator is pointing to is correct. The code definitely needs some corrections for sure but since the priority is to send a fix for the mentioned crash trackers, i'll leave this for some other day. Closing this PR for now, if anyone has any comments/suggestions to add; please feel free to do it anytime.

@dparmar18 dparmar18 closed this Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cephfs Ceph File System
Projects
None yet
3 participants