Commit 3f5728fe authored by Tomasz Zawadzki's avatar Tomasz Zawadzki
Browse files

example/fio: add option to load json_config



Added new configuration option to bdev fio_plugin
called 'spdk_json_conf'. When provided the SPDK
subsystems are loaded using this JSON configuration.

Only single type of configuration can be provided at
a single time.

While here, added bdev_rpc in Makefile to support all bdev
related RPC that can now be issued via json config.

Change-Id: I5f45fe2d8331034ef4becca43bbaedebd6b20c5a
Signed-off-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/463979


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarBroadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
parent 1a30ba7f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ CFLAGS += -I$(CONFIG_FIO_SOURCE_DIR)
LDFLAGS += -shared -rdynamic -Wl,-z,nodelete

SPDK_LIB_LIST = $(ALL_MODULES_LIST)
SPDK_LIB_LIST += thread util bdev conf copy rpc jsonrpc json log sock trace notify
SPDK_LIB_LIST += thread util bdev bdev_rpc conf copy rpc jsonrpc json log sock trace notify
SPDK_LIB_LIST += event event_bdev event_copy event_vmd

include $(SPDK_ROOT_DIR)/mk/spdk.app.mk
+45 −22
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@
struct spdk_fio_options {
	void *pad;
	char *conf;
	char *json_conf;
	unsigned mem_mb;
	bool mem_single_seg;
};
@@ -89,6 +90,7 @@ struct spdk_fio_thread {
};

static bool g_spdk_env_initialized = false;
static const char *g_json_config_file = NULL;

static int spdk_fio_init(struct thread_data *td);
static void spdk_fio_cleanup(struct thread_data *td);
@@ -200,8 +202,13 @@ spdk_fio_bdev_init_start(void *arg)
{
	bool *done = arg;

	if (g_json_config_file != NULL) {
		spdk_app_json_config_load(g_json_config_file, SPDK_DEFAULT_RPC_ADDR,
					  spdk_fio_bdev_init_done, done);
	} else {
		spdk_subsystem_init(spdk_fio_bdev_init_done, done);
	}
}

static void
spdk_fio_bdev_fini_done(void *cb_arg)
@@ -222,7 +229,7 @@ spdk_init_thread_poll(void *arg)
{
	struct spdk_fio_options		*eo = arg;
	struct spdk_fio_thread		*fio_thread;
	struct spdk_conf		*config;
	struct spdk_conf		*config = NULL;
	struct spdk_env_opts		opts;
	bool				done;
	int				rc;
@@ -235,12 +242,12 @@ spdk_init_thread_poll(void *arg)

	/* Parse the SPDK configuration file */
	eo = arg;
	if (!eo->conf || !strlen(eo->conf)) {
		SPDK_ERRLOG("No configuration file provided\n");

	if (eo->conf && eo->json_conf) {
		SPDK_ERRLOG("Cannot provide two types of configuration files\n");
		rc = EINVAL;
		goto err_exit;
	}

	} else if (eo->conf && strlen(eo->conf)) {
		config = spdk_conf_allocate();
		if (!config) {
			SPDK_ERRLOG("Unable to allocate configuration file\n");
@@ -261,6 +268,13 @@ spdk_init_thread_poll(void *arg)
			goto err_exit;
		}
		spdk_conf_set_as_default(config);
	} else if (eo->json_conf && strlen(eo->json_conf)) {
		g_json_config_file = eo->json_conf;
	} else {
		SPDK_ERRLOG("No configuration file provided\n");
		rc = EINVAL;
		goto err_exit;
	}

	/* Initialize the environment library */
	spdk_env_opts_init(&opts);
@@ -702,6 +716,15 @@ static struct fio_option options[] = {
		.category	= FIO_OPT_C_ENGINE,
		.group		= FIO_OPT_G_INVALID,
	},
	{
		.name           = "spdk_json_conf",
		.lname          = "SPDK JSON configuration file",
		.type           = FIO_OPT_STR_STORE,
		.off1           = offsetof(struct spdk_fio_options, json_conf),
		.help           = "A SPDK JSON configuration file",
		.category       = FIO_OPT_C_ENGINE,
		.group          = FIO_OPT_G_INVALID,
	},
	{
		.name		= "spdk_mem",
		.lname		= "SPDK memory in MB",