Commit 11739f3c authored by Ben Walker's avatar Ben Walker Committed by Tomasz Zawadzki
Browse files

nvme/cuse: Poll the io_msg queue when the admin queue is polled



Users already have to poll the admin queue, so embed the io_msg
queue polling there to simplify the API.

Change-Id: I4d4d3be100be0798bee4096e0bbda96e20d2405e
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/472833


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent e9b5bef8
Loading
Loading
Loading
Loading
+0 −20
Original line number Diff line number Diff line
@@ -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.
 *
+18 −1
Original line number Diff line number Diff line
@@ -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,13 +2647,29 @@ 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;
}
+20 −0
Original line number Diff line number Diff line
@@ -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,
+0 −7
Original line number Diff line number Diff line
@@ -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);
}