From d11aa8732053c2866a49d633c0f8fe3cc5995f22 Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Fri, 1 Mar 2019 00:12:55 -0500 Subject: [PATCH] nvmf: add reservation information to each subsystem's poll group Change-Id: Idcbc3053daf756c818ae3715b4ba0cbd91ed3d44 Signed-off-by: Changpeng Liu Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446212 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/nvmf/nvmf.c | 8 ++++++++ lib/nvmf/nvmf_internal.h | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/nvmf/nvmf.c b/lib/nvmf/nvmf.c index c908750b7..4ad0916eb 100644 --- a/lib/nvmf/nvmf.c +++ b/lib/nvmf/nvmf.c @@ -947,6 +947,14 @@ poll_group_update_subsystem(struct spdk_nvmf_poll_group *group, } else { /* A namespace was present before and didn't change. */ } + + if (ns == NULL) { + memset(&sgroup->ns_info[i], 0, sizeof(struct spdk_nvmf_subsystem_pg_ns_info)); + } else if (ns->rtype && ns->holder) { + sgroup->ns_info[i].crkey = ns->crkey; + sgroup->ns_info[i].rtype = ns->rtype; + sgroup->ns_info[i].hostid = ns->holder->hostid; + } } return 0; diff --git a/lib/nvmf/nvmf_internal.h b/lib/nvmf/nvmf_internal.h index d69a3d82f..94b020718 100644 --- a/lib/nvmf/nvmf_internal.h +++ b/lib/nvmf/nvmf_internal.h @@ -113,7 +113,13 @@ struct spdk_nvmf_transport_poll_group { }; struct spdk_nvmf_subsystem_pg_ns_info { - struct spdk_io_channel *channel; + struct spdk_io_channel *channel; + /* current reservation key, no reservation if the value is 0 */ + uint64_t crkey; + /* reservation type */ + enum spdk_nvme_reservation_type rtype; + /* Host ID which holds the reservation */ + struct spdk_uuid hostid; }; struct spdk_nvmf_subsystem_poll_group {