From 2e8c73841465e6f9512e72b8a2bd885a20f4fbc2 Mon Sep 17 00:00:00 2001 From: Ronen Friedman Date: Mon, 29 Sep 2025 09:36:14 -0500 Subject: [PATCH] osd: hash function for eversion_t (required by ModeCollector when using eversion_t as key type) Signed-off-by: Ronen Friedman --- src/osd/osd_types.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 4012d727d6e..f28c31f57bc 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -985,6 +985,19 @@ inline std::ostream& operator<<(std::ostream& out, const eversion_t& e) { return out << e.epoch << "'" << e.version; } +namespace std { +template <> +struct hash { + size_t operator()(const eversion_t& ev) const noexcept + { + // Combine epoch and version with a simple shift-based mix + // This is fast and works well when differences are small + return (size_t)ev.epoch ^ ((size_t)ev.version << 8 | + (size_t)ev.version >> (sizeof(size_t) * 8 - 8)); + } +}; +} // namespace std + /** * objectstore_perf_stat_t * -- 2.39.5