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

nvme: add function to get ZNS max open zones



Add a function to get the number of max open 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: I4223146bc1ddf90486892a0af5fe5ce006dc5fd3
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6442


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 74c43a74
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -96,6 +96,23 @@ uint64_t spdk_nvme_zns_ns_get_zone_size(struct spdk_nvme_ns *ns);
 */
uint64_t spdk_nvme_zns_ns_get_num_zones(struct spdk_nvme_ns *ns);

/**
 * Get the maximum number of open zones for the given namespace.
 *
 * An open zone is a zone in any of the zone states:
 * EXPLICIT OPEN or IMPLICIT OPEN.
 *
 * 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 open zones.
 */
uint32_t spdk_nvme_zns_ns_get_max_open_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
@@ -60,6 +60,14 @@ spdk_nvme_zns_ns_get_num_zones(struct spdk_nvme_ns *ns)
	return spdk_nvme_ns_get_num_sectors(ns) / spdk_nvme_zns_ns_get_zone_size_sectors(ns);
}

uint32_t
spdk_nvme_zns_ns_get_max_open_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->mor + 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
@@ -173,6 +173,7 @@
	spdk_nvme_zns_ns_get_zone_size_sectors;
	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_ctrlr_get_data;
	spdk_nvme_zns_ctrlr_get_max_zone_append_size;
	spdk_nvme_zns_zone_append;