From 2031f8f70d5fdf456be4ad02a2dc31bfc1373c76 Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Fri, 14 Aug 2020 03:32:14 +0800 Subject: [PATCH] nvme: set the error code if we cannot send keep alive command. If the transport is broken, we should set errno code in spdk_nvme_ctrlr_process_admin_completions instead of keeping silence. Signed-off-by: Ziye Yang Change-Id: Ie73763e1329e12a8c82a0223d360991f86c39be3 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3773 Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Jim Harris Reviewed-by: Aleksey Marchuk Reviewed-by: Shuhei Matsumoto --- lib/nvme/nvme_ctrlr.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/nvme/nvme_ctrlr.c b/lib/nvme/nvme_ctrlr.c index 8b506b531..804158a59 100644 --- a/lib/nvme/nvme_ctrlr.c +++ b/lib/nvme/nvme_ctrlr.c @@ -2903,22 +2903,22 @@ nvme_keep_alive_completion(void *cb_ctx, const struct spdk_nvme_cpl *cpl) * Check if we need to send a Keep Alive command. * Caller must hold ctrlr->ctrlr_lock. */ -static void +static int nvme_ctrlr_keep_alive(struct spdk_nvme_ctrlr *ctrlr) { uint64_t now; struct nvme_request *req; struct spdk_nvme_cmd *cmd; - int rc; + int rc = 0; now = spdk_get_ticks(); if (now < ctrlr->next_keep_alive_tick) { - return; + return rc; } req = nvme_allocate_request_null(ctrlr->adminq, nvme_keep_alive_completion, NULL); if (req == NULL) { - return; + return rc; } cmd = &req->cmd; @@ -2927,9 +2927,11 @@ nvme_ctrlr_keep_alive(struct spdk_nvme_ctrlr *ctrlr) rc = nvme_ctrlr_submit_admin_request(ctrlr, req); if (rc != 0) { SPDK_ERRLOG("Submitting Keep Alive failed\n"); + rc = -ENXIO; } ctrlr->next_keep_alive_tick = now + ctrlr->keep_alive_interval_ticks; + return rc; } int32_t @@ -2941,7 +2943,11 @@ spdk_nvme_ctrlr_process_admin_completions(struct spdk_nvme_ctrlr *ctrlr) nvme_robust_mutex_lock(&ctrlr->ctrlr_lock); if (ctrlr->keep_alive_interval_ticks) { - nvme_ctrlr_keep_alive(ctrlr); + rc = nvme_ctrlr_keep_alive(ctrlr); + if (rc) { + nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock); + return rc; + } } rc = nvme_io_msg_process(ctrlr);