Commit 803fbb96 authored by Jens Axboe's avatar Jens Axboe
Browse files

Merge tag 'nvme-6.10-2024-05-14' of git://git.infradead.org/nvme into block-6.10

Pull NVMe updates and fixes from Keith:

"nvme updates for Linux 6.10

 - Fabrics connection retries (Daniel, Hannes)
 - Fabrics logging enhancements (Tokunori)
 - RDMA delete optimization (Sagi)"

* tag 'nvme-6.10-2024-05-14' of git://git.infradead.org/nvme:
  nvme-rdma, nvme-tcp: include max reconnects for reconnect logging
  nvmet-rdma: Avoid o(n^2) loop in delete_ctrl
  nvme: do not retry authentication failures
  nvme-fabrics: short-circuit reconnect retries
  nvme: return kernel error codes for admin queue connect
  nvmet: return DHCHAP status codes from nvmet_setup_auth()
  nvmet: lock config semaphore when accessing DH-HMAC-CHAP key
parents e56d4b63 54a76c87
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -730,7 +730,7 @@ static void nvme_queue_auth_work(struct work_struct *work)
					 NVME_AUTH_DHCHAP_MESSAGE_CHALLENGE);
	if (ret) {
		chap->status = ret;
		chap->error = -ECONNREFUSED;
		chap->error = -EKEYREJECTED;
		return;
	}

@@ -797,7 +797,7 @@ static void nvme_queue_auth_work(struct work_struct *work)
					 NVME_AUTH_DHCHAP_MESSAGE_SUCCESS1);
	if (ret) {
		chap->status = ret;
		chap->error = -ECONNREFUSED;
		chap->error = -EKEYREJECTED;
		return;
	}

@@ -818,7 +818,7 @@ static void nvme_queue_auth_work(struct work_struct *work)
	ret = nvme_auth_process_dhchap_success1(ctrl, chap);
	if (ret) {
		/* Controller authentication failed */
		chap->error = -ECONNREFUSED;
		chap->error = -EKEYREJECTED;
		goto fail2;
	}

+3 −3
Original line number Diff line number Diff line
@@ -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))
+32 −19
Original line number Diff line number Diff line
@@ -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 {
			goto out_free_data;
		}
		ret = nvme_auth_wait(ctrl, qid);
			if (ret)
		if (ret) {
			dev_warn(ctrl->device,
					 "qid %u: authentication failed\n", qid);
				 "qid %u: authentication failed, error %d\n",
				 qid, ret);
		}
	}
out_free_data:
@@ -564,8 +559,26 @@ int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid)
}
EXPORT_SYMBOL_GPL(nvmf_connect_io_queue);

bool nvmf_should_reconnect(struct nvme_ctrl *ctrl)
/*
 * Evaluate the status information returned by the transport in order to decided
 * if a reconnect attempt should be scheduled.
 *
 * Do not retry when:
 *
 * - the DNR bit is set and the specification states no further connect
 *   attempts with the same set of paramenters should be attempted.
 *
 * - when the authentication attempt fails, because the key was invalid.
 *   This error code is set on the host side.
 */
bool nvmf_should_reconnect(struct nvme_ctrl *ctrl, int status)
{
	if (status > 0 && (status & NVME_SC_DNR))
		return false;

	if (status == -EKEYREJECTED)
		return false;

	if (ctrl->opts->max_reconnects == -1 ||
	    ctrl->nr_reconnects < ctrl->opts->max_reconnects)
		return true;
+1 −1
Original line number Diff line number Diff line
@@ -223,7 +223,7 @@ int nvmf_register_transport(struct nvmf_transport_ops *ops);
void nvmf_unregister_transport(struct nvmf_transport_ops *ops);
void nvmf_free_options(struct nvmf_ctrl_options *opts);
int nvmf_get_address(struct nvme_ctrl *ctrl, char *buf, int size);
bool nvmf_should_reconnect(struct nvme_ctrl *ctrl);
bool nvmf_should_reconnect(struct nvme_ctrl *ctrl, int status);
bool nvmf_ip_options_match(struct nvme_ctrl *ctrl,
		struct nvmf_ctrl_options *opts);
void nvmf_set_io_queues(struct nvmf_ctrl_options *opts, u32 nr_io_queues,
+1 −3
Original line number Diff line number Diff line
@@ -3310,12 +3310,10 @@ nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status)
		dev_info(ctrl->ctrl.device,
			"NVME-FC{%d}: reset: Reconnect attempt failed (%d)\n",
			ctrl->cnum, status);
		if (status > 0 && (status & NVME_SC_DNR))
			recon = false;
	} else if (time_after_eq(jiffies, rport->dev_loss_end))
		recon = false;

	if (recon && nvmf_should_reconnect(&ctrl->ctrl)) {
	if (recon && nvmf_should_reconnect(&ctrl->ctrl, status)) {
		if (portptr->port_state == FC_OBJSTATE_ONLINE)
			dev_info(ctrl->ctrl.device,
				"NVME-FC{%d}: Reconnect attempt in %ld "
Loading