Commit 9d79d27e authored by Niklas Cassel's avatar Niklas Cassel Committed by Tomasz Zawadzki
Browse files

nvme: add function to get ZNS max active zones



Add a function to get the number of max active zones for a zoned
namespace.

The value inside the identify namespace struct is a 0's based value,
where 0xffffffff means unlimited.
If unlimited, the addition will overflow and return 0,
which is the intended value to represent unlimited for this API.

Signed-off-by: default avatarNiklas Cassel <niklas.cassel@wdc.com>
Change-Id: Ia09e3db157ca0afadbd3ca4032eedd7bcd88248c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6443


Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarsunshihao <sunshihao@huawei.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent bb5330c0
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -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.
+8 −0
Original line number Diff line number Diff line
@@ -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)
{
+1 −0
Original line number Diff line number Diff line
@@ -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;