Commit 153fbcb1 authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

bdev/ocssd: JSON configuration



This patch adds support for saving JSON configuration of the OCSSD
bdev module required to recreate the current state.

Change-Id: Iedbdb8b4a2b7dd02a223ce6f073553e71b9c040a
Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/469090


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
parent ba4b326c
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -166,13 +166,11 @@ static depopulate_namespace_fn g_depopulate_namespace_fn[] = {
typedef void (*config_json_namespace_fn)(struct spdk_json_write_ctx *w, struct nvme_bdev_ns *ns);
static void nvme_ctrlr_config_json_standard_namespace(struct spdk_json_write_ctx *w,
		struct nvme_bdev_ns *ns);
static void nvme_ctrlr_config_json_ocssd_namespace(struct spdk_json_write_ctx *w,
		struct nvme_bdev_ns *ns);

static config_json_namespace_fn g_config_json_namespace_fn[] = {
	NULL,
	nvme_ctrlr_config_json_standard_namespace,
	nvme_ctrlr_config_json_ocssd_namespace,
	bdev_ocssd_namespace_config_json,
};

struct spdk_nvme_qpair *
@@ -2279,12 +2277,6 @@ nvme_ctrlr_config_json_standard_namespace(struct spdk_json_write_ctx *w, struct
	/* nop */
}

static void
nvme_ctrlr_config_json_ocssd_namespace(struct spdk_json_write_ctx *w, struct nvme_bdev_ns *ns)
{
	/* nop */
}

static void
nvme_namespace_config_json(struct spdk_json_write_ctx *w, struct nvme_bdev_ns *ns)
{
+22 −0
Original line number Diff line number Diff line
@@ -112,6 +112,28 @@ bdev_ocssd_config_json(struct spdk_json_write_ctx *w)
	return 0;
}

void
bdev_ocssd_namespace_config_json(struct spdk_json_write_ctx *w, struct nvme_bdev_ns *ns)
{
	struct nvme_bdev_ctrlr *nvme_bdev_ctrlr;
	struct nvme_bdev *nvme_bdev;

	TAILQ_FOREACH(nvme_bdev, &ns->bdevs, tailq) {
		nvme_bdev_ctrlr = nvme_bdev->nvme_bdev_ctrlr;

		spdk_json_write_object_begin(w);
		spdk_json_write_named_string(w, "method", "bdev_ocssd_create");

		spdk_json_write_named_object_begin(w, "params");
		spdk_json_write_named_string(w, "ctrlr_name", nvme_bdev_ctrlr->name);
		spdk_json_write_named_string(w, "bdev_name", nvme_bdev->disk.name);
		spdk_json_write_named_uint32(w, "nsid", nvme_bdev->nvme_ns->id);
		spdk_json_write_object_end(w);

		spdk_json_write_object_end(w);
	}
}

static int
bdev_ocssd_get_ctx_size(void)
{
+1 −0
Original line number Diff line number Diff line
@@ -48,5 +48,6 @@ void bdev_ocssd_populate_namespace(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr,
				   struct nvme_bdev_ns *nvme_ns,
				   struct nvme_async_probe_ctx *ctx);
void bdev_ocssd_depopulate_namespace(struct nvme_bdev_ns *ns);
void bdev_ocssd_namespace_config_json(struct spdk_json_write_ctx *w, struct nvme_bdev_ns *ns);

#endif /* SPDK_BDEV_OCSSD_H */
+1 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@
#include "bdev/nvme/bdev_ocssd.c"
#include "bdev/nvme/common.c"
#include "common/lib/test_env.c"
#include "unit/lib/json_mock.c"

DEFINE_STUB_V(spdk_bdev_module_list_add, (struct spdk_bdev_module *bdev_module));
DEFINE_STUB(spdk_nvme_ctrlr_is_ocssd_ns, bool, (struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid),