From 5b7ddc4bd2dcdde201ffa2681ede9a0a029bad96 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 2 Jul 2021 22:47:46 +0200 Subject: Adding upstream version 1.14. Signed-off-by: Daniel Baumann --- nvme-status.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) (limited to 'nvme-status.c') diff --git a/nvme-status.c b/nvme-status.c index 1b060dc..270eb06 100644 --- a/nvme-status.c +++ b/nvme-status.c @@ -97,7 +97,6 @@ static inline __u8 nvme_cmd_specific_status_to_errno(__u16 status) case NVME_SC_NS_ALREADY_ATTACHED: return EALREADY; case NVME_SC_THIN_PROV_NOT_SUPP: - case NVME_SC_ONCS_NOT_SUPPORTED: return EOPNOTSUPP; case NVME_SC_DEVICE_SELF_TEST_IN_PROGRESS: return EINPROGRESS; @@ -127,6 +126,22 @@ static inline __u8 nvme_fabrics_status_to_errno(__u16 status) return EIO; } +static inline __u8 nvme_path_status_to_errno(__u16 status) +{ + switch (status) { + case NVME_SC_INTERNAL_PATH_ERROR: + case NVME_SC_ANA_PERSISTENT_LOSS: + case NVME_SC_ANA_INACCESSIBLE: + case NVME_SC_ANA_TRANSITION: + case NVME_SC_CTRL_PATHING_ERROR: + case NVME_SC_HOST_PATHING_ERROR: + case NVME_SC_HOST_CMD_ABORT: + return EACCES; + } + + return EIO; +} + /* * nvme_status_to_errno - It converts given status to errno mapped * @status: >= 0 for nvme status field in completion queue entry, @@ -142,8 +157,11 @@ __u8 nvme_status_to_errno(int status, bool fabrics) if (!status) return 0; - if (status < 0) - return ECOMM; + if (status < 0) { + if (errno) + return errno; + return status; + } /* * The actual status code is enough with masking 0xff, but we need to @@ -152,12 +170,17 @@ __u8 nvme_status_to_errno(int status, bool fabrics) status &= 0x7ff; sct = nvme_status_type(status); - if (sct == NVME_SCT_GENERIC) + switch (sct) { + case NVME_SCT_GENERIC: return nvme_generic_status_to_errno(status); - else if (sct == NVME_SCT_CMD_SPECIFIC && !fabrics) - return nvme_cmd_specific_status_to_errno(status); - else if (sct == NVME_SCT_CMD_SPECIFIC && fabrics) + case NVME_SCT_CMD_SPECIFIC: + if (!fabrics) { + return nvme_cmd_specific_status_to_errno(status); + } return nvme_fabrics_status_to_errno(status); + case NVME_SCT_PATH: + return nvme_path_status_to_errno(status); + } /* * Media, integrity related status, and the others will be mapped to -- cgit v1.2.3