From 85a822292d515feb61b05acb60d14e4a892e9df6 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Tue, 29 May 2018 18:21:02 -0700 Subject: [PATCH] nvmf: refactor abort handling Combine request lookup and abort into a single operation. Keeping them separate would result in duplicating a lot of logic for finding the proper list from which to remove aborted requests. This is still a no-op for now, but it paves the way for aborting requests that are still queued in software. Change-Id: If8f268521f2c9f93b413261d87e9f39e539813aa Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/412880 Tested-by: SPDK Automated Test System Reviewed-by: Changpeng Liu Reviewed-by: Ben Walker --- lib/nvmf/ctrlr.c | 30 +++++++++++++++++------------- lib/nvmf/nvmf_internal.h | 1 - lib/nvmf/request.c | 7 ------- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/lib/nvmf/ctrlr.c b/lib/nvmf/ctrlr.c index dd55c8c7f..c918da506 100644 --- a/lib/nvmf/ctrlr.c +++ b/lib/nvmf/ctrlr.c @@ -498,13 +498,6 @@ spdk_nvmf_ctrlr_get_qpair(struct spdk_nvmf_ctrlr *ctrlr, uint16_t qid) return NULL; } -static struct spdk_nvmf_request * -spdk_nvmf_qpair_get_request(struct spdk_nvmf_qpair *qpair, uint16_t cid) -{ - /* TODO: track list of outstanding requests in qpair? */ - return NULL; -} - static uint64_t nvmf_prop_get_cap(struct spdk_nvmf_ctrlr *ctrlr) { @@ -1458,6 +1451,14 @@ invalid_cns: return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE; } + +static struct spdk_nvmf_request * +spdk_nvmf_qpair_abort(struct spdk_nvmf_qpair *qpair, uint16_t cid) +{ + /* TODO: track list of outstanding requests in qpair? */ + return NULL; +} + static void spdk_nvmf_ctrlr_abort_on_qpair(void *arg) { @@ -1483,7 +1484,7 @@ spdk_nvmf_ctrlr_abort_on_qpair(void *arg) assert(spdk_get_thread() == qpair->group->thread); - req_to_abort = spdk_nvmf_qpair_get_request(qpair, cid); + req_to_abort = spdk_nvmf_qpair_abort(qpair, cid); if (req_to_abort == NULL) { SPDK_DEBUGLOG(SPDK_LOG_NVMF, "cid %u not found\n", cid); rsp->status.sct = SPDK_NVME_SCT_GENERIC; @@ -1491,11 +1492,14 @@ spdk_nvmf_ctrlr_abort_on_qpair(void *arg) goto complete_abort; } - if (spdk_nvmf_request_abort(req_to_abort) == 0) { - SPDK_DEBUGLOG(SPDK_LOG_NVMF, "abort ctrlr=%p req=%p sqid=%u cid=%u successful\n", - ctrlr, req_to_abort, sqid, cid); - rsp->cdw0 = 0; /* Command successfully aborted */ - } + /* Complete the request with aborted status */ + req_to_abort->rsp->nvme_cpl.status.sct = SPDK_NVME_SCT_GENERIC; + req_to_abort->rsp->nvme_cpl.status.sc = SPDK_NVME_SC_ABORTED_BY_REQUEST; + spdk_nvmf_request_complete(req_to_abort); + + SPDK_DEBUGLOG(SPDK_LOG_NVMF, "abort ctrlr=%p req=%p sqid=%u cid=%u successful\n", + ctrlr, req_to_abort, sqid, cid); + rsp->cdw0 = 0; /* Command successfully aborted */ rsp->status.sct = SPDK_NVME_SCT_GENERIC; rsp->status.sc = SPDK_NVME_SC_SUCCESS; diff --git a/lib/nvmf/nvmf_internal.h b/lib/nvmf/nvmf_internal.h index a44962b35..a0601b9ee 100644 --- a/lib/nvmf/nvmf_internal.h +++ b/lib/nvmf/nvmf_internal.h @@ -252,7 +252,6 @@ int spdk_nvmf_poll_group_resume_subsystem(struct spdk_nvmf_poll_group *group, struct spdk_nvmf_subsystem *subsystem); void spdk_nvmf_request_exec(struct spdk_nvmf_request *req); int spdk_nvmf_request_complete(struct spdk_nvmf_request *req); -int spdk_nvmf_request_abort(struct spdk_nvmf_request *req); void spdk_nvmf_get_discovery_log_page(struct spdk_nvmf_tgt *tgt, void *buffer, uint64_t offset, diff --git a/lib/nvmf/request.c b/lib/nvmf/request.c index a9824856f..ff4434de9 100644 --- a/lib/nvmf/request.c +++ b/lib/nvmf/request.c @@ -152,10 +152,3 @@ spdk_nvmf_request_exec(struct spdk_nvmf_request *req) spdk_nvmf_request_complete(req); } } - -int -spdk_nvmf_request_abort(struct spdk_nvmf_request *req) -{ - /* TODO: implement abort, at least for commands that are still queued in software */ - return -1; -}