From: Ronen Friedman Date: Mon, 29 Sep 2025 14:36:14 +0000 (-0500) Subject: osd: hash function for eversion_t X-Git-Tag: testing/wip-vshankar-testing-20260129.051214-debug~1^2~5^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2e8c73841465e6f9512e72b8a2bd885a20f4fbc2;p=ceph-ci.git osd: hash function for eversion_t (required by ModeCollector when using eversion_t as key type) Signed-off-by: Ronen Friedman --- 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 *