]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/common/operation: don't share op ids between types
authorSamuel Just <sjust@redhat.com>
Fri, 30 Sep 2022 05:30:42 +0000 (22:30 -0700)
committerSamuel Just <sjust@redhat.com>
Sat, 1 Oct 2022 22:12:08 +0000 (15:12 -0700)
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 <sjust@redhat.com>
src/crimson/common/operation.h

index 9922ddccfc26c26c4f83d156c64f7b92f0cab551..73ee6919c9ae90cf76537b9c855ef99bdb4d42ce 100644 (file)
@@ -392,21 +392,17 @@ public:
 
 template <size_t NUM_REGISTRIES>
 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<id_t>(core) <<
-      (std::numeric_limits<id_t>::digits - 8));
-  }
+    : next_id(static_cast<id_t>(core) <<
+             (std::numeric_limits<id_t>::digits - 8))
+  {}
 
   template <size_t REGISTRY_INDEX>
   const op_list& get_registry() const {