Skip to contentSkip to conversation

nvme: authentication error are always non-retryable

PATCH Superseded [email protected] 3 participants 6 messages Feb 23, 2024 – Feb 26, 2024 NVMe

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme: authentication error are always non-retryable

From: Hannes Reinecke <[email protected]>

Any authentication errors which are generated internally are always non-retryable, so set the DNR bit to ensure they are not retried.

---
 drivers/nvme/host/core.c    |  6 +++---
 drivers/nvme/host/fabrics.c | 16 +++++++---------
 drivers/nvme/host/nvme.h    |  2 +-
 3 files changed, 11 insertions(+), 13 deletions(-)
drivers/nvme/host/core.c +3 -3
index 5e9a0cf43636..0a8a595070c0 100644
@@ -374,14 +374,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))
drivers/nvme/host/fabrics.c +7 -9
index ab5ac219b70a..2b66fa5cd43f 100644
@@ -467,7 +467,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 = NVME_SC_AUTH_REQUIRED | NVME_SC_DNR;
 			goto out_free_data;
 		}
 		/* Authentication required */
@@ -475,7 +475,6 @@ 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);
@@ -541,7 +540,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 = NVME_SC_AUTH_REQUIRED | NVME_SC_DNR;
 			goto out_free_data;
 		}
 		/* Authentication required */
@@ -549,13 +548,12 @@ 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\n", qid);
 	}
 out_free_data:
 	kfree(data);
drivers/nvme/host/nvme.h +1 -1
index 6ed2ca6b35e4..c08c220a68cf 100644
@@ -1123,7 +1123,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 NVME_SC_AUTH_REQUIRED | NVME_SC_DNR;
 }
 static inline void nvme_auth_free(struct nvme_ctrl *ctrl) {};
 #endif
Signature · 1 line
2.35.3
#1 lore raw
Quoted 4 lines · On Fri, Feb 23, 2024 at 11:58:04AM +0100, [email protected] wrote:

From: Hannes Reinecke <[email protected]>

Any authentication errors which are generated internally are always non-retryable, so set the DNR bit to ensure they are not retried.

This still keeps nvme-fc in the retry loop. It fails with -126 which is -ENOKEY:

[ 2267.185691] nvme nvme0: qid 0: no key
[ 2267.187596] nvme nvme0: qid 0: authentication setup failed
[ 2267.188866] nvme nvme0: NVME-FC{0}: create_assoc failed, assoc_id 2a3022dff0fe0000 ret -126
#2 lore raw
Quoted 6 lines · Daniel Wagner
Quoted 4 lines · On Fri, Feb 23, 2024 at 11:58:04AM +0100, [email protected] wrote:

From: Hannes Reinecke <[email protected]>

Any authentication errors which are generated internally are always non-retryable, so set the DNR bit to ensure they are not retried.

Quoted 7 lines

This still keeps nvme-fc in the retry loop. It fails with -126 which is -ENOKEY:

[ 2267.185691] nvme nvme0: qid 0: no key
[ 2267.187596] nvme nvme0: qid 0: authentication setup failed
[ 2267.188866] nvme nvme0: NVME-FC{0}: create_assoc failed, assoc_id 2a3022dff0fe0000 ret -126

nvme_auth_negotiate() returns -ENOKEY. What's the idea to handle negative return values? I though nvme_fc_reconnect_or_delete() should stop the retry loop for for negative values too?

#3 lore raw
In reply to Daniel Wagner
Quoted 6 lines · Daniel Wagner
Quoted 4 lines · On Fri, Feb 23, 2024 at 11:58:04AM +0100, [email protected] wrote:

From: Hannes Reinecke <[email protected]>

Any authentication errors which are generated internally are always non-retryable, so set the DNR bit to ensure they are not retried.

Quoted 7 lines

This still keeps nvme-fc in the retry loop. It fails with -126 which is -ENOKEY:

[ 2267.185691] nvme nvme0: qid 0: no key
[ 2267.187596] nvme nvme0: qid 0: authentication setup failed
[ 2267.188866] nvme nvme0: NVME-FC{0}: create_assoc failed, assoc_id 2a3022dff0fe0000 ret -126

Aw. Bugger.
Of course we do retry, as negative transport errors are considered retryable. Curiously enough, negative _NVMe_ errors are considered non-retryable. Hmph. We may want to work on that.

Cheers,

Hannes

#4 lore raw
Quoted 10 lines · Hannes Reinecke
Quoted 9 lines · Daniel Wagner
Quoted 4 lines · On Fri, Feb 23, 2024 at 11:58:04AM +0100, [email protected] wrote:

From: Hannes Reinecke <[email protected]>

Any authentication errors which are generated internally are always non-retryable, so set the DNR bit to ensure they are not retried.

This still keeps nvme-fc in the retry loop. It fails with -126 which is -ENOKEY:

Quoted 7 lines
Quoted 4 lines
[ 2267.185691] nvme nvme0: qid 0: no key
[ 2267.187596] nvme nvme0: qid 0: authentication setup failed
[ 2267.188866] nvme nvme0: NVME-FC{0}: create_assoc failed, assoc_id 2a3022dff0fe0000 ret -126

Aw. Bugger.
Of course we do retry, as negative transport errors are considered retryable. Curiously enough, negative _NVMe_ errors are considered non-retryable. Hmph. We may want to work on that.

So we'll need this one on top:

drivers/nvme/host/fabrics.c +4 -2
index 2b66fa5cd43f..2b1bac54010c 100644
@@ -475,13 +475,15 @@ 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 | NVME_SC_DNR;
                        goto out_free_data;
                }
                ret = nvme_auth_wait(ctrl, 0);
-               if (ret)
+               if (ret) {
                        dev_warn(ctrl->device,
                                 "qid 0: authentication failed\n");
-               else
+                       ret = NVME_SC_AUTH_REQUIRED | NVME_SC_DNR;
+               } else
                        dev_info(ctrl->device,
                                 "qid 0: authenticated\n");
        }

I'll send a proper patch.

Cheers,

Hannes

#5 lore raw
Quoted 1 line · Hannes Reinecke

I'll send a proper patch.

Yes, this does the trick:

nvme nvme0: qid 0: no key
nvme nvme0: qid 0: authentication setup failed
nvme nvme0: NVME-FC{0}: create_assoc failed, assoc_id 18da4ebfd6fa0000 ret 16785 nvme nvme0: NVME-FC{0}: reset: Reconnect attempt failed (16785) nvme nvme0: NVME-FC{0}: reconnect failure
nvme nvme0: Removing ctrl: NQN "blktests-subsystem-1"
(NULL device *): {0:0} Association deleted