From d21ec1f00dbba94cd3ebffbf9b8d973b9d29b1bf Mon Sep 17 00:00:00 2001 From: Seth Howell Date: Mon, 21 Aug 2017 10:32:22 -0700 Subject: [PATCH] lib/nvme: Add spdk_nvme_ns_get_ctrlr to the public api This can be used in callbacks when a user has a namespace but needs to call controller specific functions such as alloc_io_qpair. Change-Id: I00c931e2846e42f540c17f3254fe97a45e9bd079 Signed-off-by: Seth Howell Reviewed-on: https://review.gerrithub.io/375022 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Ben Walker --- CHANGELOG.md | 4 ++++ include/spdk/nvme.h | 8 ++++++++ lib/nvme/nvme_ns.c | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d81fb20b..0faa9807d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,9 @@ into account when splitting I/O requests. The HotplugEnable option in `[Nvme]` sections of the configuration file is now "No" by default. It was previously "Yes". +The NVMe library now includes a function spdk_nvme_ns_get_ctrlr which returns the +NVMe Controller associated with a given namespace. + ### NVMe-oF Target (nvmf) The NVMe-oF target no longer requires any in capsule data buffers to run, and @@ -42,6 +45,7 @@ additional clarity when constructing spdk_mempools. Previously, -1 could be passed and the library would choose a reasonable default, but this new value makes it explicit that the default is being used. + ## v17.07: Build system improvements, userspace vhost-blk target, and GPT bdev ### Build System diff --git a/include/spdk/nvme.h b/include/spdk/nvme.h index adf46c669..bc17dbd9a 100644 --- a/include/spdk/nvme.h +++ b/include/spdk/nvme.h @@ -847,6 +847,14 @@ const struct spdk_nvme_ns_data *spdk_nvme_ns_get_data(struct spdk_nvme_ns *ns); */ uint32_t spdk_nvme_ns_get_id(struct spdk_nvme_ns *ns); +/** + * \brief Get the Controller with which this namespace is associated. + * + * This function is thread safe and can be called at any point while the controller is attached to + * the SPDK NVMe driver. + */ +struct spdk_nvme_ctrlr *spdk_nvme_ns_get_ctrlr(struct spdk_nvme_ns *ns); + /** * \brief Determine whether a namespace is active. * diff --git a/lib/nvme/nvme_ns.c b/lib/nvme/nvme_ns.c index 3cd5d08ee..a787db7f2 100644 --- a/lib/nvme/nvme_ns.c +++ b/lib/nvme/nvme_ns.c @@ -143,6 +143,12 @@ spdk_nvme_ns_is_active(struct spdk_nvme_ns *ns) return nsdata->ncap != 0; } +struct spdk_nvme_ctrlr * +spdk_nvme_ns_get_ctrlr(struct spdk_nvme_ns *ns) +{ + return ns->ctrlr; +} + uint32_t spdk_nvme_ns_get_max_io_xfer_size(struct spdk_nvme_ns *ns) {