nvme: Add opal init process for nvme bdev
get_bdevs can see whether opal is supported. Change-Id: I5339a23590fcb23438e0e513d209763cee6fdeb1 Signed-off-by: Chunyang Hui <chunyang.hui@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/462590 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
f74b33ad0b
commit
984a11ad65
@ -226,6 +226,9 @@ static void
|
||||
bdev_nvme_ctrlr_destruct(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr)
|
||||
{
|
||||
assert(nvme_bdev_ctrlr->destruct);
|
||||
if (nvme_bdev_ctrlr->opal_dev) {
|
||||
spdk_opal_close(nvme_bdev_ctrlr->opal_dev);
|
||||
}
|
||||
pthread_mutex_lock(&g_bdev_nvme_mutex);
|
||||
TAILQ_REMOVE(&g_nvme_bdev_ctrlrs, nvme_bdev_ctrlr, tailq);
|
||||
pthread_mutex_unlock(&g_bdev_nvme_mutex);
|
||||
@ -651,6 +654,14 @@ bdev_nvme_dump_info_json(void *ctx, struct spdk_json_write_ctx *w)
|
||||
|
||||
spdk_json_write_object_end(w);
|
||||
|
||||
if (cdata->oacs.security) {
|
||||
spdk_json_write_named_object_begin(w, "security");
|
||||
|
||||
spdk_json_write_named_bool(w, "opal", spdk_opal_supported(nvme_bdev_ctrlr->opal_dev));
|
||||
|
||||
spdk_json_write_object_end(w);
|
||||
}
|
||||
|
||||
spdk_json_write_object_end(w);
|
||||
|
||||
return 0;
|
||||
@ -996,6 +1007,11 @@ create_ctrlr(struct spdk_nvme_ctrlr *ctrlr,
|
||||
|
||||
spdk_nvme_ctrlr_register_aer_callback(ctrlr, aer_cb, nvme_bdev_ctrlr);
|
||||
|
||||
if (spdk_nvme_ctrlr_get_flags(nvme_bdev_ctrlr->ctrlr) &
|
||||
SPDK_NVME_CTRLR_SECURITY_SEND_RECV_SUPPORTED) {
|
||||
nvme_bdev_ctrlr->opal_dev = spdk_opal_init_dev(nvme_bdev_ctrlr->ctrlr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
|
||||
#include "spdk/nvme.h"
|
||||
#include "spdk/bdev_module.h"
|
||||
#include "spdk/opal.h"
|
||||
|
||||
TAILQ_HEAD(nvme_bdev_ctrlrs, nvme_bdev_ctrlr);
|
||||
extern struct nvme_bdev_ctrlrs g_nvme_bdev_ctrlrs;
|
||||
@ -64,6 +65,8 @@ struct nvme_bdev_ctrlr {
|
||||
/** Array of bdevs indexed by nsid - 1 */
|
||||
struct nvme_bdev *bdevs;
|
||||
|
||||
struct spdk_opal_dev *opal_dev;
|
||||
|
||||
struct spdk_poller *adminq_timer_poller;
|
||||
|
||||
/** linked list pointer for device list */
|
||||
|
Loading…
Reference in New Issue
Block a user