From fa796437258aa051d2ac218bced7db70aa36ad73 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Tue, 4 May 2021 18:45:04 +0000 Subject: [PATCH] nvmf: remove struct spdk_bdev definition dependencies 1) use spdk_bdev_get_name() accessor 2) use __SPDK_BDEV_MODULE_ONLY #define The latter allows nvmf to just get the spdk_bdev_module definitions and APIs that it needs for claiming bdevs for purposes of avoiding the same namespace used in different subsystems. This also ensures that future changes to structures like spdk_bdev and spdk_bdev_io will not cause lib/nvmf so version changes. Note: we include bdev_module.h explicitly in the nvmf/subsystem unit tests now, before including subsystem.c, because the unit tests do depend on knowing the internal structure of spdk_bdev. Signed-off-by: Jim Harris Change-Id: I2f499a741d19f4749eadb402641f28137245fd23 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7738 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Anil Veerabhadrappa Reviewed-by: Aleksey Marchuk Reviewed-by: Shuhei Matsumoto Tested-by: SPDK CI Jenkins --- lib/nvmf/subsystem.c | 3 ++- test/unit/lib/nvmf/fc.c/fc_ut.c | 1 + test/unit/lib/nvmf/subsystem.c/subsystem_ut.c | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/nvmf/subsystem.c b/lib/nvmf/subsystem.c index 457fa64d6..be9c12342 100644 --- a/lib/nvmf/subsystem.c +++ b/lib/nvmf/subsystem.c @@ -44,6 +44,7 @@ #include "spdk/json.h" #include "spdk/file.h" +#define __SPDK_BDEV_MODULE_ONLY #include "spdk/bdev_module.h" #include "spdk/log.h" #include "spdk_internal/utf.h" @@ -1320,7 +1321,7 @@ nvmf_ns_event(enum spdk_bdev_event_type type, { SPDK_DEBUGLOG(nvmf, "Bdev event: type %d, name %s, subsystem_id %d, ns_id %d\n", type, - bdev->name, + spdk_bdev_get_name(bdev), ((struct spdk_nvmf_ns *)event_ctx)->subsystem->id, ((struct spdk_nvmf_ns *)event_ctx)->nsid); diff --git a/test/unit/lib/nvmf/fc.c/fc_ut.c b/test/unit/lib/nvmf/fc.c/fc_ut.c index a7603a7bc..560505767 100644 --- a/test/unit/lib/nvmf/fc.c/fc_ut.c +++ b/test/unit/lib/nvmf/fc.c/fc_ut.c @@ -51,6 +51,7 @@ #include "json/json_write.c" #include "nvmf/nvmf.c" #include "nvmf/transport.c" +#include "spdk/bdev_module.h" #include "nvmf/subsystem.c" #include "nvmf/fc.c" #include "nvmf/fc_ls.c" diff --git a/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c b/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c index 3263eeb66..2c113acd5 100644 --- a/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c +++ b/test/unit/lib/nvmf/subsystem.c/subsystem_ut.c @@ -37,6 +37,7 @@ #include "spdk_cunit.h" #include "spdk_internal/mock.h" +#include "spdk/bdev_module.h" #include "nvmf/subsystem.c" SPDK_LOG_REGISTER_COMPONENT(nvmf)