Skip to content

Commit

Permalink
fix(nexus): relaxed error unwraps in nexus destroy
Browse files Browse the repository at this point in the history
This fix eliminates a panic which happens upon unconditional
unwrap of the result of NVMe subsystem unsharing, which is
done as part of the nexus destroy logic.
Now all errors that occur upon NVMe subsystem shutdown will
be propagated to the caller of the Nexus destroy() function.

Signed-off-by: Mikhail Tcymbaliuk <[email protected]>
  • Loading branch information
mtzaurus committed Oct 17, 2022
1 parent 94c5a3e commit f211461
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mayastor/src/bdev/nexus/nexus_bdev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ impl<'n> Nexus<'n> {
pub async fn destroy(mut self: Pin<&mut Self>) -> Result<(), Error> {
info!("Destroying nexus {}", self.name);

self.as_mut().destroy_shares().await;
self.as_mut().destroy_shares().await?;

// wait for all rebuild jobs to be cancelled before proceeding with the
// destruction of the nexus
Expand Down
8 changes: 5 additions & 3 deletions mayastor/src/bdev/nexus/nexus_share.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,15 @@ impl<'n> Nexus<'n> {
}

/// Shutdowns all shares.
pub(crate) async fn destroy_shares(mut self: Pin<&mut Self>) {
pub(crate) async fn destroy_shares(
mut self: Pin<&mut Self>,
) -> Result<(), Error> {
let _ = self.as_mut().unshare_nexus().await;
assert_eq!(self.share_handle, None);

// no-op when not shared and will be removed once the old share bits are
// gone
self.as_mut().unshare().await.unwrap();
// gone. Ignore device name provided in case of successful unsharing.
self.as_mut().unshare().await.map(|_| ())
}

/// TODO
Expand Down

0 comments on commit f211461

Please sign in to comment.