event: spdk_app_json_config_load no longer requires an event
Take a callback and an argument instead. Change-Id: I9edda1a9bd506e12f309e52e520e97c0d705d6a2 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446992 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>
This commit is contained in:
parent
46777dd8b9
commit
d92a1fb4ac
@ -364,6 +364,12 @@ spdk_app_start_rpc(void *arg1, void *arg2)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_spdk_app_start_rpc(void *arg1)
|
||||||
|
{
|
||||||
|
spdk_app_start_rpc(arg1, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static struct spdk_conf *
|
static struct spdk_conf *
|
||||||
spdk_app_setup_conf(const char *config_file)
|
spdk_app_setup_conf(const char *config_file)
|
||||||
{
|
{
|
||||||
@ -562,13 +568,13 @@ bootstrap_fn(void *arg1, void *arg2)
|
|||||||
{
|
{
|
||||||
struct spdk_event *rpc_start_event;
|
struct spdk_event *rpc_start_event;
|
||||||
|
|
||||||
rpc_start_event = spdk_event_allocate(g_init_lcore, spdk_app_start_rpc,
|
|
||||||
NULL, NULL);
|
|
||||||
|
|
||||||
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, rpc_start_event);
|
spdk_app_json_config_load(g_spdk_app.json_config_file, g_spdk_app.rpc_addr, _spdk_app_start_rpc,
|
||||||
|
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(rpc_start_event);
|
||||||
} else {
|
} else {
|
||||||
|
@ -37,7 +37,6 @@
|
|||||||
|
|
||||||
#include "spdk/util.h"
|
#include "spdk/util.h"
|
||||||
#include "spdk/log.h"
|
#include "spdk/log.h"
|
||||||
#include "spdk/event.h"
|
|
||||||
#include "spdk/env.h"
|
#include "spdk/env.h"
|
||||||
#include "spdk/thread.h"
|
#include "spdk/thread.h"
|
||||||
#include "spdk/jsonrpc.h"
|
#include "spdk/jsonrpc.h"
|
||||||
@ -88,7 +87,8 @@ 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;
|
||||||
struct spdk_event *done_event;
|
spdk_msg_fn cb_fn;
|
||||||
|
void *cb_arg;
|
||||||
|
|
||||||
/* Current subsystem */
|
/* Current subsystem */
|
||||||
struct spdk_json_val *subsystems; /* "subsystems" array */
|
struct spdk_json_val *subsystems; /* "subsystems" array */
|
||||||
@ -134,7 +134,7 @@ spdk_app_json_config_load_done(struct load_json_config_ctx *ctx, int rc)
|
|||||||
SPDK_ERRLOG("Config load failed. Stopping SPDK application.\n");
|
SPDK_ERRLOG("Config load failed. Stopping SPDK application.\n");
|
||||||
spdk_app_stop(rc);
|
spdk_app_stop(rc);
|
||||||
} else {
|
} else {
|
||||||
spdk_event_call(ctx->done_event);
|
ctx->cb_fn(ctx->cb_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
SPDK_DEBUG_APP_CFG("Config load finished\n");
|
SPDK_DEBUG_APP_CFG("Config load finished\n");
|
||||||
@ -426,7 +426,7 @@ static struct spdk_json_object_decoder subsystem_decoders[] = {
|
|||||||
*
|
*
|
||||||
* In second iteration "subsystems" array is walked through again, this time only
|
* In second iteration "subsystems" array is walked through again, this time only
|
||||||
* RUNTIME RPC methods are used. When ctx->subsystems_it became NULL second time it
|
* RUNTIME RPC methods are used. When ctx->subsystems_it became NULL second time it
|
||||||
* indicate that there is no more subsystems to load. The done_event is called to finish
|
* indicate that there is no more subsystems to load. The cb_fn is called to finish
|
||||||
* configuration.
|
* configuration.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
@ -563,18 +563,19 @@ err:
|
|||||||
|
|
||||||
void
|
void
|
||||||
spdk_app_json_config_load(const char *json_config_file, const char *rpc_addr,
|
spdk_app_json_config_load(const char *json_config_file, const char *rpc_addr,
|
||||||
struct spdk_event *done_event)
|
spdk_msg_fn cb_fn, void *cb_arg)
|
||||||
{
|
{
|
||||||
struct load_json_config_ctx *ctx = calloc(1, sizeof(*ctx));
|
struct load_json_config_ctx *ctx = calloc(1, sizeof(*ctx));
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
assert(done_event);
|
assert(cb_fn);
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
spdk_app_stop(-ENOMEM);
|
spdk_app_stop(-ENOMEM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->done_event = done_event;
|
ctx->cb_fn = cb_fn;
|
||||||
|
ctx->cb_arg = cb_arg;
|
||||||
ctx->thread = spdk_get_thread();
|
ctx->thread = spdk_get_thread();
|
||||||
|
|
||||||
rc = spdk_app_json_config_read(json_config_file, ctx);
|
rc = spdk_app_json_config_read(json_config_file, ctx);
|
||||||
|
@ -34,9 +34,9 @@
|
|||||||
#ifndef SPDK_JSON_CONFIG_H
|
#ifndef SPDK_JSON_CONFIG_H
|
||||||
#define SPDK_JSON_CONFIG_H
|
#define SPDK_JSON_CONFIG_H
|
||||||
|
|
||||||
#include "spdk/event.h"
|
#include "spdk/thread.h"
|
||||||
|
|
||||||
void spdk_app_json_config_load(const char *json_config_file, const char *rpc_addr,
|
void spdk_app_json_config_load(const char *json_config_file, const char *rpc_addr,
|
||||||
struct spdk_event *done_event);
|
spdk_msg_fn cb_fn, void *cb_arg);
|
||||||
|
|
||||||
#endif /* SPDK_JSON_CONFIG_H */
|
#endif /* SPDK_JSON_CONFIG_H */
|
||||||
|
@ -49,7 +49,7 @@ DEFINE_STUB_V(spdk_rpc_register_method, (const char *method, spdk_rpc_method_han
|
|||||||
DEFINE_STUB_V(spdk_rpc_set_state, (uint32_t state));
|
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_V(spdk_app_json_config_load, (const char *json_config_file, const char *rpc_addr,
|
DEFINE_STUB_V(spdk_app_json_config_load, (const char *json_config_file, const char *rpc_addr,
|
||||||
struct spdk_event *done_event));
|
spdk_msg_fn cb_fn, void *cb_arg));
|
||||||
|
|
||||||
static void
|
static void
|
||||||
unittest_usage(void)
|
unittest_usage(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user