From 69bcb185f3dfcfb3fa71e35abccd064c6a7e934c Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Thu, 18 Aug 2022 16:55:35 +0200 Subject: [PATCH] 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 Change-Id: I1a88ad2bb761f589d214fec8f0690c38572824d6 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14116 Reviewed-by: Michal Berger Reviewed-by: Jim Harris Reviewed-by: Aleksey Marchuk Reviewed-by: Krzysztof Karas Tested-by: SPDK CI Jenkins --- module/bdev/xnvme/bdev_xnvme.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/module/bdev/xnvme/bdev_xnvme.c b/module/bdev/xnvme/bdev_xnvme.c index c219d9a60..f71df0ede 100644 --- a/module/bdev/xnvme/bdev_xnvme.c +++ b/module/bdev/xnvme/bdev_xnvme.c @@ -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) {