Commit eaaddf3d authored by Ben Walker's avatar Ben Walker Committed by Jim Harris
Browse files

nvmf: Poll groups now automatically register pollers



This simplifies the public API and requirements for
user applications.

Change-Id: Ibb0d25a7838a0fa683f39e79cb4fef78adf6aee8
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/388040


Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
parent 2bbe6a80
Loading
Loading
Loading
Loading
+0 −22
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@

struct nvmf_tgt_poll_group {
	struct spdk_nvmf_poll_group *group;
	struct spdk_poller *poller;
};

struct nvmf_tgt g_tgt = {};
@@ -111,14 +110,6 @@ spdk_nvmf_shutdown_cb(void)
	nvmf_tgt_advance_state(NULL, NULL);
}

static void
subsystem_poll(void *arg)
{
	struct nvmf_tgt_subsystem *app_subsys = arg;

	spdk_nvmf_subsystem_poll(app_subsys->subsystem);
}

static void
_nvmf_tgt_start_subsystem(void *arg1, void *arg2)
{
@@ -126,8 +117,6 @@ _nvmf_tgt_start_subsystem(void *arg1, void *arg2)
	struct spdk_nvmf_subsystem *subsystem = app_subsys->subsystem;

	spdk_nvmf_subsystem_start(subsystem);

	app_subsys->poller = spdk_poller_register(subsystem_poll, app_subsys, 0);
}

void
@@ -210,14 +199,6 @@ acceptor_poll(void *arg)
	spdk_nvmf_tgt_accept(tgt);
}

static void
nvmf_tgt_poll_group_poll(void *arg)
{
	struct nvmf_tgt_poll_group *app_poll_group = arg;

	spdk_nvmf_poll_group_poll(app_poll_group->group);
}

static void
nvmf_tgt_destroy_poll_group_done(void *arg1, void *arg2)
{
@@ -236,8 +217,6 @@ nvmf_tgt_destroy_poll_group(void *arg1, void *arg2)
	pg = &g_poll_groups[g_tgt.core];
	assert(pg != NULL);

	spdk_poller_unregister(&pg->poller);

	spdk_nvmf_poll_group_destroy(pg->group);
	pg->group = NULL;

@@ -276,7 +255,6 @@ nvmf_tgt_create_poll_group(void *arg1, void *arg2)
		SPDK_ERRLOG("Failed to create poll group for core %u\n", g_tgt.core);
	}

	pg->poller = spdk_poller_register(nvmf_tgt_poll_group_poll, pg, 0);
	g_active_poll_groups++;

	spdk_event_call(event);
+0 −8
Original line number Diff line number Diff line
@@ -111,11 +111,6 @@ struct spdk_nvmf_poll_group *spdk_nvmf_poll_group_create(struct spdk_nvmf_tgt *t
 */
void spdk_nvmf_poll_group_destroy(struct spdk_nvmf_poll_group *group);

/**
 * Check a poll group for work completions.
 */
int spdk_nvmf_poll_group_poll(struct spdk_nvmf_poll_group *group);

/*
 * The NVMf subsystem, as indicated in the specification, is a collection
 * of controllers.  Any individual controller has
@@ -254,9 +249,6 @@ struct spdk_nvmf_listener *spdk_nvmf_subsystem_get_next_listener(
const struct spdk_nvme_transport_id *spdk_nvmf_listener_get_trid(
	struct spdk_nvmf_listener *listener);


void spdk_nvmf_subsystem_poll(struct spdk_nvmf_subsystem *subsystem);

/**
 * Add a namespace to a subsytem.
 *
+0 −6
Original line number Diff line number Diff line
@@ -589,12 +589,6 @@ spdk_nvmf_property_set(struct spdk_nvmf_request *req)
	return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE;
}

int
spdk_nvmf_ctrlr_poll(struct spdk_nvmf_ctrlr *ctrlr)
{
	return spdk_nvmf_poll_group_poll(ctrlr->group);
}

static int
spdk_nvmf_ctrlr_set_features_host_identifier(struct spdk_nvmf_request *req)
{
+19 −19
Original line number Diff line number Diff line
@@ -199,6 +199,21 @@ spdk_nvmf_tgt_accept(struct spdk_nvmf_tgt *tgt)
	}
}

static void
spdk_nvmf_poll_group_poll(void *ctx)
{
	struct spdk_nvmf_poll_group *group = ctx;
	int rc;
	struct spdk_nvmf_transport_poll_group *tgroup;

	TAILQ_FOREACH(tgroup, &group->tgroups, link) {
		rc = spdk_nvmf_transport_poll_group_poll(tgroup);
		if (rc < 0) {
			return;
		}
	}
}

struct spdk_nvmf_poll_group *
spdk_nvmf_poll_group_create(struct spdk_nvmf_tgt *tgt)
{
@@ -223,6 +238,8 @@ spdk_nvmf_poll_group_create(struct spdk_nvmf_tgt *tgt)
		TAILQ_INSERT_TAIL(&group->tgroups, tgroup, link);
	}

	group->poller = spdk_poller_register(spdk_nvmf_poll_group_poll, group, 0);

	return group;
}

@@ -231,6 +248,8 @@ spdk_nvmf_poll_group_destroy(struct spdk_nvmf_poll_group *group)
{
	struct spdk_nvmf_transport_poll_group *tgroup, *tmp;

	spdk_poller_unregister(&group->poller);

	TAILQ_FOREACH_SAFE(tgroup, &group->tgroups, link, tmp) {
		TAILQ_REMOVE(&group->tgroups, tgroup, link);
		spdk_nvmf_transport_poll_group_destroy(tgroup);
@@ -273,25 +292,6 @@ spdk_nvmf_poll_group_remove(struct spdk_nvmf_poll_group *group,
	return rc;
}

int
spdk_nvmf_poll_group_poll(struct spdk_nvmf_poll_group *group)
{
	int rc;
	int count = 0;
	struct spdk_nvmf_transport_poll_group *tgroup;

	TAILQ_FOREACH(tgroup, &group->tgroups, link) {
		rc = spdk_nvmf_transport_poll_group_poll(tgroup);
		if (rc < 0) {
			return rc;
		}
		count += rc;
		break;
	}

	return count;
}

SPDK_TRACE_REGISTER_FN(nvmf_trace)
{
	spdk_trace_register_object(OBJECT_NVMF_IO, 'r');
+2 −2
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ struct spdk_nvmf_transport_poll_group {
};

struct spdk_nvmf_poll_group {
	struct spdk_poller				*poller;
	TAILQ_HEAD(, spdk_nvmf_transport_poll_group)	tgroups;
};

@@ -214,7 +215,6 @@ void spdk_nvmf_get_discovery_log_page(struct spdk_nvmf_tgt *tgt,
				      uint32_t length);

struct spdk_nvmf_qpair *spdk_nvmf_ctrlr_get_qpair(struct spdk_nvmf_ctrlr *ctrlr, uint16_t qid);
int spdk_nvmf_ctrlr_poll(struct spdk_nvmf_ctrlr *ctrlr);
void spdk_nvmf_ctrlr_destruct(struct spdk_nvmf_ctrlr *ctrlr);
int spdk_nvmf_ctrlr_process_fabrics_cmd(struct spdk_nvmf_request *req);
int spdk_nvmf_ctrlr_process_admin_cmd(struct spdk_nvmf_request *req);
Loading