Skip to content

Commit

Permalink
Try #1711:
Browse files Browse the repository at this point in the history
  • Loading branch information
mayastor-bors committed Aug 6, 2024
2 parents 00d90e0 + 8893313 commit f8cb7f2
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 42 deletions.
2 changes: 1 addition & 1 deletion io-engine/src/bdev/nexus/nexus_bdev_children.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ impl<'n> Nexus<'n> {
nexus_name,
child_device, "Unplugging nexus child device",
);
child.unplug();
child.unplug().await;
}
None => {
warn!(
Expand Down
34 changes: 12 additions & 22 deletions io-engine/src/bdev/nexus/nexus_child.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ use crate::{
BlockDeviceHandle,
CoreError,
DeviceEventSink,
Reactor,
Reactors,
VerboseError,
},
eventing::replica_events::state_change_event_meta,
Expand Down Expand Up @@ -1109,7 +1107,7 @@ impl<'c> NexusChild<'c> {
/// underlying device is removed.
///
/// Note: The descriptor *must* be dropped for the unplug to complete.
pub(crate) fn unplug(&mut self) {
pub(crate) async fn unplug(&mut self) {
info!("{self:?}: unplugging child...");

let state = self.state();
Expand Down Expand Up @@ -1139,12 +1137,10 @@ impl<'c> NexusChild<'c> {
// device-related events directly.
if state != ChildState::Faulted(FaultReason::IoError) {
let nexus_name = self.parent.clone();
Reactor::block_on(async move {
match nexus_lookup_mut(&nexus_name) {
Some(n) => n.reconfigure(DrEvent::ChildUnplug).await,
None => error!("Nexus '{nexus_name}' not found"),
}
});
match nexus_lookup_mut(&nexus_name) {
Some(n) => n.reconfigure(DrEvent::ChildUnplug).await,
None => error!("Nexus '{nexus_name}' not found"),
}
}

if is_destroying {
Expand All @@ -1153,22 +1149,16 @@ impl<'c> NexusChild<'c> {
self.device_descriptor.take();
}

self.unplug_complete();
info!("{self:?}: child successfully unplugged");
self.unplug_complete().await;
}

/// Signal that the child unplug is complete.
fn unplug_complete(&self) {
let sender = self.remove_channel.0.clone();
let name = self.name.clone();
Reactors::current().send_future(async move {
if let Err(e) = sender.send(()).await {
error!(
"Failed to send unplug complete for child '{}': {}",
name, e
);
}
});
async fn unplug_complete(&self) {
if let Err(error) = self.remove_channel.0.send(()).await {
info!("{self:?}: failed to send unplug complete: {error}");
} else {
info!("{self:?}: child successfully unplugged");
}
}

/// create a new nexus child
Expand Down
7 changes: 5 additions & 2 deletions io-engine/src/bdev/nvmx/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1071,8 +1071,11 @@ pub(crate) mod options {
self.admin_timeout_ms = Some(timeout);
self
}
pub fn with_fabrics_connect_timeout_us(mut self, timeout: u64) -> Self {
self.fabrics_connect_timeout_us = Some(timeout);
pub fn with_fabrics_connect_timeout_us<T: Into<Option<u64>>>(
mut self,
timeout: T,
) -> Self {
self.fabrics_connect_timeout_us = timeout.into();
self
}

Expand Down
4 changes: 2 additions & 2 deletions io-engine/src/bdev/nvmx/qpair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,9 @@ impl<'a> Connection<'a> {
0 => Ok(false),
// Connection is still in progress, keep polling.
1 => Ok(true),
// Error occured during polling.
// Error occurred during polling.
e => {
let e = Errno::from_i32(-e);
let e = Errno::from_i32(e.abs());
error!(?self, "I/O qpair async connection polling error: {e}");
Err(e)
}
Expand Down
6 changes: 6 additions & 0 deletions io-engine/src/bdev/nvmx/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ impl<'probe> NvmeControllerContext<'probe> {
)
.with_transport_retry_count(
Config::get().nvme_bdev_opts.transport_retry_count as u8,
)
.with_fabrics_connect_timeout_us(
crate::subsys::config::opts::try_from_env(
"NVMF_FABRICS_CONNECT_TIMEOUT",
1_000_000,
),
);

let hostnqn = template.hostnqn.clone().or_else(|| {
Expand Down
2 changes: 1 addition & 1 deletion io-engine/src/subsys/config/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ pub struct NvmfTcpTransportOpts {
}

/// try to read an env variable or returns the default when not found
fn try_from_env<T>(name: &str, default: T) -> T
pub(crate) fn try_from_env<T>(name: &str, default: T) -> T
where
T: FromStr + Display + Copy,
<T as FromStr>::Err: Debug + Display,
Expand Down
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 f8cb7f2

Please sign in to comment.