-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(csi driver): make mount and unmounts non-blocking #888
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ use csi_driver::PublishParams; | |
use glob::glob; | ||
use nvmeadm::nvmf_subsystem::Subsystem; | ||
use regex::Regex; | ||
use tokio::task::spawn_blocking; | ||
use tracing::warn; | ||
use udev::{Device, Enumerator}; | ||
use url::Url; | ||
|
@@ -206,12 +207,17 @@ impl Attach for NvmfAttach { | |
.hostnqn(self.hostnqn.clone()) | ||
.keep_alive_tmo(self.keep_alive_tmo) | ||
.build()?; | ||
match ca.connect() { | ||
// Should we remove this arm? | ||
Err(NvmeError::ConnectInProgress) => Ok(()), | ||
Err(err) => Err(err.into()), | ||
Ok(_) => Ok(()), | ||
} | ||
|
||
spawn_blocking(move || { | ||
match ca.connect() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that this is not blocking, what happens if the future is dropped but the connect/disconnect ioctls are still in progress. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I understood, tasks spawned by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if the join handle is dropped? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The ca.connect() will be non-cancellable because it's blocking and stuck in ioctl anyway but the code which is calling this is cancellable and will potentially re-run again, and schedule another cannot, or potentially a disconnect. Ah, we could ref-count the volume guard in the sawn_blocking? |
||
// Should we remove this arm? | ||
Err(NvmeError::ConnectInProgress) => Ok(()), | ||
Err(err) => Err(err.into()), | ||
Ok(_) => Ok(()), | ||
} | ||
}) | ||
.await | ||
.map_err(|error| DeviceError::new(&error.to_string()))? | ||
} | ||
Err(err) => Err(err.into()), | ||
} | ||
|
@@ -295,14 +301,17 @@ impl NvmfDetach { | |
#[tonic::async_trait] | ||
impl Detach for NvmfDetach { | ||
async fn detach(&self) -> Result<(), DeviceError> { | ||
if disconnect(&self.nqn)? == 0 { | ||
return Err(DeviceError::from(format!( | ||
let nqn = self.nqn.clone(); | ||
spawn_blocking(move || match disconnect(&nqn) { | ||
Ok(0) => Err(DeviceError::from(format!( | ||
"nvmf disconnect {} failed: no device found", | ||
self.nqn | ||
))); | ||
} | ||
|
||
Ok(()) | ||
nqn | ||
))), | ||
Err(error) => Err(error.into()), | ||
Ok(_) => Ok(()), | ||
}) | ||
.await | ||
.map_err(|error| DeviceError::from(error.to_string()))? | ||
} | ||
|
||
fn devname(&self) -> DeviceName { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍