]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/scrub: make sched-targets comparator transitive
authorRonen Friedman <rfriedma@redhat.com>
Wed, 16 Oct 2024 12:04:38 +0000 (07:04 -0500)
committerRonen Friedman <rfriedma@redhat.com>
Tue, 22 Oct 2024 09:39:54 +0000 (04:39 -0500)
The comparator used to sort the scrub targets wasn't transitive, which
can lead to undefined behavior (and likely - to a crash of the sort
algorithm in some implementations). That - due to the clause comparing
the two targets of the same PG.

This commit fixes the comparator. The sorted queue is no longer
guaranteed to have a ripe deep target before the corresponding
shallow one, which is less than optimal - but it won't crash.

Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
src/osd/scrubber/scrub_queue_entry.h

index 03d959769b20651f444c392f606dd0d07a14bb07..aeb76c104fed9fed79c594c36025de7f344ff706 100644 (file)
@@ -98,11 +98,6 @@ static inline std::weak_ordering cmp_ripe_entries(
   if (auto cmp = r.urgency <=> l.urgency; cmp != 0) {
     return cmp;
   }
-  // if we are comparing the two targets of the same PG, once both are
-  // ripe - the 'deep' scrub is considered 'higher' than the 'shallow' one.
-  if (l.pgid == r.pgid && r.level < l.level) {
-    return std::weak_ordering::less;
-  }
   // the 'utime_t' operator<=> is 'partial_ordering', it seems.
   if (auto cmp = std::weak_order(
          double(l.schedule.scheduled_at), double(r.schedule.scheduled_at));