diff --git a/lib/nvme/nvme_internal.h b/lib/nvme/nvme_internal.h index be10f3c539..d259e362c9 100644 --- a/lib/nvme/nvme_internal.h +++ b/lib/nvme/nvme_internal.h @@ -925,6 +925,7 @@ void nvme_qpair_complete_error_reqs(struct spdk_nvme_qpair *qpair); int nvme_qpair_submit_request(struct spdk_nvme_qpair *qpair, struct nvme_request *req); void nvme_qpair_abort_reqs(struct spdk_nvme_qpair *qpair, uint32_t dnr); +void nvme_qpair_resubmit_requests(struct spdk_nvme_qpair *qpair, uint32_t num_requests); int nvme_ctrlr_identify_active_ns(struct spdk_nvme_ctrlr *ctrlr); void nvme_ns_set_identify_data(struct spdk_nvme_ns *ns); diff --git a/lib/nvme/nvme_qpair.c b/lib/nvme/nvme_qpair.c index 29e1d541f4..433e41f8c7 100644 --- a/lib/nvme/nvme_qpair.c +++ b/lib/nvme/nvme_qpair.c @@ -454,12 +454,33 @@ nvme_qpair_check_enabled(struct spdk_nvme_qpair *qpair) return nvme_qpair_get_state(qpair) == NVME_QPAIR_ENABLED; } +void +nvme_qpair_resubmit_requests(struct spdk_nvme_qpair *qpair, uint32_t num_requests) +{ + uint32_t i; + int resubmit_rc; + struct nvme_request *req; + + for (i = 0; i < num_requests; i++) { + if (qpair->ctrlr->is_resetting) { + break; + } + if ((req = STAILQ_FIRST(&qpair->queued_req)) == NULL) { + break; + } + STAILQ_REMOVE_HEAD(&qpair->queued_req, stailq); + resubmit_rc = nvme_qpair_resubmit_request(qpair, req); + if (spdk_unlikely(resubmit_rc != 0)) { + SPDK_ERRLOG("Unable to resubmit as many requests as we completed.\n"); + break; + } + } +} + int32_t spdk_nvme_qpair_process_completions(struct spdk_nvme_qpair *qpair, uint32_t max_completions) { int32_t ret; - int32_t resubmit_rc; - int32_t i; struct nvme_request *req, *tmp; if (spdk_unlikely(qpair->ctrlr->is_failed)) { @@ -513,17 +534,7 @@ spdk_nvme_qpair_process_completions(struct spdk_nvme_qpair *qpair, uint32_t max_ * At this point, ret must represent the number of completions we reaped. * submit as many queued requests as we completed. */ - i = 0; - while (i < ret && !STAILQ_EMPTY(&qpair->queued_req) && !qpair->ctrlr->is_resetting) { - req = STAILQ_FIRST(&qpair->queued_req); - STAILQ_REMOVE_HEAD(&qpair->queued_req, stailq); - resubmit_rc = nvme_qpair_resubmit_request(qpair, req); - if (spdk_unlikely(resubmit_rc != 0)) { - SPDK_ERRLOG("Unable to resubmit as many requests as we completed.\n"); - break; - } - i++; - } + nvme_qpair_resubmit_requests(qpair, ret); return ret; }