]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
async/rdma: initialize worker in RDMAStack::create_worker()
authorKefu Chai <kchai@redhat.com>
Wed, 24 Feb 2021 04:06:45 +0000 (12:06 +0800)
committeryite.gu <yitegu0@gmail.com>
Sun, 4 Feb 2024 03:21:17 +0000 (11:21 +0800)
in ff65c800b3e1f3f7e3989223b9bde4cbbaf5c076, we moved create_worker()
call out of the constructor to avoid calling virtual functions in
constructor. but this created a regression where RDMAStack's constructor
tries to reference its workers not yet created.

in this change, the workers are initialized right after they are
created.

Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 103ec86cfab3e6807602b128346212bc8eb0d88d)

src/msg/async/rdma/RDMAStack.cc

index cf16bbf96d302a9eefdfb8a8fa7a98055aed7c2b..32618c72b1bb8dcd86bb2450a6c491529b9f3601 100644 (file)
@@ -783,13 +783,6 @@ RDMAStack::RDMAStack(CephContext *cct)
     rdma_dispatcher(std::make_shared<RDMADispatcher>(cct, ib))
 {
   ldout(cct, 20) << __func__ << " constructing RDMAStack..." << dendl;
-
-  unsigned num = get_num_worker();
-  for (unsigned i = 0; i < num; ++i) {
-    RDMAWorker* w = dynamic_cast<RDMAWorker*>(get_worker(i));
-    w->set_dispatcher(rdma_dispatcher);
-    w->set_ib(ib);
-  }
   ldout(cct, 20) << " creating RDMAStack:" << this << " with dispatcher:" << rdma_dispatcher.get() << dendl;
 }
 
@@ -802,7 +795,10 @@ RDMAStack::~RDMAStack()
 
 Worker* RDMAStack::create_worker(CephContext *c, unsigned worker_id)
 {
-  return new RDMAWorker(c, worker_id);
+  auto w = new RDMAWorker(c, worker_id);
+  w->set_dispatcher(rdma_dispatcher);
+  w->set_ib(ib);
+  return w;
 }
 
 void RDMAStack::spawn_worker(unsigned i, std::function<void ()> &&func)