From 7c1e9773653f2575d6691e268a4266f22ba3b61e Mon Sep 17 00:00:00 2001 From: Sun Yuechi Date: Thu, 25 Jun 2026 22:15:46 +0800 Subject: [PATCH] osd: fix osd_reqid_t comparison strict weak ordering The 'l.inc < r.inc' term in operator< lacked an 'l.name == r.name' guard, breaking antisymmetry, so it was not a valid strict weak ordering. Replace it with std::tie. The only ordered container keyed on osd_reqid_t is ECInject::write_failures0_reqid (QA/debug error injection), so no production code path is affected and no backport is needed. Signed-off-by: Sun Yuechi --- src/osd/osd_types.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 1065066948e..977af60bed3 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #ifdef WITH_CRIMSON @@ -240,12 +241,10 @@ inline bool operator!=(const osd_reqid_t& l, const osd_reqid_t& r) { return (l.name != r.name) || (l.inc != r.inc) || (l.tid != r.tid); } inline bool operator<(const osd_reqid_t& l, const osd_reqid_t& r) { - return (l.name < r.name) || (l.inc < r.inc) || - (l.name == r.name && l.inc == r.inc && l.tid < r.tid); + return std::tie(l.name, l.inc, l.tid) < std::tie(r.name, r.inc, r.tid); } inline bool operator<=(const osd_reqid_t& l, const osd_reqid_t& r) { - return (l.name < r.name) || (l.inc < r.inc) || - (l.name == r.name && l.inc == r.inc && l.tid <= r.tid); + return std::tie(l.name, l.inc, l.tid) <= std::tie(r.name, r.inc, r.tid); } inline bool operator>(const osd_reqid_t& l, const osd_reqid_t& r) { return !(l <= r); } inline bool operator>=(const osd_reqid_t& l, const osd_reqid_t& r) { return !(l < r); } -- 2.47.3