Skip to content

Commit

Permalink
feat(nvme): On command completion handle zoned nvme errors
Browse files Browse the repository at this point in the history
Zoned related CommandSpecificStatusCodes's should not take out the
nexus.

Signed-off-by: Dennis Maisenbacher <[email protected]>
  • Loading branch information
MaisenbacherD committed Mar 20, 2023
1 parent 76c1a8c commit 56b6aa8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
13 changes: 10 additions & 3 deletions io-engine/src/bdev/nexus/nexus_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use crate::core::{
DeviceCommand,
GenericStatusCode,
IoCompletionStatus,
is_zoned_nvme_error,
IoStatus,
IoSubmissionFailure,
IoType,
Expand Down Expand Up @@ -193,7 +194,6 @@ impl<'n> NexusBio<'n> {
if success {
self.ok_checked();
} else {
// IO failure, mark the IO failed and take the child out
error!(
"{:?}: IO completion for '{}' failed: {:?}, ctx={:?}",
self,
Expand All @@ -202,8 +202,15 @@ impl<'n> NexusBio<'n> {
self.ctx()
);
self.ctx_mut().status = IoStatus::Failed;
self.ctx_mut().must_fail = true;
self.handle_failure(child, status);
if is_zoned_nvme_error(status) {
// Don't take zoned child out on zoned related nvme errors
self.ctx_mut().must_fail = false;
self.ok_checked();
} else {
// IO failure, mark the IO failed and take the child out
self.ctx_mut().must_fail = true;
self.handle_failure(child, status);
}
}
}

Expand Down
19 changes: 18 additions & 1 deletion io-engine/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub use lock::{
};
pub use runtime::spawn;
pub use share::{Protocol, PtplProps, Share, ShareProps, UpdateProps};
pub use spdk_rs::{cpu_cores, GenericStatusCode, IoStatus, IoType, NvmeStatus};
pub use spdk_rs::{cpu_cores, GenericStatusCode, IoStatus, IoType, NvmeStatus, CommandSpecificStatusCode};
pub use thread::Mthread;

use crate::subsys::NvmfError;
Expand Down Expand Up @@ -301,6 +301,23 @@ impl From<NvmeStatus> for IoCompletionStatus {
}
}

pub fn is_zoned_nvme_error(status: IoCompletionStatus) -> bool {
match status {
IoCompletionStatus::NvmeError(NvmeStatus::CommandSpecific(cssc)) => match cssc {
CommandSpecificStatusCode::ZonedBoundaryError => true,
CommandSpecificStatusCode::ZoneIsFull => true,
CommandSpecificStatusCode::ZoneIsReadOnly => true,
CommandSpecificStatusCode::ZoneIsOffline => true,
CommandSpecificStatusCode::ZoneInvalidWrite => true,
CommandSpecificStatusCode::TooManyActiveZones => true,
CommandSpecificStatusCode::TooManyOpenZones => true,
CommandSpecificStatusCode::InvalidZoneStateTransition => true,
_ => false,
},
_ => false,
}
}

// TODO move this elsewhere ASAP
pub static PAUSING: AtomicUsize = AtomicUsize::new(0);
pub static PAUSED: AtomicUsize = AtomicUsize::new(0);
Expand Down
2 changes: 1 addition & 1 deletion spdk-rs
Submodule spdk-rs updated 2 files
+1 −0 src/lib.rs
+18 −2 src/nvme.rs

0 comments on commit 56b6aa8

Please sign in to comment.