Commit f155c980 authored by Ben Walker's avatar Ben Walker Committed by Changpeng Liu
Browse files

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: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446993


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent c1672b60
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@

#include "spdk/event.h"
#include "spdk/json.h"
#include "spdk/thread.h"

struct spdk_event {
	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_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_init_next(int rc);
void spdk_subsystem_fini_next(void);
+6 −9
Original line number Diff line number Diff line
@@ -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,
					  NULL);
	} else {
		rpc_start_event = spdk_event_allocate(g_init_lcore, spdk_app_start_rpc, NULL, NULL);

		if (!g_delay_subsystem_init) {
			spdk_subsystem_init(rpc_start_event);
			spdk_subsystem_init(_spdk_app_start_rpc, NULL);
		} else {
			rpc_start_event = spdk_event_allocate(g_init_lcore, spdk_app_start_rpc, NULL, NULL);
			spdk_event_call(rpc_start_event);
		}
	}
@@ -1059,11 +1058,13 @@ spdk_app_usage(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_json_write_ctx *w;

	assert(spdk_env_get_current_core() == g_init_lcore);

	spdk_app_start_application();

	w = spdk_jsonrpc_begin_result(request);
@@ -1079,17 +1080,13 @@ static void
spdk_rpc_start_subsystem_init(struct spdk_jsonrpc_request *request,
			      const struct spdk_json_val *params)
{
	struct spdk_event *cb_event;

	if (params != NULL) {
		spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
						 "start_subsystem_init requires no parameters");
		return;
	}

	cb_event = spdk_event_allocate(g_init_lcore, spdk_rpc_start_subsystem_init_cpl,
				       request, NULL);
	spdk_subsystem_init(cb_event);
	spdk_subsystem_init(spdk_rpc_start_subsystem_init_cpl, request);
}
SPDK_RPC_REGISTER("start_subsystem_init", spdk_rpc_start_subsystem_init, SPDK_RPC_STARTUP)

+7 −4
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#include "spdk/stdinc.h"

#include "spdk/log.h"
#include "spdk/thread.h"

#include "spdk_internal/event.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 bool g_subsystems_initialized = 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 uint32_t g_fini_core;

@@ -136,7 +138,7 @@ spdk_subsystem_init_next(int rc)

	if (!g_next_subsystem) {
		g_subsystems_initialized = true;
		spdk_event_call(g_app_start_event);
		g_app_start_fn(g_app_start_arg);
		return;
	}

@@ -173,11 +175,12 @@ spdk_subsystem_verify(void *arg1, void *arg2)
}

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;

	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);
	spdk_event_call(verify_event);
+1 −1
Original line number Diff line number Diff line
@@ -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,
		void *arg2), NULL);
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,
		uint32_t state_mask));
DEFINE_STUB_V(spdk_rpc_set_state, (uint32_t state));
+5 −9
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ spdk_env_get_current_core(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;
	int i;
	char subsystem_name[16];
	struct spdk_event *app_start_event;

	global_rc = -1;
	app_start_event = spdk_event_allocate(0, ut_event_fn, NULL, NULL);
	spdk_subsystem_init(app_start_event);
	spdk_subsystem_init(ut_event_fn, NULL);

	i = 4;
	TAILQ_FOREACH(subsystem, &g_subsystems, tailq) {
@@ -141,7 +139,6 @@ subsystem_sort_test_depends_on_multiple(void)
{
	int i;
	struct spdk_subsystem *subsystem;
	struct spdk_event *app_start_event;

	subsystem_clear();
	set_up_subsystem(&g_ut_subsystems[0], "iscsi");
@@ -171,8 +168,7 @@ subsystem_sort_test_depends_on_multiple(void)
	}

	global_rc = -1;
	app_start_event = spdk_event_allocate(0, ut_event_fn, NULL, NULL);
	spdk_subsystem_init(app_start_event);
	spdk_subsystem_init(ut_event_fn, NULL);

	subsystem = TAILQ_FIRST(&g_subsystems);
	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]);

	global_rc = -1;
	spdk_subsystem_init(NULL);
	spdk_subsystem_init(ut_event_fn, NULL);
	CU_ASSERT(global_rc != 0);

	/*
@@ -262,7 +258,7 @@ subsystem_sort_test_missing_dependency(void)
	spdk_add_subsystem_depend(&g_ut_subsystem_deps[0]);

	global_rc = -1;
	spdk_subsystem_init(NULL);
	spdk_subsystem_init(ut_event_fn, NULL);
	CU_ASSERT(global_rc != 0);

}