Commit af38d200 authored by Jim Harris's avatar Jim Harris
Browse files

nvme: add ctrlr option for logging errors



Currently the nvme driver will always log any
request completed with error status.  Some
applications may not want this behavior.  So provide
an option to disable it at the controller level.
When this option is enabled, any failed requests
from queues associated with that controller
(including the admin queue) will not log the
failed request.

Of course the application will still receive
the failed status code and can decide to do its
own logging there.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: Ia093fcd23cf321a820fd53183ee7e2dac4f9d378

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/454081


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 0f1ce06d
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -181,6 +181,13 @@ struct spdk_nvme_ctrlr_opts {
	 * Set to true, means having data digest for the data in the NVMe/TCP PDU
	 */
	bool data_digest;

	/**
	 * Disable logging of requests that are completed with error status.
	 *
	 * Defaults to 'false' (errors are logged).
	 */
	bool disable_error_logging;
};

/**
+4 −0
Original line number Diff line number Diff line
@@ -161,6 +161,10 @@ spdk_nvme_ctrlr_get_default_ctrlr_opts(struct spdk_nvme_ctrlr_opts *opts, size_t
	if (FIELD_OK(data_digest)) {
		opts->data_digest = false;
	}

	if (FIELD_OK(disable_error_logging)) {
		opts->disable_error_logging = false;
	}
#undef FIELD_OK
}

+4 −2
Original line number Diff line number Diff line
@@ -1296,7 +1296,7 @@ nvme_pcie_qpair_complete_tracker(struct spdk_nvme_qpair *qpair, struct nvme_trac
	retry = error && nvme_completion_is_retry(cpl) &&
		req->retries < spdk_nvme_retry_count;

	if (error && print_on_error) {
	if (error && print_on_error && !qpair->ctrlr->opts.disable_error_logging) {
		nvme_qpair_print_command(qpair, &req->cmd);
		nvme_qpair_print_completion(qpair, cpl);
	}
@@ -1361,7 +1361,9 @@ nvme_pcie_qpair_abort_trackers(struct spdk_nvme_qpair *qpair, uint32_t dnr)
	struct nvme_tracker *tr, *temp;

	TAILQ_FOREACH_SAFE(tr, &pqpair->outstanding_tr, tq_list, temp) {
		if (!qpair->ctrlr->opts.disable_error_logging) {
			SPDK_ERRLOG("aborting outstanding command\n");
		}
		nvme_pcie_qpair_manual_complete_tracker(qpair, tr, SPDK_NVME_SCT_GENERIC,
							SPDK_NVME_SC_ABORTED_BY_REQUEST, dnr, true);
	}
+4 −2
Original line number Diff line number Diff line
@@ -377,7 +377,7 @@ nvme_qpair_manual_complete_request(struct spdk_nvme_qpair *qpair,

	error = spdk_nvme_cpl_is_error(&cpl);

	if (error && print_on_error) {
	if (error && print_on_error && !qpair->ctrlr->opts.disable_error_logging) {
		SPDK_NOTICELOG("Command completed manually:\n");
		nvme_qpair_print_command(qpair, &req->cmd);
		nvme_qpair_print_completion(qpair, &cpl);
@@ -395,7 +395,9 @@ nvme_qpair_abort_queued_reqs(struct spdk_nvme_qpair *qpair, uint32_t dnr)
	while (!STAILQ_EMPTY(&qpair->queued_req)) {
		req = STAILQ_FIRST(&qpair->queued_req);
		STAILQ_REMOVE_HEAD(&qpair->queued_req, stailq);
		if (!qpair->ctrlr->opts.disable_error_logging) {
			SPDK_ERRLOG("aborting queued i/o\n");
		}
		nvme_qpair_manual_complete_request(qpair, req, SPDK_NVME_SCT_GENERIC,
						   SPDK_NVME_SC_ABORTED_BY_REQUEST, dnr, true);
	}