event: spdk_subsystem_init no longer requires an event
It just takes a function pointer and a context instead. Change-Id: Id8cdc968ddbc3776f60ad73e9aa09983ca03fa3f Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446993 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
c1672b6021
commit
f155c98084
@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
#include "spdk/event.h"
|
#include "spdk/event.h"
|
||||||
#include "spdk/json.h"
|
#include "spdk/json.h"
|
||||||
|
#include "spdk/thread.h"
|
||||||
|
|
||||||
struct spdk_event {
|
struct spdk_event {
|
||||||
uint32_t lcore;
|
uint32_t lcore;
|
||||||
@ -86,7 +87,7 @@ extern struct spdk_subsystem_depend_list g_subsystems_deps;
|
|||||||
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(struct spdk_event *app_start_event);
|
void spdk_subsystem_init(spdk_msg_fn cb_fn, void *cb_arg);
|
||||||
void spdk_subsystem_fini(struct spdk_event *app_finish_event);
|
void spdk_subsystem_fini(struct spdk_event *app_finish_event);
|
||||||
void spdk_subsystem_init_next(int rc);
|
void spdk_subsystem_init_next(int rc);
|
||||||
void spdk_subsystem_fini_next(void);
|
void spdk_subsystem_fini_next(void);
|
||||||
|
@ -573,11 +573,10 @@ bootstrap_fn(void *arg1, void *arg2)
|
|||||||
spdk_app_json_config_load(g_spdk_app.json_config_file, g_spdk_app.rpc_addr, _spdk_app_start_rpc,
|
spdk_app_json_config_load(g_spdk_app.json_config_file, g_spdk_app.rpc_addr, _spdk_app_start_rpc,
|
||||||
NULL);
|
NULL);
|
||||||
} else {
|
} else {
|
||||||
rpc_start_event = spdk_event_allocate(g_init_lcore, spdk_app_start_rpc, NULL, NULL);
|
|
||||||
|
|
||||||
if (!g_delay_subsystem_init) {
|
if (!g_delay_subsystem_init) {
|
||||||
spdk_subsystem_init(rpc_start_event);
|
spdk_subsystem_init(_spdk_app_start_rpc, NULL);
|
||||||
} else {
|
} else {
|
||||||
|
rpc_start_event = spdk_event_allocate(g_init_lcore, spdk_app_start_rpc, NULL, NULL);
|
||||||
spdk_event_call(rpc_start_event);
|
spdk_event_call(rpc_start_event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1059,11 +1058,13 @@ spdk_app_usage(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spdk_rpc_start_subsystem_init_cpl(void *arg1, void *arg2)
|
spdk_rpc_start_subsystem_init_cpl(void *arg1)
|
||||||
{
|
{
|
||||||
struct spdk_jsonrpc_request *request = arg1;
|
struct spdk_jsonrpc_request *request = arg1;
|
||||||
struct spdk_json_write_ctx *w;
|
struct spdk_json_write_ctx *w;
|
||||||
|
|
||||||
|
assert(spdk_env_get_current_core() == g_init_lcore);
|
||||||
|
|
||||||
spdk_app_start_application();
|
spdk_app_start_application();
|
||||||
|
|
||||||
w = spdk_jsonrpc_begin_result(request);
|
w = spdk_jsonrpc_begin_result(request);
|
||||||
@ -1079,17 +1080,13 @@ static void
|
|||||||
spdk_rpc_start_subsystem_init(struct spdk_jsonrpc_request *request,
|
spdk_rpc_start_subsystem_init(struct spdk_jsonrpc_request *request,
|
||||||
const struct spdk_json_val *params)
|
const struct spdk_json_val *params)
|
||||||
{
|
{
|
||||||
struct spdk_event *cb_event;
|
|
||||||
|
|
||||||
if (params != NULL) {
|
if (params != NULL) {
|
||||||
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||||
"start_subsystem_init requires no parameters");
|
"start_subsystem_init requires no parameters");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cb_event = spdk_event_allocate(g_init_lcore, spdk_rpc_start_subsystem_init_cpl,
|
spdk_subsystem_init(spdk_rpc_start_subsystem_init_cpl, request);
|
||||||
request, NULL);
|
|
||||||
spdk_subsystem_init(cb_event);
|
|
||||||
}
|
}
|
||||||
SPDK_RPC_REGISTER("start_subsystem_init", spdk_rpc_start_subsystem_init, SPDK_RPC_STARTUP)
|
SPDK_RPC_REGISTER("start_subsystem_init", spdk_rpc_start_subsystem_init, SPDK_RPC_STARTUP)
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "spdk/stdinc.h"
|
#include "spdk/stdinc.h"
|
||||||
|
|
||||||
#include "spdk/log.h"
|
#include "spdk/log.h"
|
||||||
|
#include "spdk/thread.h"
|
||||||
|
|
||||||
#include "spdk_internal/event.h"
|
#include "spdk_internal/event.h"
|
||||||
#include "spdk/env.h"
|
#include "spdk/env.h"
|
||||||
@ -43,7 +44,8 @@ struct spdk_subsystem_depend_list g_subsystems_deps = TAILQ_HEAD_INITIALIZER(g_s
|
|||||||
static struct spdk_subsystem *g_next_subsystem;
|
static struct spdk_subsystem *g_next_subsystem;
|
||||||
static bool g_subsystems_initialized = false;
|
static bool g_subsystems_initialized = false;
|
||||||
static bool g_subsystems_init_interrupted = false;
|
static bool g_subsystems_init_interrupted = false;
|
||||||
static struct spdk_event *g_app_start_event;
|
static spdk_msg_fn g_app_start_fn = NULL;
|
||||||
|
static void *g_app_start_arg = NULL;
|
||||||
static struct spdk_event *g_app_stop_event;
|
static struct spdk_event *g_app_stop_event;
|
||||||
static uint32_t g_fini_core;
|
static uint32_t g_fini_core;
|
||||||
|
|
||||||
@ -136,7 +138,7 @@ spdk_subsystem_init_next(int rc)
|
|||||||
|
|
||||||
if (!g_next_subsystem) {
|
if (!g_next_subsystem) {
|
||||||
g_subsystems_initialized = true;
|
g_subsystems_initialized = true;
|
||||||
spdk_event_call(g_app_start_event);
|
g_app_start_fn(g_app_start_arg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,11 +175,12 @@ spdk_subsystem_verify(void *arg1, void *arg2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
spdk_subsystem_init(struct spdk_event *app_start_event)
|
spdk_subsystem_init(spdk_msg_fn cb_fn, void *cb_arg)
|
||||||
{
|
{
|
||||||
struct spdk_event *verify_event;
|
struct spdk_event *verify_event;
|
||||||
|
|
||||||
g_app_start_event = app_start_event;
|
g_app_start_fn = cb_fn;
|
||||||
|
g_app_start_arg = cb_arg;
|
||||||
|
|
||||||
verify_event = spdk_event_allocate(spdk_env_get_current_core(), spdk_subsystem_verify, NULL, NULL);
|
verify_event = spdk_event_allocate(spdk_env_get_current_core(), spdk_subsystem_verify, NULL, NULL);
|
||||||
spdk_event_call(verify_event);
|
spdk_event_call(verify_event);
|
||||||
|
@ -43,7 +43,7 @@ DEFINE_STUB_V(spdk_event_call, (struct spdk_event *event));
|
|||||||
DEFINE_STUB(spdk_event_allocate, struct spdk_event *, (uint32_t core, spdk_event_fn fn, void *arg1,
|
DEFINE_STUB(spdk_event_allocate, struct spdk_event *, (uint32_t core, spdk_event_fn fn, void *arg1,
|
||||||
void *arg2), NULL);
|
void *arg2), NULL);
|
||||||
DEFINE_STUB(spdk_env_get_current_core, uint32_t, (void), 0);
|
DEFINE_STUB(spdk_env_get_current_core, uint32_t, (void), 0);
|
||||||
DEFINE_STUB_V(spdk_subsystem_init, (struct spdk_event *app_start_event));
|
DEFINE_STUB_V(spdk_subsystem_init, (spdk_msg_fn cb_fn, void *cb_arg));
|
||||||
DEFINE_STUB_V(spdk_rpc_register_method, (const char *method, spdk_rpc_method_handler func,
|
DEFINE_STUB_V(spdk_rpc_register_method, (const char *method, spdk_rpc_method_handler func,
|
||||||
uint32_t state_mask));
|
uint32_t state_mask));
|
||||||
DEFINE_STUB_V(spdk_rpc_set_state, (uint32_t state));
|
DEFINE_STUB_V(spdk_rpc_set_state, (uint32_t state));
|
||||||
|
@ -55,7 +55,7 @@ spdk_env_get_current_core(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ut_event_fn(void *arg1, void *arg2)
|
ut_event_fn(void *arg1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,11 +121,9 @@ 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;
|
||||||
app_start_event = spdk_event_allocate(0, ut_event_fn, NULL, NULL);
|
spdk_subsystem_init(ut_event_fn, NULL);
|
||||||
spdk_subsystem_init(app_start_event);
|
|
||||||
|
|
||||||
i = 4;
|
i = 4;
|
||||||
TAILQ_FOREACH(subsystem, &g_subsystems, tailq) {
|
TAILQ_FOREACH(subsystem, &g_subsystems, tailq) {
|
||||||
@ -141,7 +139,6 @@ 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");
|
||||||
@ -171,8 +168,7 @@ subsystem_sort_test_depends_on_multiple(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
global_rc = -1;
|
global_rc = -1;
|
||||||
app_start_event = spdk_event_allocate(0, ut_event_fn, NULL, NULL);
|
spdk_subsystem_init(ut_event_fn, 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);
|
||||||
@ -247,7 +243,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);
|
spdk_subsystem_init(ut_event_fn, NULL);
|
||||||
CU_ASSERT(global_rc != 0);
|
CU_ASSERT(global_rc != 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -262,7 +258,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);
|
spdk_subsystem_init(ut_event_fn, NULL);
|
||||||
CU_ASSERT(global_rc != 0);
|
CU_ASSERT(global_rc != 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user