Skip to content

Commit

Permalink
fix(nvmf/target): remove usage of block_on
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
tiagolobocastro committed Aug 6, 2024
1 parent ad5c31a commit 8893313
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions io-engine/src/subsys/nvmf/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 8893313

Please sign in to comment.