Skip to content

Commit 4435033

Browse files
hreineckekeithbusch
authored andcommitted
nvme: return kernel error codes for admin queue connect
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 <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Signed-off-by: Hannes Reinecke <[email protected]> Signed-off-by: Daniel Wagner <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 44e3c25 commit 4435033

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

drivers/nvme/host/core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,14 +383,14 @@ static inline enum nvme_disposition nvme_decide_disposition(struct request *req)
383383
if (likely(nvme_req(req)->status == 0))
384384
return COMPLETE;
385385

386-
if ((nvme_req(req)->status & 0x7ff) == NVME_SC_AUTH_REQUIRED)
387-
return AUTHENTICATE;
388-
389386
if (blk_noretry_request(req) ||
390387
(nvme_req(req)->status & NVME_SC_DNR) ||
391388
nvme_req(req)->retries >= nvme_max_retries)
392389
return COMPLETE;
393390

391+
if ((nvme_req(req)->status & 0x7ff) == NVME_SC_AUTH_REQUIRED)
392+
return AUTHENTICATE;
393+
394394
if (req->cmd_flags & REQ_NVME_MPATH) {
395395
if (nvme_is_path_error(nvme_req(req)->status) ||
396396
blk_queue_dying(req->q))

drivers/nvme/host/fabrics.c

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -428,12 +428,6 @@ static void nvmf_connect_cmd_prep(struct nvme_ctrl *ctrl, u16 qid,
428428
* fabrics-protocol connection of the NVMe Admin queue between the
429429
* host system device and the allocated NVMe controller on the
430430
* target system via a NVMe Fabrics "Connect" command.
431-
*
432-
* Return:
433-
* 0: success
434-
* > 0: NVMe error status code
435-
* < 0: Linux errno error code
436-
*
437431
*/
438432
int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl)
439433
{
@@ -467,22 +461,22 @@ int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl)
467461
if (result & NVME_CONNECT_AUTHREQ_ASCR) {
468462
dev_warn(ctrl->device,
469463
"qid 0: secure concatenation is not supported\n");
470-
ret = NVME_SC_AUTH_REQUIRED;
464+
ret = -EOPNOTSUPP;
471465
goto out_free_data;
472466
}
473467
/* Authentication required */
474468
ret = nvme_auth_negotiate(ctrl, 0);
475469
if (ret) {
476470
dev_warn(ctrl->device,
477471
"qid 0: authentication setup failed\n");
478-
ret = NVME_SC_AUTH_REQUIRED;
479472
goto out_free_data;
480473
}
481474
ret = nvme_auth_wait(ctrl, 0);
482-
if (ret)
475+
if (ret) {
483476
dev_warn(ctrl->device,
484-
"qid 0: authentication failed\n");
485-
else
477+
"qid 0: authentication failed, error %d\n",
478+
ret);
479+
} else
486480
dev_info(ctrl->device,
487481
"qid 0: authenticated\n");
488482
}
@@ -542,20 +536,21 @@ int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid)
542536
if (result & NVME_CONNECT_AUTHREQ_ASCR) {
543537
dev_warn(ctrl->device,
544538
"qid 0: secure concatenation is not supported\n");
545-
ret = NVME_SC_AUTH_REQUIRED;
539+
ret = -EOPNOTSUPP;
546540
goto out_free_data;
547541
}
548542
/* Authentication required */
549543
ret = nvme_auth_negotiate(ctrl, qid);
550544
if (ret) {
551545
dev_warn(ctrl->device,
552546
"qid %d: authentication setup failed\n", qid);
553-
ret = NVME_SC_AUTH_REQUIRED;
554-
} else {
555-
ret = nvme_auth_wait(ctrl, qid);
556-
if (ret)
557-
dev_warn(ctrl->device,
558-
"qid %u: authentication failed\n", qid);
547+
goto out_free_data;
548+
}
549+
ret = nvme_auth_wait(ctrl, qid);
550+
if (ret) {
551+
dev_warn(ctrl->device,
552+
"qid %u: authentication failed, error %d\n",
553+
qid, ret);
559554
}
560555
}
561556
out_free_data:

drivers/nvme/host/nvme.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ static inline int nvme_auth_negotiate(struct nvme_ctrl *ctrl, int qid)
11141114
}
11151115
static inline int nvme_auth_wait(struct nvme_ctrl *ctrl, int qid)
11161116
{
1117-
return NVME_SC_AUTH_REQUIRED;
1117+
return -EPROTONOSUPPORT;
11181118
}
11191119
static inline void nvme_auth_free(struct nvme_ctrl *ctrl) {};
11201120
#endif

0 commit comments

Comments
 (0)