From ea80818901503b86c05e4b0554e418352199d1a9 Mon Sep 17 00:00:00 2001 From: WANGHAILIANG Date: Mon, 17 Aug 2020 17:40:47 +0800 Subject: [PATCH] test/bdevperf: fix an int types for offset which can result in core dumped. Originally, config->offset was defined as int type. When the capacity of SSD is very large, such as 8T(P4510), then bdev->blockcnt2 is 7814037168, config->offset is 3907018584. At this time, it exceeds the maximum int range of 2147483647 and becomes a negative number, resulting in core dumped. Debug info: config->filename is Nvme1n1. make_cli_job_config offset is -387948712. This should be: config->filename is Nvme1n1. make_cli_job_config offset is 3907018584. Change-Id: Ia83d88cc4e56d6c97a6d3fc1a2593b6fc31655b2 Signed-off-by: WANGHAILIANG Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3818 Community-CI: Broadcom CI Reviewed-by: GangCao Reviewed-by: Changpeng Liu Reviewed-by: Shuhei Matsumoto Tested-by: SPDK CI Jenkins --- test/bdev/bdevperf/bdevperf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/bdev/bdevperf/bdevperf.c b/test/bdev/bdevperf/bdevperf.c index adcdf31cb..ab6dc9f35 100644 --- a/test/bdev/bdevperf/bdevperf.c +++ b/test/bdev/bdevperf/bdevperf.c @@ -170,7 +170,7 @@ struct job_config { int bs; int iodepth; int rwmixread; - int offset; + int64_t offset; int length; enum job_config_rw rw; TAILQ_ENTRY(job_config) link; @@ -1465,7 +1465,7 @@ bdevperf_construct_config_jobs(void) } static int -make_cli_job_config(const char *filename, int offset, int range) +make_cli_job_config(const char *filename, int64_t offset, int range) { struct job_config *config = calloc(1, sizeof(*config)); @@ -1499,7 +1499,7 @@ bdevperf_construct_multithread_jobs(void) uint32_t i; uint32_t num_cores; uint32_t blocks_per_job; - uint32_t offset; + int64_t offset; num_cores = 0; SPDK_ENV_FOREACH_CORE(i) {