nvmf: send abort request to the qpair group thread
Abort is not currently implemented, since spdk_nvmf_qpair_get_request() always returns NULL, but this will allow it to be implemented in a thread-safe way. Change-Id: I6dfd1ee50848deed0f4a2667aad5a811d8dd4ca7 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-on: https://review.gerrithub.io/410723 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
2ee95af0fd
commit
35efde744a
@ -1429,9 +1429,10 @@ invalid_cns:
|
||||
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
|
||||
}
|
||||
|
||||
static int
|
||||
spdk_nvmf_ctrlr_abort(struct spdk_nvmf_request *req)
|
||||
static void
|
||||
spdk_nvmf_ctrlr_abort_on_qpair(void *arg)
|
||||
{
|
||||
struct spdk_nvmf_request *req = arg;
|
||||
struct spdk_nvmf_ctrlr *ctrlr = req->qpair->ctrlr;
|
||||
struct spdk_nvme_cpl *rsp = &req->rsp->nvme_cpl;
|
||||
struct spdk_nvme_cmd *cmd = &req->cmd->nvme_cmd;
|
||||
@ -1443,6 +1444,47 @@ spdk_nvmf_ctrlr_abort(struct spdk_nvmf_request *req)
|
||||
|
||||
SPDK_DEBUGLOG(SPDK_LOG_NVMF, "abort sqid=%u cid=%u\n", sqid, cid);
|
||||
|
||||
qpair = spdk_nvmf_ctrlr_get_qpair(ctrlr, sqid);
|
||||
if (qpair == NULL) {
|
||||
SPDK_DEBUGLOG(SPDK_LOG_NVMF, "sqid %u not found\n", sqid);
|
||||
rsp->status.sct = SPDK_NVME_SCT_GENERIC;
|
||||
rsp->status.sc = SPDK_NVME_SC_INVALID_FIELD;
|
||||
goto complete_abort;
|
||||
}
|
||||
|
||||
assert(spdk_get_thread() == qpair->group->thread);
|
||||
|
||||
req_to_abort = spdk_nvmf_qpair_get_request(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;
|
||||
rsp->status.sc = SPDK_NVME_SC_INVALID_FIELD;
|
||||
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 */
|
||||
}
|
||||
rsp->status.sct = SPDK_NVME_SCT_GENERIC;
|
||||
rsp->status.sc = SPDK_NVME_SC_SUCCESS;
|
||||
|
||||
complete_abort:
|
||||
/* Complete the abort request on the admin qpair */
|
||||
spdk_thread_send_msg(req->qpair->group->thread, _spdk_nvmf_request_complete, req);
|
||||
}
|
||||
|
||||
static int
|
||||
spdk_nvmf_ctrlr_abort(struct spdk_nvmf_request *req)
|
||||
{
|
||||
struct spdk_nvmf_ctrlr *ctrlr = req->qpair->ctrlr;
|
||||
struct spdk_nvme_cpl *rsp = &req->rsp->nvme_cpl;
|
||||
struct spdk_nvme_cmd *cmd = &req->cmd->nvme_cmd;
|
||||
uint32_t cdw10 = cmd->cdw10;
|
||||
uint16_t sqid = cdw10 & 0xFFFFu;
|
||||
struct spdk_nvmf_qpair *qpair;
|
||||
|
||||
rsp->cdw0 = 1; /* Command not aborted */
|
||||
|
||||
qpair = spdk_nvmf_ctrlr_get_qpair(ctrlr, sqid);
|
||||
@ -1453,27 +1495,9 @@ spdk_nvmf_ctrlr_abort(struct spdk_nvmf_request *req)
|
||||
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
|
||||
}
|
||||
|
||||
/*
|
||||
* NOTE: This relies on the assumption that all connections for a ctrlr will be handled
|
||||
* on the same thread. If this assumption becomes untrue, this will need to pass a message
|
||||
* to the thread handling qpair, and the abort will need to be asynchronous.
|
||||
*/
|
||||
req_to_abort = spdk_nvmf_qpair_get_request(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;
|
||||
rsp->status.sc = SPDK_NVME_SC_INVALID_FIELD;
|
||||
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
|
||||
}
|
||||
|
||||
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 */
|
||||
}
|
||||
rsp->status.sct = SPDK_NVME_SCT_GENERIC;
|
||||
rsp->status.sc = SPDK_NVME_SC_SUCCESS;
|
||||
return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
|
||||
/* Process the abort request on the poll group thread handling the qpair */
|
||||
spdk_thread_send_msg(qpair->group->thread, spdk_nvmf_ctrlr_abort_on_qpair, req);
|
||||
return SPDK_NVMF_REQUEST_EXEC_STATUS_ASYNCHRONOUS;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -226,6 +226,12 @@ nvme_status_success(const struct spdk_nvme_status *status)
|
||||
return status->sct == SPDK_NVME_SCT_GENERIC && status->sc == SPDK_NVME_SC_SUCCESS;
|
||||
}
|
||||
|
||||
struct spdk_thread *
|
||||
spdk_get_thread(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
spdk_thread_send_msg(const struct spdk_thread *thread, spdk_thread_fn fn, void *ctx)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user