Commit 69bcb185 authored by Tomasz Zawadzki's avatar Tomasz Zawadzki
Browse files

bdev/xnvme: save xnvme bdevs from runtime



config_json callback is used to preserve all
bdevs that were created during application runtime.

xnvme bdev module was missing this callback.

While here, io_mechanism is now saved in the bdev_xnvme
structure for reference in the config_json.
Haven't seen an option to pull this from xnvme itself.

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


Reviewed-by: default avatarMichal Berger <michal.berger@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 69b4e8b1
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ struct bdev_xnvme_task {
struct bdev_xnvme {
	struct spdk_bdev	bdev;
	char			*filename;
	char			*io_mechanism;
	struct xnvme_dev	*dev;
	uint32_t		nsid;

@@ -52,11 +53,34 @@ bdev_xnvme_get_ctx_size(void)
	return sizeof(struct bdev_xnvme_task);
}

static int
bdev_xnvme_config_json(struct spdk_json_write_ctx *w)
{
	struct bdev_xnvme *xnvme;

	TAILQ_FOREACH(xnvme, &g_xnvme_bdev_head, link) {
		spdk_json_write_object_begin(w);

		spdk_json_write_named_string(w, "method", "bdev_xnvme_create");

		spdk_json_write_named_object_begin(w, "params");
		spdk_json_write_named_string(w, "name", xnvme->bdev.name);
		spdk_json_write_named_string(w, "filename", xnvme->filename);
		spdk_json_write_named_string(w, "io_mechanism", xnvme->io_mechanism);
		spdk_json_write_object_end(w);

		spdk_json_write_object_end(w);
	}

	return 0;
}

static struct spdk_bdev_module xnvme_if = {
	.name		= "xnvme",
	.module_init	= bdev_xnvme_init,
	.module_fini	= bdev_xnvme_fini,
	.get_ctx_size	= bdev_xnvme_get_ctx_size,
	.config_json	= bdev_xnvme_config_json,
};

SPDK_BDEV_MODULE_REGISTER(xnvme, &xnvme_if)
@@ -199,6 +223,7 @@ bdev_xnvme_free(struct bdev_xnvme *xnvme)
	assert(xnvme != NULL);

	xnvme_dev_close(xnvme->dev);
	free(xnvme->io_mechanism);
	free(xnvme->filename);
	free(xnvme->bdev.name);
	free(xnvme);
@@ -290,6 +315,10 @@ create_xnvme_bdev(const char *name, const char *filename, const char *io_mechani
	if (!opts.async) {
		goto error_return;
	}
	xnvme->io_mechanism = strdup(io_mechanism);
	if (!xnvme->io_mechanism) {
		goto error_return;
	}

	xnvme->filename = strdup(filename);
	if (!xnvme->filename) {