Commit 814ccae7 authored by luchangqi.123's avatar luchangqi.123 Committed by Tomasz Zawadzki
Browse files

bdev/nvme: add json config saving for nvme_cuse



When we call the rpc command save_config, the current spdk environment will be saved,
but the environment created by bdev_nvme_cuse_register is currently missing.

In the production environment, SPDK usually auto-restarts with saved config file(by rpc.py save_config command) by systemd or docker.
The missing NVMe cuse config leads to the lack of the  additional spdk/cuse device once SPDK restarts.

Change-Id: I0d4c9f279f99539426343af80e76bf42b400ef94
Signed-off-by: default avatarluchangqi.123 <luchangqi.123@bytedance.com>
Signed-off-by: default avatarzhenwei pi <pizhenwei@bytedance.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/20039


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Community-CI: Mellanox Build Bot
parent dbe47004
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -7908,6 +7908,31 @@ bdev_nvme_discovery_config_json(struct spdk_json_write_ctx *w, struct discovery_
	spdk_json_write_object_end(w);
}

#ifdef SPDK_CONFIG_NVME_CUSE
static void
nvme_ctrlr_cuse_config_json(struct spdk_json_write_ctx *w,
			    struct nvme_ctrlr *nvme_ctrlr)
{
	size_t cuse_name_size = 128;
	char cuse_name[cuse_name_size];

	if (spdk_nvme_cuse_get_ctrlr_name(nvme_ctrlr->ctrlr,
					  cuse_name, &cuse_name_size) != 0) {
		return;
	}

	spdk_json_write_object_begin(w);

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

	spdk_json_write_named_object_begin(w, "params");
	spdk_json_write_named_string(w, "name", nvme_ctrlr->nbdev_ctrlr->name);
	spdk_json_write_object_end(w);

	spdk_json_write_object_end(w);
}
#endif

static void
nvme_ctrlr_config_json(struct spdk_json_write_ctx *w,
		       struct nvme_ctrlr *nvme_ctrlr)
@@ -7982,6 +8007,10 @@ bdev_nvme_config_json(struct spdk_json_write_ctx *w)
	TAILQ_FOREACH(nbdev_ctrlr, &g_nvme_bdev_ctrlrs, tailq) {
		TAILQ_FOREACH(nvme_ctrlr, &nbdev_ctrlr->ctrlrs, tailq) {
			nvme_ctrlr_config_json(w, nvme_ctrlr);

#ifdef SPDK_CONFIG_NVME_CUSE
			nvme_ctrlr_cuse_config_json(w, nvme_ctrlr);
#endif
		}
	}