Commit 90779f58 authored by Ben Walker's avatar Ben Walker Committed by Jim Harris
Browse files

bdev: Move event subsystem initialization to event_bdev



This breaks the dependency on the event subsystem logic.

Change-Id: Ic47a219bc1e272c3421b265f74bba959e1aa5f62
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/365730


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent aacd61d5
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@

#include "spdk/stdinc.h"

#include "spdk/event.h"
#include "spdk/scsi_spec.h"
#include "spdk/nvme_spec.h"

@@ -107,7 +106,9 @@ struct spdk_bdev_io_stat {
	uint64_t num_write_ops;
};

void spdk_bdev_initialize(void);
typedef void (*spdk_bdev_init_cb)(void *cb_arg, int rc);

void spdk_bdev_initialize(spdk_bdev_init_cb cb_fn, void *cb_arg);
int spdk_bdev_finish(void);
void spdk_bdev_config_text(FILE *fp);

+23 −5
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@
#include "spdk/scsi_spec.h"

#include "spdk_internal/bdev.h"
#include "spdk_internal/event.h"
#include "spdk_internal/log.h"
#include "spdk/string.h"

@@ -82,6 +81,8 @@ static struct spdk_bdev_mgr g_bdev_mgr = {

static struct spdk_bdev_module_if *g_next_bdev_module;
static struct spdk_bdev_module_if *g_next_vbdev_module;
static spdk_bdev_init_cb	g_cb_fn = NULL;
static void			*g_cb_arg = NULL;

struct spdk_bdev_mgmt_channel {
	need_buf_tailq_t need_buf_small;
@@ -298,13 +299,25 @@ spdk_bdev_mgmt_channel_destroy(void *io_device, void *ctx_buf)
	}
}

static void
spdk_bdev_init_complete(int rc)
{
	spdk_bdev_init_cb cb_fn = g_cb_fn;
	void *cb_arg = g_cb_arg;

	g_cb_fn = NULL;
	g_cb_arg = NULL;

	cb_fn(cb_arg, rc);
}

void
spdk_bdev_module_init_next(int rc)
{
	if (rc) {
		assert(g_next_bdev_module != NULL);
		SPDK_ERRLOG("Failed to init bdev module: %s\n", g_next_bdev_module->module_name);
		spdk_subsystem_init_next(rc);
		spdk_bdev_init_complete(rc);
		return;
	}

@@ -327,7 +340,7 @@ spdk_vbdev_module_init_next(int rc)
	if (rc) {
		assert(g_next_vbdev_module != NULL);
		SPDK_ERRLOG("Failed to init vbdev module: %s\n", g_next_vbdev_module->module_name);
		spdk_subsystem_init_next(rc);
		spdk_bdev_init_complete(rc);
		return;
	}

@@ -340,16 +353,21 @@ spdk_vbdev_module_init_next(int rc)
	if (g_next_vbdev_module) {
		g_next_vbdev_module->module_init();
	} else {
		spdk_subsystem_init_next(0);
		spdk_bdev_init_complete(rc);;
	}
}

void
spdk_bdev_initialize(void)
spdk_bdev_initialize(spdk_bdev_init_cb cb_fn, void *cb_arg)
{
	int cache_size;
	int rc = 0;

	assert(cb_fn != NULL);

	g_cb_fn = cb_fn;
	g_cb_arg = cb_arg;

	g_bdev_mgr.bdev_io_pool = spdk_mempool_create("blockdev_io",
				  SPDK_BDEV_IO_POOL_SIZE,
				  sizeof(struct spdk_bdev_io) +
+20 −1
Original line number Diff line number Diff line
@@ -37,5 +37,24 @@

#include "spdk_internal/event.h"

SPDK_SUBSYSTEM_REGISTER(bdev, spdk_bdev_initialize, spdk_bdev_finish, spdk_bdev_config_text)
static void
spdk_bdev_initialize_complete(void *cb_arg, int rc)
{
	spdk_subsystem_init_next(rc);
}

static void
spdk_bdev_subsystem_initialize(void)
{
	spdk_bdev_initialize(spdk_bdev_initialize_complete, NULL);
}

static int
spdk_bdev_subsystem_finish(void)
{
	return spdk_bdev_finish();
}

SPDK_SUBSYSTEM_REGISTER(bdev, spdk_bdev_subsystem_initialize,
			spdk_bdev_subsystem_finish, spdk_bdev_config_text)
SPDK_SUBSYSTEM_DEPEND(bdev, copy)