diff --git a/include/spdk/nvme.h b/include/spdk/nvme.h index b08c35c95c..86b0d0e85f 100644 --- a/include/spdk/nvme.h +++ b/include/spdk/nvme.h @@ -421,6 +421,8 @@ struct spdk_nvme_qpair; /** * Signature for the callback function invoked when a timeout is * detected on a request. + * For timeouts detected on the admin queue pair, the qpair returned + * here will be NULL. */ typedef void (*spdk_nvme_timeout_cb)(void *cb_arg, struct spdk_nvme_ctrlr *ctrlr, @@ -592,6 +594,7 @@ int spdk_nvme_ctrlr_cmd_get_log_page(struct spdk_nvme_ctrlr *ctrlr, * * \param ctrlr NVMe controller to which the command was submitted. * \param qpair NVMe queue pair to which the command was submitted. + * For admin commands, pass NULL for the qpair. * \param cid Command ID of the command to abort. * \param cb_fn Callback function to invoke when the abort has completed. * \param cb_arg Argument to pass to the callback function.\ diff --git a/lib/nvme/nvme_ctrlr_cmd.c b/lib/nvme/nvme_ctrlr_cmd.c index 4f1c0b4dc6..8fd8e5901b 100644 --- a/lib/nvme/nvme_ctrlr_cmd.c +++ b/lib/nvme/nvme_ctrlr_cmd.c @@ -399,7 +399,13 @@ spdk_nvme_ctrlr_cmd_abort(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_qpair int rc; struct nvme_request *req; struct spdk_nvme_cmd *cmd; - uint16_t sqid = qpair->id; + uint16_t sqid; + + if (qpair) { + sqid = qpair->id; + } else { + sqid = ctrlr->adminq->id; /* 0 */ + } nvme_robust_mutex_lock(&ctrlr->ctrlr_lock); req = nvme_allocate_request_null(cb_fn, cb_arg); diff --git a/lib/nvme/nvme_pcie.c b/lib/nvme/nvme_pcie.c index d9a6fcd94c..83a3418ff8 100644 --- a/lib/nvme/nvme_pcie.c +++ b/lib/nvme/nvme_pcie.c @@ -1823,13 +1823,21 @@ nvme_pcie_qpair_check_timeout(struct spdk_nvme_qpair *qpair) struct nvme_pcie_qpair *pqpair = nvme_pcie_qpair(qpair); struct spdk_nvme_ctrlr *ctrlr = qpair->ctrlr; + /* We don't want to expose the admin queue to the user, + * so when we're timing out admin commands set the + * qpair to NULL. + */ + if (qpair == ctrlr->adminq) { + qpair = NULL; + } + t02 = spdk_get_ticks(); TAILQ_FOREACH_SAFE(tr, &pqpair->outstanding_tr, tq_list, tmp) { if (tr->timed_out) { continue; } - if (qpair == ctrlr->adminq && + if (qpair == NULL && tr->req->cmd.opc == SPDK_NVME_OPC_ASYNC_EVENT_REQUEST) { continue; }