diff --git a/include/spdk/nvme.h b/include/spdk/nvme.h index 3ab81878b..6c9d390cf 100644 --- a/include/spdk/nvme.h +++ b/include/spdk/nvme.h @@ -1246,26 +1246,6 @@ int spdk_nvme_ctrlr_cmd_io_raw_with_md(struct spdk_nvme_ctrlr *ctrlr, int32_t spdk_nvme_qpair_process_completions(struct spdk_nvme_qpair *qpair, uint32_t max_completions); -/** - * Process IO message sent to controller from external module. - * - * This call process requests from the ring, send IO to an allocated qpair or - * admin commands in its context. This call is non-blocking and intended to be - * polled by SPDK thread to provide safe environment for NVMe request - * completition sent by external module to controller. - * - * The caller must ensure that each controller is polled by only one thread at - * a time. - * - * This function may be called at any point while the controller is attached to - * the SPDK NVMe driver. - * - * \param ctrlr Opaque handle to NVMe controller. - * - * \return number of processed external IO messages. - */ -int spdk_nvme_io_msg_process(struct spdk_nvme_ctrlr *ctrlr); - /** * Send the given admin command to the NVMe controller. * diff --git a/lib/nvme/nvme_ctrlr.c b/lib/nvme/nvme_ctrlr.c index e89c1c2d0..8d3e35237 100644 --- a/lib/nvme/nvme_ctrlr.c +++ b/lib/nvme/nvme_ctrlr.c @@ -34,6 +34,7 @@ #include "spdk/stdinc.h" #include "nvme_internal.h" +#include "nvme_io_msg.h" #include "spdk/env.h" #include "spdk/string.h" @@ -2646,14 +2647,30 @@ int32_t spdk_nvme_ctrlr_process_admin_completions(struct spdk_nvme_ctrlr *ctrlr) { int32_t num_completions; + int32_t rc; nvme_robust_mutex_lock(&ctrlr->ctrlr_lock); + if (ctrlr->keep_alive_interval_ticks) { nvme_ctrlr_keep_alive(ctrlr); } - num_completions = spdk_nvme_qpair_process_completions(ctrlr->adminq, 0); + + rc = spdk_nvme_io_msg_process(ctrlr); + if (rc < 0) { + nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock); + return rc; + } + num_completions = rc; + + rc = spdk_nvme_qpair_process_completions(ctrlr->adminq, 0); nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock); + if (rc < 0) { + num_completions = rc; + } else { + num_completions += rc; + } + return num_completions; } diff --git a/lib/nvme/nvme_io_msg.h b/lib/nvme/nvme_io_msg.h index 2efa5fcaf..69bf17fe5 100644 --- a/lib/nvme/nvme_io_msg.h +++ b/lib/nvme/nvme_io_msg.h @@ -58,6 +58,26 @@ struct nvme_io_msg_producer { int nvme_io_msg_send(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid, spdk_nvme_io_msg_fn fn, void *arg); +/** + * Process IO message sent to controller from external module. + * + * This call process requests from the ring, send IO to an allocated qpair or + * admin commands in its context. This call is non-blocking and intended to be + * polled by SPDK thread to provide safe environment for NVMe request + * completition sent by external module to controller. + * + * The caller must ensure that each controller is polled by only one thread at + * a time. + * + * This function may be called at any point while the controller is attached to + * the SPDK NVMe driver. + * + * \param ctrlr Opaque handle to NVMe controller. + * + * \return number of processed external IO messages. + */ +int spdk_nvme_io_msg_process(struct spdk_nvme_ctrlr *ctrlr); + int nvme_io_msg_ctrlr_start(struct spdk_nvme_ctrlr *ctrlr, struct nvme_io_msg_producer *io_msg_producer); void nvme_io_msg_ctrlr_stop(struct spdk_nvme_ctrlr *ctrlr, diff --git a/module/bdev/nvme/bdev_nvme.c b/module/bdev/nvme/bdev_nvme.c index 0accdeba1..8ca2dc5b9 100644 --- a/module/bdev/nvme/bdev_nvme.c +++ b/module/bdev/nvme/bdev_nvme.c @@ -210,13 +210,6 @@ bdev_nvme_poll_adminq(void *arg) { struct spdk_nvme_ctrlr *ctrlr = arg; - /* Process io messages that were passed from non-polled mode threads - * to this ctrlr. This is used as part of nvme cuse support for surfacing - * /dev nodes that can be used by standard Linux management applications - * like nvme-cli. - */ - spdk_nvme_io_msg_process(ctrlr); - return spdk_nvme_ctrlr_process_admin_completions(ctrlr); }