From: Kefu Chai Date: Wed, 24 Feb 2021 04:06:45 +0000 (+0800) Subject: async/rdma: initialize worker in RDMAStack::create_worker() X-Git-Tag: v16.2.15~8^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9df11e889b037aa967f08d28dd8b272b8ad3a29d;p=ceph.git async/rdma: initialize worker in RDMAStack::create_worker() 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 (cherry picked from commit 103ec86cfab3e6807602b128346212bc8eb0d88d) --- diff --git a/src/msg/async/rdma/RDMAStack.cc b/src/msg/async/rdma/RDMAStack.cc index cf16bbf96d3..32618c72b1b 100644 --- a/src/msg/async/rdma/RDMAStack.cc +++ b/src/msg/async/rdma/RDMAStack.cc @@ -783,13 +783,6 @@ RDMAStack::RDMAStack(CephContext *cct) rdma_dispatcher(std::make_shared(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(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 &&func)