From: Samuel Just Date: Fri, 30 Sep 2022 05:30:42 +0000 (-0700) Subject: crimson/common/operation: don't share op ids between types X-Git-Tag: v18.1.0~1068^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8456ea5e40782ea16e4c5eaf3e95cda64f7699f0;p=ceph.git 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 --- 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 {