event: Move json config loading to init
Loading subsystems and restoring state from a JSON config file is useful outside of the SPDK application framework, so move it to lib/init. Change-Id: I7dd3ceace2e7b1b28eef83c91ce6a4eedc85740e Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6645 Reviewed-by: Tom Nabarro <tom.nabarro@outlook.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot
This commit is contained in:
parent
9f62796127
commit
dde419084b
@ -219,7 +219,7 @@ spdk_fio_bdev_init_start(void *arg)
|
|||||||
{
|
{
|
||||||
bool *done = arg;
|
bool *done = arg;
|
||||||
|
|
||||||
spdk_app_json_config_load(g_json_config_file, SPDK_DEFAULT_RPC_ADDR,
|
spdk_subsystem_init_from_json_config(g_json_config_file, SPDK_DEFAULT_RPC_ADDR,
|
||||||
spdk_fio_bdev_init_done, done, true);
|
spdk_fio_bdev_init_done, done, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,6 +76,20 @@ typedef void (*spdk_subsystem_init_fn)(int rc, void *ctx);
|
|||||||
*/
|
*/
|
||||||
void spdk_subsystem_init(spdk_subsystem_init_fn cb_fn, void *cb_arg);
|
void spdk_subsystem_init(spdk_subsystem_init_fn cb_fn, void *cb_arg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Like spdk_subsystem_init, but additionally configure each subsystem using the provided JSON config
|
||||||
|
* file. This will automatically start a JSON RPC server and then stop it.
|
||||||
|
*
|
||||||
|
* \param json_config_file Path to a JSON config file.
|
||||||
|
* \param rpc_addr Path to a unix domain socket to send configuration RPCs to.
|
||||||
|
* \param cb_fn Function called when the process is complete.
|
||||||
|
* \param cb_arg User context passed to cb_fn.
|
||||||
|
* \param stop_on_error Whether to stop initialization if one of the JSON RPCs fails.
|
||||||
|
*/
|
||||||
|
void spdk_subsystem_init_from_json_config(const char *json_config_file, const char *rpc_addr,
|
||||||
|
spdk_subsystem_init_fn cb_fn, void *cb_arg,
|
||||||
|
bool stop_on_error);
|
||||||
|
|
||||||
typedef void (*spdk_subsystem_fini_fn)(void *ctx);
|
typedef void (*spdk_subsystem_fini_fn)(void *ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -164,12 +164,6 @@ int spdk_reactor_set_interrupt_mode(uint32_t lcore, bool new_in_interrupt,
|
|||||||
*/
|
*/
|
||||||
struct spdk_thread *_spdk_get_app_thread(void);
|
struct spdk_thread *_spdk_get_app_thread(void);
|
||||||
|
|
||||||
typedef void (*spdk_app_init_fn)(int rc, void *ctx);
|
|
||||||
|
|
||||||
void spdk_app_json_config_load(const char *json_config_file, const char *rpc_addr,
|
|
||||||
spdk_app_init_fn cb_fn, void *cb_arg,
|
|
||||||
bool stop_on_error);
|
|
||||||
|
|
||||||
struct spdk_governor_capabilities {
|
struct spdk_governor_capabilities {
|
||||||
bool freq_change;
|
bool freq_change;
|
||||||
bool freq_getset;
|
bool freq_getset;
|
||||||
|
@ -40,7 +40,7 @@ SO_MINOR := 0
|
|||||||
CFLAGS += $(ENV_CFLAGS)
|
CFLAGS += $(ENV_CFLAGS)
|
||||||
|
|
||||||
LIBNAME = event
|
LIBNAME = event
|
||||||
C_SRCS = app.c reactor.c json_config.c log_rpc.c \
|
C_SRCS = app.c reactor.c log_rpc.c \
|
||||||
app_rpc.c scheduler_static.c
|
app_rpc.c scheduler_static.c
|
||||||
|
|
||||||
# Do not compile schedulers and governors based on DPDK env
|
# Do not compile schedulers and governors based on DPDK env
|
||||||
|
@ -403,7 +403,8 @@ bootstrap_fn(void *arg1)
|
|||||||
|
|
||||||
if (g_spdk_app.json_config_file) {
|
if (g_spdk_app.json_config_file) {
|
||||||
g_delay_subsystem_init = false;
|
g_delay_subsystem_init = false;
|
||||||
spdk_app_json_config_load(g_spdk_app.json_config_file, g_spdk_app.rpc_addr, app_start_rpc,
|
spdk_subsystem_init_from_json_config(g_spdk_app.json_config_file, g_spdk_app.rpc_addr,
|
||||||
|
app_start_rpc,
|
||||||
NULL, !g_spdk_app.json_config_ignore_errors);
|
NULL, !g_spdk_app.json_config_ignore_errors);
|
||||||
} else {
|
} else {
|
||||||
if (!g_delay_subsystem_init) {
|
if (!g_delay_subsystem_init) {
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
spdk_reactor_get;
|
spdk_reactor_get;
|
||||||
spdk_for_each_reactor;
|
spdk_for_each_reactor;
|
||||||
spdk_reactor_set_interrupt_mode;
|
spdk_reactor_set_interrupt_mode;
|
||||||
spdk_app_json_config_load;
|
|
||||||
|
|
||||||
local: *;
|
local: *;
|
||||||
};
|
};
|
||||||
|
@ -37,7 +37,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
|
|||||||
SO_VER := 1
|
SO_VER := 1
|
||||||
SO_MINOR := 0
|
SO_MINOR := 0
|
||||||
|
|
||||||
C_SRCS = subsystem.c subsystem_rpc.c rpc.c
|
C_SRCS = json_config.c subsystem.c subsystem_rpc.c rpc.c
|
||||||
LIBNAME = init
|
LIBNAME = init
|
||||||
|
|
||||||
SPDK_MAP_FILE = $(abspath $(CURDIR)/spdk_init.map)
|
SPDK_MAP_FILE = $(abspath $(CURDIR)/spdk_init.map)
|
||||||
|
@ -86,7 +86,7 @@ typedef void (*client_resp_handler)(struct load_json_config_ctx *,
|
|||||||
struct load_json_config_ctx {
|
struct load_json_config_ctx {
|
||||||
/* Thread used during configuration. */
|
/* Thread used during configuration. */
|
||||||
struct spdk_thread *thread;
|
struct spdk_thread *thread;
|
||||||
spdk_app_init_fn cb_fn;
|
spdk_subsystem_init_fn cb_fn;
|
||||||
void *cb_arg;
|
void *cb_arg;
|
||||||
bool stop_on_error;
|
bool stop_on_error;
|
||||||
|
|
||||||
@ -567,8 +567,8 @@ err:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
spdk_app_json_config_load(const char *json_config_file, const char *rpc_addr,
|
spdk_subsystem_init_from_json_config(const char *json_config_file, const char *rpc_addr,
|
||||||
spdk_app_init_fn cb_fn, void *cb_arg,
|
spdk_subsystem_init_fn cb_fn, void *cb_arg,
|
||||||
bool stop_on_error)
|
bool stop_on_error)
|
||||||
{
|
{
|
||||||
struct load_json_config_ctx *ctx = calloc(1, sizeof(*ctx));
|
struct load_json_config_ctx *ctx = calloc(1, sizeof(*ctx));
|
@ -8,6 +8,7 @@
|
|||||||
spdk_subsystem_fini;
|
spdk_subsystem_fini;
|
||||||
spdk_subsystem_init_next;
|
spdk_subsystem_init_next;
|
||||||
spdk_subsystem_fini_next;
|
spdk_subsystem_fini_next;
|
||||||
|
spdk_subsystem_init_from_json_config;
|
||||||
|
|
||||||
spdk_rpc_initialize;
|
spdk_rpc_initialize;
|
||||||
spdk_rpc_finish;
|
spdk_rpc_finish;
|
||||||
|
@ -84,7 +84,7 @@ DEPDIRS-trace := log util $(JSON_LIBS)
|
|||||||
DEPDIRS-bdev := log util thread $(JSON_LIBS) notify trace
|
DEPDIRS-bdev := log util thread $(JSON_LIBS) notify trace
|
||||||
DEPDIRS-blobfs := log thread blob trace
|
DEPDIRS-blobfs := log thread blob trace
|
||||||
DEPDIRS-event := log util thread $(JSON_LIBS) trace init
|
DEPDIRS-event := log util thread $(JSON_LIBS) trace init
|
||||||
DEPDIRS-init := jsonrpc json log rpc thread
|
DEPDIRS-init := jsonrpc json log rpc thread util
|
||||||
|
|
||||||
DEPDIRS-ftl := log util thread trace bdev
|
DEPDIRS-ftl := log util thread trace bdev
|
||||||
DEPDIRS-nbd := log util thread $(JSON_LIBS) bdev
|
DEPDIRS-nbd := log util thread $(JSON_LIBS) bdev
|
||||||
|
@ -51,7 +51,8 @@ DEFINE_STUB_V(spdk_rpc_set_state, (uint32_t state));
|
|||||||
DEFINE_STUB(spdk_rpc_get_state, uint32_t, (void), SPDK_RPC_RUNTIME);
|
DEFINE_STUB(spdk_rpc_get_state, uint32_t, (void), SPDK_RPC_RUNTIME);
|
||||||
DEFINE_STUB(spdk_rpc_initialize, int, (const char *listen_addr), 0);
|
DEFINE_STUB(spdk_rpc_initialize, int, (const char *listen_addr), 0);
|
||||||
DEFINE_STUB_V(spdk_rpc_finish, (void));
|
DEFINE_STUB_V(spdk_rpc_finish, (void));
|
||||||
DEFINE_STUB_V(spdk_app_json_config_load, (const char *json_config_file, const char *rpc_addr,
|
DEFINE_STUB_V(spdk_subsystem_init_from_json_config, (const char *json_config_file,
|
||||||
|
const char *rpc_addr,
|
||||||
spdk_subsystem_init_fn cb_fn, void *cb_arg, bool stop_on_error));
|
spdk_subsystem_init_fn cb_fn, void *cb_arg, bool stop_on_error));
|
||||||
DEFINE_STUB_V(spdk_reactors_start, (void));
|
DEFINE_STUB_V(spdk_reactors_start, (void));
|
||||||
DEFINE_STUB_V(spdk_reactors_stop, (void *arg1));
|
DEFINE_STUB_V(spdk_reactors_stop, (void *arg1));
|
||||||
|
Loading…
Reference in New Issue
Block a user