nvmf: Create poll groups on their respective cores

Previously, all of the poll groups were created on the
core doing the configuration. However, creating poll groups
will eventually construct the I/O channels, and that must
be done on the core we plan to use the poll group on.

Change-Id: Iff57ac0e43bb722eb27cf01d7bf55f3946a165eb
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/385515
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Ben Walker 2017-11-02 16:03:10 -07:00
parent db3edeb341
commit 07c639cdec

View File

@ -223,11 +223,43 @@ nvmf_tgt_poll_group_poll(void *arg)
spdk_nvmf_poll_group_poll(app_poll_group->group); spdk_nvmf_poll_group_poll(app_poll_group->group);
} }
static void
nvmf_tgt_create_poll_group_done(void *arg1, void *arg2)
{
struct nvmf_tgt_poll_group *pg;
pg = &g_poll_groups[g_tgt.core];
if (pg->group == NULL) {
g_tgt.state = NVMF_TGT_ERROR;
} else {
g_tgt.state = NVMF_TGT_INIT_START_POLLER;
}
nvmf_tgt_advance_state(NULL, NULL);
}
static void
nvmf_tgt_create_poll_group(void *arg1, void *arg2)
{
struct nvmf_tgt_poll_group *pg;
struct spdk_event *event = arg1;
assert(g_tgt.core == spdk_env_get_current_core());
pg = &g_poll_groups[g_tgt.core];
pg->group = spdk_nvmf_poll_group_create(g_tgt.tgt);
if (pg->group == NULL) {
SPDK_ERRLOG("Failed to create poll group for core %u\n", g_tgt.core);
}
spdk_event_call(event);
}
static void static void
nvmf_tgt_advance_state(void *arg1, void *arg2) nvmf_tgt_advance_state(void *arg1, void *arg2)
{ {
enum nvmf_tgt_state prev_state; enum nvmf_tgt_state prev_state;
int rc = 0; int rc = -1;
do { do {
prev_state = g_tgt.state; prev_state = g_tgt.state;
@ -271,26 +303,18 @@ nvmf_tgt_advance_state(void *arg1, void *arg2)
g_tgt.state = NVMF_TGT_INIT_CREATE_POLL_GROUP; g_tgt.state = NVMF_TGT_INIT_CREATE_POLL_GROUP;
break; break;
case NVMF_TGT_INIT_CREATE_POLL_GROUP: { case NVMF_TGT_INIT_CREATE_POLL_GROUP: {
struct nvmf_tgt_poll_group *pg; struct spdk_event *event, *return_event;
pg = &g_poll_groups[g_tgt.core]; /* Send an event to the poller core, create an event, and event back to this core. */
assert(pg != NULL); return_event = spdk_event_allocate(spdk_env_get_current_core(), nvmf_tgt_create_poll_group_done,
NULL, NULL);
pg->group = spdk_nvmf_poll_group_create(g_tgt.tgt); event = spdk_event_allocate(g_tgt.core, nvmf_tgt_create_poll_group,
if (pg->group == NULL) { return_event, NULL);
SPDK_ERRLOG("Failed to create poll group for core %u\n", g_tgt.core); spdk_event_call(event);
rc = -ENOMEM;
g_tgt.state = NVMF_TGT_ERROR;
break;
}
g_tgt.state = NVMF_TGT_INIT_START_POLLER;
break; break;
} }
case NVMF_TGT_INIT_START_POLLER: { case NVMF_TGT_INIT_START_POLLER: {
struct nvmf_tgt_poll_group *pg; struct nvmf_tgt_poll_group *pg = &g_poll_groups[g_tgt.core];
pg = &g_poll_groups[g_tgt.core];
assert(pg != NULL);
spdk_poller_register(&pg->poller, spdk_poller_register(&pg->poller,
nvmf_tgt_poll_group_poll, pg, nvmf_tgt_poll_group_poll, pg,