subsystem: move allocation of subsystem_init event to subsystem
Previously two spdk_events were allocated in spdk_app_start(). Now app allocated spdk_event for function to be called after initialization is complete. Meanwhile subsystem allocates its own spdk_event. Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Change-Id: I4822f76d30cc2f7b95a86a4ffbfc61b80c0a903e Reviewed-on: https://review.gerrithub.io/382673 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:
parent
0473a303e0
commit
7aba48fe1e
@ -70,7 +70,7 @@ struct spdk_subsystem_depend {
|
|||||||
void spdk_add_subsystem(struct spdk_subsystem *subsystem);
|
void spdk_add_subsystem(struct spdk_subsystem *subsystem);
|
||||||
void spdk_add_subsystem_depend(struct spdk_subsystem_depend *depend);
|
void spdk_add_subsystem_depend(struct spdk_subsystem_depend *depend);
|
||||||
|
|
||||||
void spdk_subsystem_init(void *arg1, void *arg2);
|
void spdk_subsystem_init(struct spdk_event *app_start_event);
|
||||||
void spdk_subsystem_fini(void);
|
void spdk_subsystem_fini(void);
|
||||||
void spdk_subsystem_init_next(int rc);
|
void spdk_subsystem_init_next(int rc);
|
||||||
void spdk_subsystem_config(FILE *fp);
|
void spdk_subsystem_config(FILE *fp);
|
||||||
|
@ -379,8 +379,7 @@ spdk_app_start(struct spdk_app_opts *opts, spdk_event_fn start_fn,
|
|||||||
app_start_event = spdk_event_allocate(spdk_env_get_current_core(), start_fn,
|
app_start_event = spdk_event_allocate(spdk_env_get_current_core(), start_fn,
|
||||||
arg1, arg2);
|
arg1, arg2);
|
||||||
|
|
||||||
spdk_event_call(spdk_event_allocate(spdk_env_get_current_core(), spdk_subsystem_init,
|
spdk_subsystem_init(app_start_event);
|
||||||
app_start_event, NULL));
|
|
||||||
|
|
||||||
/* This blocks until spdk_app_stop is called */
|
/* This blocks until spdk_app_stop is called */
|
||||||
spdk_reactors_start();
|
spdk_reactors_start();
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "spdk/log.h"
|
#include "spdk/log.h"
|
||||||
|
|
||||||
#include "spdk_internal/event.h"
|
#include "spdk_internal/event.h"
|
||||||
|
#include "spdk/env.h"
|
||||||
|
|
||||||
static TAILQ_HEAD(spdk_subsystem_list, spdk_subsystem) g_subsystems =
|
static TAILQ_HEAD(spdk_subsystem_list, spdk_subsystem) g_subsystems =
|
||||||
TAILQ_HEAD_INITIALIZER(g_subsystems);
|
TAILQ_HEAD_INITIALIZER(g_subsystems);
|
||||||
@ -138,13 +139,11 @@ spdk_subsystem_init_next(int rc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
spdk_subsystem_init(void *arg1, void *arg2)
|
spdk_subsystem_verify(void *arg1, void *arg2)
|
||||||
{
|
{
|
||||||
struct spdk_subsystem_depend *dep;
|
struct spdk_subsystem_depend *dep;
|
||||||
|
|
||||||
g_app_start_event = (struct spdk_event *)arg1;
|
|
||||||
|
|
||||||
/* Verify that all dependency name and depends_on subsystems are registered */
|
/* Verify that all dependency name and depends_on subsystems are registered */
|
||||||
TAILQ_FOREACH(dep, &g_depends, tailq) {
|
TAILQ_FOREACH(dep, &g_depends, tailq) {
|
||||||
if (!spdk_subsystem_find(&g_subsystems, dep->name)) {
|
if (!spdk_subsystem_find(&g_subsystems, dep->name)) {
|
||||||
@ -165,6 +164,17 @@ spdk_subsystem_init(void *arg1, void *arg2)
|
|||||||
spdk_subsystem_init_next(0);
|
spdk_subsystem_init_next(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
spdk_subsystem_init(struct spdk_event *app_start_event)
|
||||||
|
{
|
||||||
|
struct spdk_event *verify_event;
|
||||||
|
|
||||||
|
g_app_start_event = app_start_event;
|
||||||
|
|
||||||
|
verify_event = spdk_event_allocate(spdk_env_get_current_core(), spdk_subsystem_verify, NULL, NULL);
|
||||||
|
spdk_event_call(verify_event);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
spdk_subsystem_fini(void)
|
spdk_subsystem_fini(void)
|
||||||
{
|
{
|
||||||
|
@ -47,8 +47,33 @@ spdk_app_stop(int rc)
|
|||||||
global_rc = rc;
|
global_rc = rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t
|
||||||
|
spdk_env_get_current_core(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ut_event_fn(void *arg1, void *arg2)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
struct spdk_event *
|
||||||
|
spdk_event_allocate(uint32_t core, spdk_event_fn fn, void *arg1, void *arg2)
|
||||||
|
{
|
||||||
|
struct spdk_event *event = calloc(1, sizeof(*event));
|
||||||
|
|
||||||
|
event->fn = fn;
|
||||||
|
event->arg1 = arg1;
|
||||||
|
event->arg2 = arg2;
|
||||||
|
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
void spdk_event_call(struct spdk_event *event)
|
void spdk_event_call(struct spdk_event *event)
|
||||||
{
|
{
|
||||||
|
event->fn(event->arg1, event->arg2);
|
||||||
|
free(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -89,9 +114,11 @@ subsystem_sort_test_depends_on_single(void)
|
|||||||
struct spdk_subsystem *subsystem;
|
struct spdk_subsystem *subsystem;
|
||||||
int i;
|
int i;
|
||||||
char subsystem_name[16];
|
char subsystem_name[16];
|
||||||
|
struct spdk_event *app_start_event;
|
||||||
|
|
||||||
global_rc = -1;
|
global_rc = -1;
|
||||||
spdk_subsystem_init(NULL, NULL);
|
app_start_event = spdk_event_allocate(0, ut_event_fn, NULL, NULL);
|
||||||
|
spdk_subsystem_init(app_start_event);
|
||||||
|
|
||||||
i = 4;
|
i = 4;
|
||||||
TAILQ_FOREACH(subsystem, &g_subsystems, tailq) {
|
TAILQ_FOREACH(subsystem, &g_subsystems, tailq) {
|
||||||
@ -107,6 +134,7 @@ subsystem_sort_test_depends_on_multiple(void)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct spdk_subsystem *subsystem;
|
struct spdk_subsystem *subsystem;
|
||||||
|
struct spdk_event *app_start_event;
|
||||||
|
|
||||||
subsystem_clear();
|
subsystem_clear();
|
||||||
set_up_subsystem(&g_ut_subsystems[0], "iscsi");
|
set_up_subsystem(&g_ut_subsystems[0], "iscsi");
|
||||||
@ -136,7 +164,8 @@ subsystem_sort_test_depends_on_multiple(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
global_rc = -1;
|
global_rc = -1;
|
||||||
spdk_subsystem_init(NULL, NULL);
|
app_start_event = spdk_event_allocate(0, ut_event_fn, NULL, NULL);
|
||||||
|
spdk_subsystem_init(app_start_event);
|
||||||
|
|
||||||
subsystem = TAILQ_FIRST(&g_subsystems);
|
subsystem = TAILQ_FIRST(&g_subsystems);
|
||||||
CU_ASSERT(strcmp(subsystem->name, "interface") == 0);
|
CU_ASSERT(strcmp(subsystem->name, "interface") == 0);
|
||||||
@ -195,7 +224,7 @@ subsystem_sort_test_missing_dependency(void)
|
|||||||
spdk_add_subsystem_depend(&g_ut_subsystem_deps[0]);
|
spdk_add_subsystem_depend(&g_ut_subsystem_deps[0]);
|
||||||
|
|
||||||
global_rc = -1;
|
global_rc = -1;
|
||||||
spdk_subsystem_init(NULL, NULL);
|
spdk_subsystem_init(NULL);
|
||||||
CU_ASSERT(global_rc != 0);
|
CU_ASSERT(global_rc != 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -210,7 +239,7 @@ subsystem_sort_test_missing_dependency(void)
|
|||||||
spdk_add_subsystem_depend(&g_ut_subsystem_deps[0]);
|
spdk_add_subsystem_depend(&g_ut_subsystem_deps[0]);
|
||||||
|
|
||||||
global_rc = -1;
|
global_rc = -1;
|
||||||
spdk_subsystem_init(NULL, NULL);
|
spdk_subsystem_init(NULL);
|
||||||
CU_ASSERT(global_rc != 0);
|
CU_ASSERT(global_rc != 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user