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

nvme/fio_plugin: use calloc to allocate zone report buffer



spdk_nvme_zns_report_zones() is implemented using
nvme_allocate_request_user_copy(), which under the hood will do
a spdk_zmalloc() with the SPDK_MALLOC_DMA flag set, and will copy
over the result to our buffer.

Therefore, it is redundant for us to use spdk_dma_zmalloc(),
because it will cause us to allocate twice the amount of memory
from the precious DMA pool than needed.

Changing this zone report buffer allocation to a calloc also
has the benefit of making the code uniform with all other
spdk_nvme_zns_report_zones() call sites in the SPDK codebase.

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


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 7ce5dd62
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1243,7 +1243,7 @@ spdk_fio_report_zones(struct thread_data *td, struct fio_file *f, uint64_t offse
	report_nzones_max = (mdts_nbytes - sizeof(*report)) / sizeof(report->descs[0]);
	report_nzones_max = spdk_min(spdk_min(report_nzones_max, nr_zones), ns_nzones);
	report_nbytes = sizeof(report->descs[0]) * report_nzones_max + sizeof(*report);
	report = spdk_dma_zmalloc(report_nbytes, NVME_IO_ALIGN, NULL);
	report = calloc(1, report_nbytes);
	if (!report) {
		log_err("spdk/nvme: failed report_zones(): ENOMEM\n");
		return -ENOMEM;
@@ -1310,7 +1310,7 @@ spdk_fio_report_zones(struct thread_data *td, struct fio_file *f, uint64_t offse
	}

exit:
	spdk_dma_free(report);
	free(report);

	return err ? err : (int)report_nzones;
}