From: Ronen Friedman Date: Wed, 16 Oct 2024 12:04:38 +0000 (-0500) Subject: osd/scrub: make sched-targets comparator transitive X-Git-Tag: v20.0.0~755^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9f3e18b97cb0930bcbc3145301f9479bb5c3ce4e;p=ceph.git osd/scrub: make sched-targets comparator transitive 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 --- diff --git a/src/osd/scrubber/scrub_queue_entry.h b/src/osd/scrubber/scrub_queue_entry.h index 03d959769b20..aeb76c104fed 100644 --- a/src/osd/scrubber/scrub_queue_entry.h +++ b/src/osd/scrubber/scrub_queue_entry.h @@ -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));