diff --git a/include/spdk/nvme_zns.h b/include/spdk/nvme_zns.h index dd0de784f4..025f5b0917 100644 --- a/include/spdk/nvme_zns.h +++ b/include/spdk/nvme_zns.h @@ -113,6 +113,23 @@ uint64_t spdk_nvme_zns_ns_get_num_zones(struct spdk_nvme_ns *ns); */ uint32_t spdk_nvme_zns_ns_get_max_open_zones(struct spdk_nvme_ns *ns); +/** + * Get the maximum number of active zones for the given namespace. + * + * An active zone is a zone in any of the zone states: + * EXPLICIT OPEN, IMPLICIT OPEN or CLOSED. + * + * If this value is 0, there is no limit. + * + * This function is thread safe and can be called at any point while the controller + * is attached to the SPDK NVMe driver. + * + * \param ns Namespace to query. + * + * \return the maximum number of active zones. + */ +uint32_t spdk_nvme_zns_ns_get_max_active_zones(struct spdk_nvme_ns *ns); + /** * Get the Zoned Namespace Command Set Specific Identify Controller data * as defined by the NVMe Zoned Namespace Command Set Specification. diff --git a/lib/nvme/nvme_zns.c b/lib/nvme/nvme_zns.c index 825102bc7b..bdccb7742e 100644 --- a/lib/nvme/nvme_zns.c +++ b/lib/nvme/nvme_zns.c @@ -68,6 +68,14 @@ spdk_nvme_zns_ns_get_max_open_zones(struct spdk_nvme_ns *ns) return nsdata_zns->mor + 1; } +uint32_t +spdk_nvme_zns_ns_get_max_active_zones(struct spdk_nvme_ns *ns) +{ + const struct spdk_nvme_zns_ns_data *nsdata_zns = spdk_nvme_zns_ns_get_data(ns); + + return nsdata_zns->mar + 1; +} + const struct spdk_nvme_zns_ctrlr_data * spdk_nvme_zns_ctrlr_get_data(struct spdk_nvme_ctrlr *ctrlr) { diff --git a/lib/nvme/spdk_nvme.map b/lib/nvme/spdk_nvme.map index f2b75b54c4..0675eb1a8e 100644 --- a/lib/nvme/spdk_nvme.map +++ b/lib/nvme/spdk_nvme.map @@ -174,6 +174,7 @@ spdk_nvme_zns_ns_get_zone_size; spdk_nvme_zns_ns_get_num_zones; spdk_nvme_zns_ns_get_max_open_zones; + spdk_nvme_zns_ns_get_max_active_zones; spdk_nvme_zns_ctrlr_get_data; spdk_nvme_zns_ctrlr_get_max_zone_append_size; spdk_nvme_zns_zone_append;