Commit 6e0d1dcd authored by Ziye Yang's avatar Ziye Yang Committed by Jim Harris
Browse files

subsystem: make subsystem init in async manner



The next patch will make bdev modules init
in the async manner.

Change-Id: I4909c80510d786daf54003b99a5925428cf37373
Signed-off-by: default avatarZiye Yang <optimistyzy@gmail.com>
Reviewed-on: https://review.gerrithub.io/362110


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 8a44220b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@
#define IDLE_INTERVAL_TIME_IN_US 5000

const char *spdk_net_framework_get_name(void);
int spdk_net_framework_start(void);
void spdk_net_framework_start(void);
void spdk_net_framework_clear_socket_association(int sock);
int spdk_net_framework_fini(void);
int spdk_net_framework_idle_time(void);
+4 −2
Original line number Diff line number Diff line
@@ -55,7 +55,8 @@ uint32_t spdk_event_queue_run_batch(uint32_t lcore);

struct spdk_subsystem {
	const char *name;
	int (*init)(void);
	/* User must call spdk_subsystem_init_next() when they are done with their initialization. */
	void (*init)(void);
	int (*fini)(void);
	void (*config)(FILE *fp);
	TAILQ_ENTRY(spdk_subsystem) tailq;
@@ -71,8 +72,9 @@ struct spdk_subsystem_depend {
void spdk_add_subsystem(struct spdk_subsystem *subsystem);
void spdk_add_subsystem_depend(struct spdk_subsystem_depend *depend);

int spdk_subsystem_init(void);
void spdk_subsystem_init(void);
int spdk_subsystem_fini(void);
void spdk_subsystem_init_next(int rc);
void spdk_subsystem_config(FILE *fp);

/**
+13 −7
Original line number Diff line number Diff line
@@ -258,7 +258,7 @@ spdk_bdev_mgmt_channel_destroy(void *io_device, void *ctx_buf)
{
}

static int
static void
spdk_bdev_initialize(void)
{
	int i, cache_size;
@@ -274,7 +274,8 @@ spdk_bdev_initialize(void)

	if (g_bdev_mgr.bdev_io_pool == NULL) {
		SPDK_ERRLOG("could not allocate spdk_bdev_io pool");
		return -1;
		rc = -1;
		goto end;
	}

	for (i = 0; i < RTE_MAX_LCORE; i++) {
@@ -295,7 +296,8 @@ spdk_bdev_initialize(void)
				    SPDK_ENV_SOCKET_ID_ANY);
	if (!g_bdev_mgr.buf_small_pool) {
		SPDK_ERRLOG("create rbuf small pool failed\n");
		return -1;
		rc = -1;
		goto end;
	}

	cache_size = BUF_LARGE_POOL_SIZE / (2 * spdk_env_get_core_count());
@@ -306,19 +308,22 @@ spdk_bdev_initialize(void)
				    SPDK_ENV_SOCKET_ID_ANY);
	if (!g_bdev_mgr.buf_large_pool) {
		SPDK_ERRLOG("create rbuf large pool failed\n");
		return -1;
		rc = -1;
		goto end;
	}

	TAILQ_FOREACH(bdev_module, &g_bdev_mgr.bdev_modules, tailq) {
		rc = bdev_module->module_init();
		if (rc) {
			return rc;
			rc = -1;
			goto end;
		}
	}
	TAILQ_FOREACH(bdev_module, &g_bdev_mgr.vbdev_modules, tailq) {
		rc = bdev_module->module_init();
		if (rc) {
			return rc;
			rc = -1;
			goto end;
		}
	}

@@ -326,7 +331,8 @@ spdk_bdev_initialize(void)
				spdk_bdev_mgmt_channel_destroy,
				sizeof(struct spdk_bdev_mgmt_channel));

	return 0;
end:
	spdk_subsystem_init_next(rc);
}

static int
+3 −2
Original line number Diff line number Diff line
@@ -237,7 +237,7 @@ spdk_copy_engine_module_finish(void)
	}
}

static int
static void
spdk_copy_engine_initialize(void)
{
	spdk_copy_engine_module_initialize();
@@ -247,7 +247,8 @@ spdk_copy_engine_initialize(void)
	 */
	spdk_io_device_register(&spdk_copy_module_list, copy_create_cb, copy_destroy_cb,
				sizeof(struct copy_io_channel));
	return 0;

	spdk_subsystem_init_next(0);
}

static int
+7 −7
Original line number Diff line number Diff line
@@ -410,13 +410,6 @@ spdk_app_init(struct spdk_app_opts *opts)
			spdk_trace_set_tpoint_group_mask(tpoint_group_mask);
		}
	}

	rc = spdk_subsystem_init();
	if (rc < 0) {
		SPDK_ERRLOG("spdk_subsystem_init() failed\n");
		spdk_conf_free(g_spdk_app.config);
		exit(EXIT_FAILURE);
	}
}

int
@@ -440,6 +433,13 @@ spdk_app_start(spdk_event_fn start_fn, void *arg1, void *arg2)

	g_spdk_app.rc = 0;

	spdk_subsystem_init();

	/* Early return if there is error */
	if (g_spdk_app.rc) {
		return g_spdk_app.rc;
	}

	event = spdk_event_allocate(rte_get_master_lcore(), start_fn,
				    arg1, arg2);
	/* Queues up the event, but can't run it until the reactors start */
Loading