nvme: move is_enabled logic to common layer

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Idd938f255226256d864f70921ecd70c54769b9b2

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453485
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Jim Harris 2019-05-06 16:37:01 -07:00 committed by Changpeng Liu
parent 4dd2fae3ad
commit 5d431efd6d
4 changed files with 30 additions and 28 deletions

View File

@ -1432,7 +1432,6 @@ nvme_pcie_io_qpair_enable(struct spdk_nvme_qpair *qpair)
int
nvme_pcie_qpair_enable(struct spdk_nvme_qpair *qpair)
{
qpair->is_enabled = true;
if (nvme_qpair_is_io_queue(qpair)) {
nvme_pcie_io_qpair_enable(qpair);
} else {
@ -1455,7 +1454,6 @@ nvme_pcie_io_qpair_disable(struct spdk_nvme_qpair *qpair)
int
nvme_pcie_qpair_disable(struct spdk_nvme_qpair *qpair)
{
qpair->is_enabled = false;
if (nvme_qpair_is_io_queue(qpair)) {
nvme_pcie_io_qpair_disable(qpair);
} else {
@ -1974,16 +1972,6 @@ nvme_pcie_qpair_build_prps_sgl_request(struct spdk_nvme_qpair *qpair, struct nvm
return 0;
}
static inline bool
nvme_pcie_qpair_check_enabled(struct spdk_nvme_qpair *qpair)
{
if (!qpair->is_enabled &&
!qpair->ctrlr->is_resetting) {
nvme_qpair_enable(qpair);
}
return qpair->is_enabled;
}
int
nvme_pcie_qpair_submit_request(struct spdk_nvme_qpair *qpair, struct nvme_request *req)
{
@ -1993,8 +1981,6 @@ nvme_pcie_qpair_submit_request(struct spdk_nvme_qpair *qpair, struct nvme_reques
struct spdk_nvme_ctrlr *ctrlr = qpair->ctrlr;
struct nvme_pcie_qpair *pqpair = nvme_pcie_qpair(qpair);
nvme_pcie_qpair_check_enabled(qpair);
if (spdk_unlikely(nvme_qpair_is_admin_queue(qpair))) {
nvme_robust_mutex_lock(&ctrlr->ctrlr_lock);
}
@ -2111,16 +2097,6 @@ nvme_pcie_qpair_process_completions(struct spdk_nvme_qpair *qpair, uint32_t max_
uint32_t num_completions = 0;
struct spdk_nvme_ctrlr *ctrlr = qpair->ctrlr;
if (spdk_unlikely(!nvme_pcie_qpair_check_enabled(qpair))) {
/*
* qpair is not enabled, likely because a controller reset is
* is in progress. Ignore the interrupt - any I/O that was
* associated with this interrupt will get retried when the
* reset is complete.
*/
return 0;
}
if (spdk_unlikely(nvme_qpair_is_admin_queue(qpair))) {
nvme_robust_mutex_lock(&ctrlr->ctrlr_lock);
}

View File

@ -386,6 +386,16 @@ nvme_qpair_manual_complete_request(struct spdk_nvme_qpair *qpair,
nvme_free_request(req);
}
static bool
nvme_qpair_check_enabled(struct spdk_nvme_qpair *qpair)
{
if (!qpair->is_enabled && !qpair->ctrlr->is_resetting) {
nvme_qpair_enable(qpair);
}
return qpair->is_enabled;
}
int32_t
spdk_nvme_qpair_process_completions(struct spdk_nvme_qpair *qpair, uint32_t max_completions)
{
@ -397,6 +407,14 @@ spdk_nvme_qpair_process_completions(struct spdk_nvme_qpair *qpair, uint32_t max_
return 0;
}
if (spdk_unlikely(!nvme_qpair_check_enabled(qpair))) {
/*
* qpair is not enabled, likely because a controller reset is
* in progress.
*/
return 0;
}
/* error injection for those queued error requests */
if (spdk_unlikely(!STAILQ_EMPTY(&qpair->err_req_head))) {
STAILQ_FOREACH_SAFE(req, &qpair->err_req_head, stailq, tmp) {
@ -501,6 +519,8 @@ nvme_qpair_submit_request(struct spdk_nvme_qpair *qpair, struct nvme_request *re
return -ENXIO;
}
nvme_qpair_check_enabled(qpair);
if (req->num_children) {
/*
* This is a split (parent) request. Submit all of the children but not the parent
@ -576,6 +596,7 @@ nvme_qpair_enable(struct spdk_nvme_qpair *qpair)
_nvme_io_qpair_enable(qpair);
}
qpair->is_enabled = true;
nvme_transport_qpair_enable(qpair);
}
@ -596,6 +617,7 @@ nvme_qpair_complete_error_reqs(struct spdk_nvme_qpair *qpair)
void
nvme_qpair_disable(struct spdk_nvme_qpair *qpair)
{
qpair->is_enabled = false;
nvme_transport_qpair_disable(qpair);
}

View File

@ -1558,9 +1558,11 @@ nvme_rdma_qpair_submit_request(struct spdk_nvme_qpair *qpair,
assert(req != NULL);
rdma_req = nvme_rdma_req_get(rqpair);
if (!rdma_req) {
if (!rdma_req || !qpair->is_enabled) {
/*
* No rdma_req is available. Queue the request to be processed later.
* No rdma_req is available, or the qpair is disabled due to
* an in-progress reset. Queue the request to be processed
* later.
*/
STAILQ_INSERT_TAIL(&qpair->queued_req, req, stailq);
return 0;

View File

@ -704,9 +704,11 @@ nvme_tcp_qpair_submit_request(struct spdk_nvme_qpair *qpair,
assert(req != NULL);
tcp_req = nvme_tcp_req_get(tqpair);
if (!tcp_req) {
if (!tcp_req || !qpair->is_enabled) {
/*
* No tcp_req is available. Queue the request to be processed later.
* No tcp_req is available, or the qpair is currently disabled
* due to an in-progress reset. Queue the request to be
* processed later.
*/
STAILQ_INSERT_TAIL(&qpair->queued_req, req, stailq);
return 0;