Commit 8f9fdf2d authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

identify: fix zone report bufsize calculation



It used to solely rely on the max_xfer_size of a controller, which, on
some transports (e.g. TCP), can be unlimited and is set to UINT32_MAX.
We obviously don't need to allocate that much memory, so limit it to the
number of zones we're trying to show.

Fixes #3297.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I2a54cc5d63234045733d5c848a38ac8957a71033
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/22323


Community-CI: Mellanox Build Bot
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent c829c01f
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -1125,17 +1125,17 @@ get_and_print_zns_zone_report(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *q

	format_index = spdk_nvme_ns_get_format_index(nsdata);
	zdes = nsdata_zns->lbafe[format_index].zdes * 64;
	zones_to_print = g_zone_report_limit ? spdk_min(total_zones, (uint64_t)g_zone_report_limit) : \
			 total_zones;

	report_bufsize = spdk_nvme_ns_get_max_io_xfer_size(ns);
	report_bufsize = spdk_min(zrs + zones_to_print * (zds + zdes),
				  spdk_nvme_ns_get_max_io_xfer_size(ns));
	report_buf = calloc(1, report_bufsize);
	if (!report_buf) {
		printf("Zone report allocation failed!\n");
		exit(1);
	}

	zones_to_print = g_zone_report_limit ? spdk_min(total_zones, (uint64_t)g_zone_report_limit) : \
			 total_zones;

	print_uline('=', printf("NVMe ZNS Zone Report (first %zu of %zu)\n", zones_to_print, total_zones));

	while (handled_zones < zones_to_print) {