From 31a1b193a29f17251c5c2450002661deff8c1ffc Mon Sep 17 00:00:00 2001 From: Alexey Marchuk Date: Tue, 5 Oct 2021 16:38:32 +0300 Subject: [PATCH] perf: Add check that io_size is a multiple of ns sector size It is possible to specify io_size which is not a multiple of sector size and in that case real IO will have size of g_io_size_bytes/sector_size. It is integer division, so IO will be less than requested by the user. At the same time performance statistics are reported using io_size specified by the user (which is bigger than real IO size) so we have wrong statistics (e.g. we can see BW higher than NIC line rate). To avoid this confusing situation, add a check that user's io_size can be evenly divided by ns sector size. Signed-off-by: Alexey Marchuk Change-Id: Ie63b5b7b3d99b5c51c10ec09e084fd30d6cb33dd Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9733 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Konrad Sztyber Reviewed-by: Shuhei Matsumoto Reviewed-by: Tomasz Zawadzki --- examples/nvme/perf/perf.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/nvme/perf/perf.c b/examples/nvme/perf/perf.c index 797364d379..10c2558579 100644 --- a/examples/nvme/perf/perf.c +++ b/examples/nvme/perf/perf.c @@ -1207,6 +1207,13 @@ register_ns(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_ns *ns) return; } + if (g_io_size_bytes % sector_size != 0) { + printf("WARNING: IO size %u (-o) is not a multiple of nsid %u sector size %u." + " Removing this ns from test\n", g_io_size_bytes, spdk_nvme_ns_get_id(ns), sector_size); + g_warn = true; + return; + } + max_xfer_size = spdk_nvme_ns_get_max_io_xfer_size(ns); spdk_nvme_ctrlr_get_default_io_qpair_opts(ctrlr, &opts, sizeof(opts)); /* NVMe driver may add additional entries based on