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: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I1a88ad2bb761f589d214fec8f0690c38572824d6
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14116
Reviewed-by: Michal Berger <michal.berger@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: Krzysztof Karas <krzysztof.karas@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Tomasz Zawadzki 2022-08-18 16:55:35 +02:00
parent 69b4e8b17f
commit 69bcb185f3

View File

@ -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) {