From af38d200e6aece649f5066b088046c0e035eb85c Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Fri, 10 May 2019 10:40:28 -0700 Subject: [PATCH] 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: Jim Harris Change-Id: Ia093fcd23cf321a820fd53183ee7e2dac4f9d378 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/454081 Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Shuhei Matsumoto --- include/spdk/nvme.h | 7 +++++++ lib/nvme/nvme_ctrlr.c | 4 ++++ lib/nvme/nvme_pcie.c | 6 ++++-- lib/nvme/nvme_qpair.c | 6 ++++-- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/include/spdk/nvme.h b/include/spdk/nvme.h index 862877f33..ca51e5a9e 100644 --- a/include/spdk/nvme.h +++ b/include/spdk/nvme.h @@ -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; }; /** diff --git a/lib/nvme/nvme_ctrlr.c b/lib/nvme/nvme_ctrlr.c index e9efebf05..4d6133faf 100644 --- a/lib/nvme/nvme_ctrlr.c +++ b/lib/nvme/nvme_ctrlr.c @@ -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 } diff --git a/lib/nvme/nvme_pcie.c b/lib/nvme/nvme_pcie.c index 1a7dbedd5..8d603a39c 100644 --- a/lib/nvme/nvme_pcie.c +++ b/lib/nvme/nvme_pcie.c @@ -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) { - SPDK_ERRLOG("aborting outstanding command\n"); + 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); } diff --git a/lib/nvme/nvme_qpair.c b/lib/nvme/nvme_qpair.c index c25dfe764..d9b6ccc4e 100644 --- a/lib/nvme/nvme_qpair.c +++ b/lib/nvme/nvme_qpair.c @@ -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); - SPDK_ERRLOG("aborting queued i/o\n"); + 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); }