Skip to content

Commit 71280ba

Browse files
author
mayastor-bors
committed
Try #1711:
2 parents 00d90e0 + 182d2f7 commit 71280ba

File tree

7 files changed

+41
-40
lines changed

7 files changed

+41
-40
lines changed

io-engine/src/bdev/nexus/nexus_bdev_children.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ impl<'n> Nexus<'n> {
900900
nexus_name,
901901
child_device, "Unplugging nexus child device",
902902
);
903-
child.unplug();
903+
child.unplug().await;
904904
}
905905
None => {
906906
warn!(

io-engine/src/bdev/nexus/nexus_child.rs

+10-20
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ use crate::{
2424
BlockDeviceHandle,
2525
CoreError,
2626
DeviceEventSink,
27-
Reactor,
28-
Reactors,
2927
VerboseError,
3028
},
3129
eventing::replica_events::state_change_event_meta,
@@ -1109,7 +1107,7 @@ impl<'c> NexusChild<'c> {
11091107
/// underlying device is removed.
11101108
///
11111109
/// Note: The descriptor *must* be dropped for the unplug to complete.
1112-
pub(crate) fn unplug(&mut self) {
1110+
pub(crate) async fn unplug(&mut self) {
11131111
info!("{self:?}: unplugging child...");
11141112

11151113
let state = self.state();
@@ -1139,12 +1137,10 @@ impl<'c> NexusChild<'c> {
11391137
// device-related events directly.
11401138
if state != ChildState::Faulted(FaultReason::IoError) {
11411139
let nexus_name = self.parent.clone();
1142-
Reactor::block_on(async move {
1143-
match nexus_lookup_mut(&nexus_name) {
1144-
Some(n) => n.reconfigure(DrEvent::ChildUnplug).await,
1145-
None => error!("Nexus '{nexus_name}' not found"),
1146-
}
1147-
});
1140+
match nexus_lookup_mut(&nexus_name) {
1141+
Some(n) => n.reconfigure(DrEvent::ChildUnplug).await,
1142+
None => error!("Nexus '{nexus_name}' not found"),
1143+
}
11481144
}
11491145

11501146
if is_destroying {
@@ -1154,21 +1150,15 @@ impl<'c> NexusChild<'c> {
11541150
}
11551151

11561152
self.unplug_complete();
1157-
info!("{self:?}: child successfully unplugged");
11581153
}
11591154

11601155
/// Signal that the child unplug is complete.
11611156
fn unplug_complete(&self) {
1162-
let sender = self.remove_channel.0.clone();
1163-
let name = self.name.clone();
1164-
Reactors::current().send_future(async move {
1165-
if let Err(e) = sender.send(()).await {
1166-
error!(
1167-
"Failed to send unplug complete for child '{}': {}",
1168-
name, e
1169-
);
1170-
}
1171-
});
1157+
if self.remove_channel.0.close() {
1158+
info!("{self:?}: child successfully unplugged");
1159+
} else {
1160+
error!("{self:?} child was already unplugged");
1161+
}
11721162
}
11731163

11741164
/// create a new nexus child

io-engine/src/bdev/nvmx/controller.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1071,8 +1071,11 @@ pub(crate) mod options {
10711071
self.admin_timeout_ms = Some(timeout);
10721072
self
10731073
}
1074-
pub fn with_fabrics_connect_timeout_us(mut self, timeout: u64) -> Self {
1075-
self.fabrics_connect_timeout_us = Some(timeout);
1074+
pub fn with_fabrics_connect_timeout_us<T: Into<Option<u64>>>(
1075+
mut self,
1076+
timeout: T,
1077+
) -> Self {
1078+
self.fabrics_connect_timeout_us = timeout.into();
10761079
self
10771080
}
10781081

io-engine/src/bdev/nvmx/qpair.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,9 @@ impl<'a> Connection<'a> {
467467
0 => Ok(false),
468468
// Connection is still in progress, keep polling.
469469
1 => Ok(true),
470-
// Error occured during polling.
470+
// Error occurred during polling.
471471
e => {
472-
let e = Errno::from_i32(-e);
472+
let e = Errno::from_i32(e.abs());
473473
error!(?self, "I/O qpair async connection polling error: {e}");
474474
Err(e)
475475
}

io-engine/src/bdev/nvmx/uri.rs

+6
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@ impl<'probe> NvmeControllerContext<'probe> {
227227
)
228228
.with_transport_retry_count(
229229
Config::get().nvme_bdev_opts.transport_retry_count as u8,
230+
)
231+
.with_fabrics_connect_timeout_us(
232+
crate::subsys::config::opts::try_from_env(
233+
"NVMF_FABRICS_CONNECT_TIMEOUT",
234+
3_000_000,
235+
),
230236
);
231237

232238
let hostnqn = template.hostnqn.clone().or_else(|| {

io-engine/src/subsys/config/opts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ pub struct NvmfTcpTransportOpts {
156156
}
157157

158158
/// try to read an env variable or returns the default when not found
159-
fn try_from_env<T>(name: &str, default: T) -> T
159+
pub(crate) fn try_from_env<T>(name: &str, default: T) -> T
160160
where
161161
T: FromStr + Display + Copy,
162162
<T as FromStr>::Err: Debug + Display,

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)