]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-status: add status to error no support for path related errors
authorGollu Appalanaidu <anaidu.gollu@samsung.com>
Sun, 14 Feb 2021 16:33:33 +0000 (22:03 +0530)
committerKeith Busch <kbusch@kernel.org>
Mon, 15 Feb 2021 17:15:35 +0000 (10:15 -0700)
Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
linux/nvme.h
nvme-status.c

index 6ba5257950231cca331b04fe82e78ae6eab431ac..ad5e259ce59eee5c269c84fa97c1041ce9847aef 100644 (file)
@@ -1491,6 +1491,7 @@ enum {
        NVME_SCT_GENERIC                = 0x0,
        NVME_SCT_CMD_SPECIFIC           = 0x1,
        NVME_SCT_MEDIA                  = 0x2,
+      NVME_SCT_PATH                   = 0x3,
 };
 
 enum {
index 149e6f2b4fc2623e48a010ae58001f9565f865e6..35467512ffd46058ce761fadce1535c8c7054f54 100644 (file)
@@ -126,6 +126,18 @@ 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_ANA_PERSISTENT_LOSS:
+       case NVME_SC_ANA_INACCESSIBLE:
+       case NVME_SC_ANA_TRANSITION:
+               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,
@@ -154,12 +166,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