From 88933133bfdfee697af35e1f79da44335c4f584e Mon Sep 17 00:00:00 2001 From: Tiago Castro Date: Tue, 6 Aug 2024 09:54:42 +0100 Subject: [PATCH] fix(nvmf/target): remove usage of block_on Split creating from starting the subsystem. This way we can start the subsystem in master reactor, and then move to the next spdk subsystem. Signed-off-by: Tiago Castro --- io-engine/src/subsys/nvmf/target.rs | 30 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/io-engine/src/subsys/nvmf/target.rs b/io-engine/src/subsys/nvmf/target.rs index 56c23f281..25980da47 100644 --- a/io-engine/src/subsys/nvmf/target.rs +++ b/io-engine/src/subsys/nvmf/target.rs @@ -27,7 +27,7 @@ use spdk_rs::libspdk::{ use crate::{ constants::NVME_CONTROLLER_MODEL_ID, - core::{Cores, Mthread, Reactor, Reactors}, + core::{Cores, Mthread, Reactors}, ffihelper::{AsStr, FfiResult}, subsys::{ nvmf::{ @@ -272,7 +272,7 @@ impl Target { /// enable discovery for the target -- note that the discovery system is not /// started - fn enable_discovery(&self) { + fn enable_discovery(&self) -> NvmfSubsystem { debug!("enabling discovery for target"); let discovery = unsafe { NvmfSubsystem::from(spdk_nvmf_subsystem_create( @@ -296,12 +296,7 @@ impl Target { discovery.allow_any(true); - Reactor::block_on(async { - let nqn = discovery.get_nqn(); - if let Err(e) = discovery.start().await { - error!("Error starting subsystem '{}': {}", nqn, e.to_string()); - } - }); + discovery } /// stop all subsystems on this target we are borrowed here @@ -355,13 +350,20 @@ impl Target { /// Final state for the target during init. pub fn running(&mut self) { - self.enable_discovery(); - info!( - "nvmf target accepting new connections and is ready to roll..{}", - '\u{1F483}' - ); + let discovery = self.enable_discovery(); - unsafe { spdk_subsystem_init_next(0) } + Reactors::master().send_future(async move { + let nqn = discovery.get_nqn(); + if let Err(error) = discovery.start().await { + error!("Error starting subsystem '{nqn}': {error}"); + } + + info!( + "nvmf target accepting new connections and is ready to roll..{}", + '\u{1F483}' + ); + unsafe { spdk_subsystem_init_next(0) } + }) } /// Shutdown procedure.