bdev/nvme: nvme_bdev remembers if opal is enabled or not

This is helpful to simplify bdev_nvme_dump_info_json() when supporting
multipath.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I7cf7712b8ee8ac6f15354a46dee2edbacbdeafcf
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5794
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Shuhei Matsumoto 2021-01-06 07:47:47 +09:00 committed by Tomasz Zawadzki
parent 885dd11225
commit e995690fbc
2 changed files with 3 additions and 1 deletions

View File

@ -1073,7 +1073,7 @@ bdev_nvme_dump_info_json(void *ctx, struct spdk_json_write_ctx *w)
if (cdata->oacs.security) { if (cdata->oacs.security) {
spdk_json_write_named_object_begin(w, "security"); spdk_json_write_named_object_begin(w, "security");
spdk_json_write_named_bool(w, "opal", nvme_bdev_ctrlr->opal_dev ? true : false); spdk_json_write_named_bool(w, "opal", nvme_bdev->opal);
spdk_json_write_object_end(w); spdk_json_write_object_end(w);
} }
@ -1202,6 +1202,7 @@ nvme_bdev_create(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr, struct nvme_bdev_ns *n
} }
bdev->nvme_ns = nvme_ns; bdev->nvme_ns = nvme_ns;
bdev->opal = nvme_bdev_ctrlr->opal_dev != NULL;
rc = nvme_disk_create(&bdev->disk, nvme_bdev_ctrlr->name, nvme_bdev_ctrlr->ctrlr, rc = nvme_disk_create(&bdev->disk, nvme_bdev_ctrlr->name, nvme_bdev_ctrlr->ctrlr,
nvme_ns->ns, nvme_bdev_ctrlr->prchk_flags, bdev); nvme_ns->ns, nvme_bdev_ctrlr->prchk_flags, bdev);

View File

@ -116,6 +116,7 @@ struct nvme_bdev_ctrlr {
struct nvme_bdev { struct nvme_bdev {
struct spdk_bdev disk; struct spdk_bdev disk;
struct nvme_bdev_ns *nvme_ns; struct nvme_bdev_ns *nvme_ns;
bool opal;
TAILQ_ENTRY(nvme_bdev) tailq; TAILQ_ENTRY(nvme_bdev) tailq;
}; };