From 8456ea5e40782ea16e4c5eaf3e95cda64f7699f0 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Thu, 29 Sep 2022 22:30:42 -0700 Subject: [PATCH] crimson/common/operation: don't share op ids between types This way, a particular id will be unique regardless of op type and we can use it as an unambiguous identifier. Signed-off-by: Samuel Just --- src/crimson/common/operation.h | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/crimson/common/operation.h b/src/crimson/common/operation.h index 9922ddccfc26..73ee6919c9ae 100644 --- a/src/crimson/common/operation.h +++ b/src/crimson/common/operation.h @@ -392,21 +392,17 @@ public: template class OperationRegistryT : public OperationRegistryI { + Operation::id_t next_id = 0; std::array< op_list, NUM_REGISTRIES > registries; - std::array< - uint64_t, - NUM_REGISTRIES - > op_id_counters = {}; - protected: void do_register(Operation *op) final { const auto op_type = op->get_type(); registries[op_type].push_back(*op); - op->set_id(++op_id_counters[op_type]); + op->set_id(++next_id); } bool registries_empty() const final { @@ -418,13 +414,12 @@ protected: } protected: - OperationRegistryT(core_id_t core) { + OperationRegistryT(core_id_t core) // Use core to initialize upper 8 bits of counters to ensure that // ids generated by different cores are disjoint - op_id_counters.fill( - static_cast(core) << - (std::numeric_limits::digits - 8)); - } + : next_id(static_cast(core) << + (std::numeric_limits::digits - 8)) + {} template const op_list& get_registry() const { -- 2.47.3