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 <ziye.yang@intel.com>
Change-Id: Ie73763e1329e12a8c82a0223d360991f86c39be3
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3773
Community-CI: Broadcom CI
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Ziye Yang 2020-08-14 03:32:14 +08:00 committed by Tomasz Zawadzki
parent 518a1e013a
commit 2031f8f70d

View File

@ -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. * Check if we need to send a Keep Alive command.
* Caller must hold ctrlr->ctrlr_lock. * Caller must hold ctrlr->ctrlr_lock.
*/ */
static void static int
nvme_ctrlr_keep_alive(struct spdk_nvme_ctrlr *ctrlr) nvme_ctrlr_keep_alive(struct spdk_nvme_ctrlr *ctrlr)
{ {
uint64_t now; uint64_t now;
struct nvme_request *req; struct nvme_request *req;
struct spdk_nvme_cmd *cmd; struct spdk_nvme_cmd *cmd;
int rc; int rc = 0;
now = spdk_get_ticks(); now = spdk_get_ticks();
if (now < ctrlr->next_keep_alive_tick) { if (now < ctrlr->next_keep_alive_tick) {
return; return rc;
} }
req = nvme_allocate_request_null(ctrlr->adminq, nvme_keep_alive_completion, NULL); req = nvme_allocate_request_null(ctrlr->adminq, nvme_keep_alive_completion, NULL);
if (req == NULL) { if (req == NULL) {
return; return rc;
} }
cmd = &req->cmd; cmd = &req->cmd;
@ -2927,9 +2927,11 @@ nvme_ctrlr_keep_alive(struct spdk_nvme_ctrlr *ctrlr)
rc = nvme_ctrlr_submit_admin_request(ctrlr, req); rc = nvme_ctrlr_submit_admin_request(ctrlr, req);
if (rc != 0) { if (rc != 0) {
SPDK_ERRLOG("Submitting Keep Alive failed\n"); SPDK_ERRLOG("Submitting Keep Alive failed\n");
rc = -ENXIO;
} }
ctrlr->next_keep_alive_tick = now + ctrlr->keep_alive_interval_ticks; ctrlr->next_keep_alive_tick = now + ctrlr->keep_alive_interval_ticks;
return rc;
} }
int32_t int32_t
@ -2941,7 +2943,11 @@ spdk_nvme_ctrlr_process_admin_completions(struct spdk_nvme_ctrlr *ctrlr)
nvme_robust_mutex_lock(&ctrlr->ctrlr_lock); nvme_robust_mutex_lock(&ctrlr->ctrlr_lock);
if (ctrlr->keep_alive_interval_ticks) { 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); rc = nvme_io_msg_process(ctrlr);