Commit 35efde74 authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

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: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/410723


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 2ee95af0
Loading
Loading
Loading
Loading
+36 −12
Original line number Diff line number Diff line
@@ -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,27 +1444,22 @@ spdk_nvmf_ctrlr_abort(struct spdk_nvmf_request *req)

	SPDK_DEBUGLOG(SPDK_LOG_NVMF, "abort sqid=%u cid=%u\n", sqid, cid);

	rsp->cdw0 = 1; /* Command not aborted */

	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;
		return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
		goto complete_abort;
	}

	/*
	 * 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.
	 */
	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;
		return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
		goto complete_abort;
	}

	if (spdk_nvmf_request_abort(req_to_abort) == 0) {
@@ -1473,9 +1469,37 @@ spdk_nvmf_ctrlr_abort(struct spdk_nvmf_request *req)
	}
	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);
	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;
		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
get_features_generic(struct spdk_nvmf_request *req, uint32_t cdw0)
{
+6 −0
Original line number Diff line number Diff line
@@ -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)
{