Skip to content

Commit 8893313

Browse files
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 <tiagolobocastro@gmail.com>
1 parent ad5c31a commit 8893313

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

io-engine/src/subsys/nvmf/target.rs

+16-14
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use spdk_rs::libspdk::{
2727

2828
use crate::{
2929
constants::NVME_CONTROLLER_MODEL_ID,
30-
core::{Cores, Mthread, Reactor, Reactors},
30+
core::{Cores, Mthread, Reactors},
3131
ffihelper::{AsStr, FfiResult},
3232
subsys::{
3333
nvmf::{
@@ -272,7 +272,7 @@ impl Target {
272272

273273
/// enable discovery for the target -- note that the discovery system is not
274274
/// started
275-
fn enable_discovery(&self) {
275+
fn enable_discovery(&self) -> NvmfSubsystem {
276276
debug!("enabling discovery for target");
277277
let discovery = unsafe {
278278
NvmfSubsystem::from(spdk_nvmf_subsystem_create(
@@ -296,12 +296,7 @@ impl Target {
296296

297297
discovery.allow_any(true);
298298

299-
Reactor::block_on(async {
300-
let nqn = discovery.get_nqn();
301-
if let Err(e) = discovery.start().await {
302-
error!("Error starting subsystem '{}': {}", nqn, e.to_string());
303-
}
304-
});
299+
discovery
305300
}
306301

307302
/// stop all subsystems on this target we are borrowed here
@@ -355,13 +350,20 @@ impl Target {
355350

356351
/// Final state for the target during init.
357352
pub fn running(&mut self) {
358-
self.enable_discovery();
359-
info!(
360-
"nvmf target accepting new connections and is ready to roll..{}",
361-
'\u{1F483}'
362-
);
353+
let discovery = self.enable_discovery();
363354

364-
unsafe { spdk_subsystem_init_next(0) }
355+
Reactors::master().send_future(async move {
356+
let nqn = discovery.get_nqn();
357+
if let Err(error) = discovery.start().await {
358+
error!("Error starting subsystem '{nqn}': {error}");
359+
}
360+
361+
info!(
362+
"nvmf target accepting new connections and is ready to roll..{}",
363+
'\u{1F483}'
364+
);
365+
unsafe { spdk_subsystem_init_next(0) }
366+
})
365367
}
366368

367369
/// Shutdown procedure.

0 commit comments

Comments
 (0)