nvme: return kernel error codes for admin queue connect
authorHannes Reinecke <hare@suse.de>
Tue, 30 Apr 2024 13:19:26 +0000 (15:19 +0200)
committerKeith Busch <kbusch@kernel.org>
Wed, 1 May 2024 10:07:20 +0000 (03:07 -0700)
nvmf_connect_admin_queue returns NVMe error status codes and kernel
error codes. This mixes the different domains which makes maintainability
difficult.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/host/core.c
drivers/nvme/host/fabrics.c
drivers/nvme/host/nvme.h

index c9955ecd1790851f87a973e1655952717188ee32..a066429b790d935e178b275e8171220ebfa23e26 100644 (file)
@@ -383,14 +383,14 @@ static inline enum nvme_disposition nvme_decide_disposition(struct request *req)
        if (likely(nvme_req(req)->status == 0))
                return COMPLETE;
 
-       if ((nvme_req(req)->status & 0x7ff) == NVME_SC_AUTH_REQUIRED)
-               return AUTHENTICATE;
-
        if (blk_noretry_request(req) ||
            (nvme_req(req)->status & NVME_SC_DNR) ||
            nvme_req(req)->retries >= nvme_max_retries)
                return COMPLETE;
 
+       if ((nvme_req(req)->status & 0x7ff) == NVME_SC_AUTH_REQUIRED)
+               return AUTHENTICATE;
+
        if (req->cmd_flags & REQ_NVME_MPATH) {
                if (nvme_is_path_error(nvme_req(req)->status) ||
                    blk_queue_dying(req->q))
index 1f0ea1f32d22f5badee3af7b7827172c31c9ecf7..f7eaf9580b4f40aebcd0ad2f989252288c86d683 100644 (file)
@@ -428,12 +428,6 @@ static void nvmf_connect_cmd_prep(struct nvme_ctrl *ctrl, u16 qid,
  * fabrics-protocol connection of the NVMe Admin queue between the
  * host system device and the allocated NVMe controller on the
  * target system via a NVMe Fabrics "Connect" command.
- *
- * Return:
- *     0: success
- *     > 0: NVMe error status code
- *     < 0: Linux errno error code
- *
  */
 int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl)
 {
@@ -467,7 +461,7 @@ int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl)
                if (result & NVME_CONNECT_AUTHREQ_ASCR) {
                        dev_warn(ctrl->device,
                                 "qid 0: secure concatenation is not supported\n");
-                       ret = NVME_SC_AUTH_REQUIRED;
+                       ret = -EOPNOTSUPP;
                        goto out_free_data;
                }
                /* Authentication required */
@@ -475,14 +469,14 @@ int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl)
                if (ret) {
                        dev_warn(ctrl->device,
                                 "qid 0: authentication setup failed\n");
-                       ret = NVME_SC_AUTH_REQUIRED;
                        goto out_free_data;
                }
                ret = nvme_auth_wait(ctrl, 0);
-               if (ret)
+               if (ret) {
                        dev_warn(ctrl->device,
-                                "qid 0: authentication failed\n");
-               else
+                                "qid 0: authentication failed, error %d\n",
+                                ret);
+               } else
                        dev_info(ctrl->device,
                                 "qid 0: authenticated\n");
        }
@@ -542,7 +536,7 @@ int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid)
                if (result & NVME_CONNECT_AUTHREQ_ASCR) {
                        dev_warn(ctrl->device,
                                 "qid 0: secure concatenation is not supported\n");
-                       ret = NVME_SC_AUTH_REQUIRED;
+                       ret = -EOPNOTSUPP;
                        goto out_free_data;
                }
                /* Authentication required */
@@ -550,12 +544,13 @@ int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid)
                if (ret) {
                        dev_warn(ctrl->device,
                                 "qid %d: authentication setup failed\n", qid);
-                       ret = NVME_SC_AUTH_REQUIRED;
-               } else {
-                       ret = nvme_auth_wait(ctrl, qid);
-                       if (ret)
-                               dev_warn(ctrl->device,
-                                        "qid %u: authentication failed\n", qid);
+                       goto out_free_data;
+               }
+               ret = nvme_auth_wait(ctrl, qid);
+               if (ret) {
+                       dev_warn(ctrl->device,
+                                "qid %u: authentication failed, error %d\n",
+                                qid, ret);
                }
        }
 out_free_data:
index 24193fcb8bd584de277606d57738c1aea5a9cb49..f243a5822c2ba306b9b060cc2a18f4522afd9920 100644 (file)
@@ -1114,7 +1114,7 @@ static inline int nvme_auth_negotiate(struct nvme_ctrl *ctrl, int qid)
 }
 static inline int nvme_auth_wait(struct nvme_ctrl *ctrl, int qid)
 {
-       return NVME_SC_AUTH_REQUIRED;
+       return -EPROTONOSUPPORT;
 }
 static inline void nvme_auth_free(struct nvme_ctrl *ctrl) {};
 #endif