diff options
author | Jim Harris <jimharris@FreeBSD.org> | 2013-10-08 15:47:22 +0000 |
---|---|---|
committer | Jim Harris <jimharris@FreeBSD.org> | 2013-10-08 15:47:22 +0000 |
commit | 992db80f1d4150dafa344f0d7979a608490f3259 (patch) | |
tree | f4b464ac76cec93bda88ecae18628e7a2b88fd08 | |
parent | a40e72a695a5db6cf9c6da148e8e8c26158e29b3 (diff) | |
download | src-992db80f1d4150dafa344f0d7979a608490f3259.tar.gz src-992db80f1d4150dafa344f0d7979a608490f3259.zip |
Extend some 32-bit fields and variables to 64-bit to prevent overflow
when calculating stats in nvmecontrol perftest.
Sponsored by: Intel
Reported by: Joe Golio <joseph.golio@emc.com>
Reviewed by: carl
Approved by: re (hrs)
MFC after: 1 week
Notes
Notes:
svn path=/head/; revision=256152
-rw-r--r-- | sbin/nvmecontrol/perftest.c | 12 | ||||
-rw-r--r-- | sys/dev/nvme/nvme.h | 2 | ||||
-rw-r--r-- | sys/dev/nvme/nvme_test.c | 8 |
3 files changed, 12 insertions, 10 deletions
diff --git a/sbin/nvmecontrol/perftest.c b/sbin/nvmecontrol/perftest.c index a7339bf29d41..15e49757e2be 100644 --- a/sbin/nvmecontrol/perftest.c +++ b/sbin/nvmecontrol/perftest.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include <ctype.h> #include <err.h> #include <fcntl.h> +#include <inttypes.h> #include <stdbool.h> #include <stddef.h> #include <stdio.h> @@ -45,7 +46,8 @@ __FBSDID("$FreeBSD$"); static void print_perftest(struct nvme_io_test *io_test, bool perthread) { - uint32_t i, io_completed = 0, iops, mbps; + uint64_t io_completed = 0, iops, mbps; + uint32_t i; for (i = 0; i < io_test->num_threads; i++) io_completed += io_test->io_completed[i]; @@ -53,15 +55,15 @@ print_perftest(struct nvme_io_test *io_test, bool perthread) iops = io_completed/io_test->time; mbps = iops * io_test->size / (1024*1024); - printf("Threads: %2d Size: %6d %5s Time: %3d IO/s: %7d MB/s: %4d\n", + printf("Threads: %2d Size: %6d %5s Time: %3d IO/s: %7ju MB/s: %4ju\n", io_test->num_threads, io_test->size, io_test->opc == NVME_OPC_READ ? "READ" : "WRITE", - io_test->time, iops, mbps); + io_test->time, (uintmax_t)iops, (uintmax_t)mbps); if (perthread) for (i = 0; i < io_test->num_threads; i++) - printf("\t%3d: %8d IO/s\n", i, - io_test->io_completed[i]/io_test->time); + printf("\t%3d: %8ju IO/s\n", i, + (uintmax_t)io_test->io_completed[i]/io_test->time); exit(1); } diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h index cb4701abf9fa..111a9320c204 100644 --- a/sys/dev/nvme/nvme.h +++ b/sys/dev/nvme/nvme.h @@ -720,7 +720,7 @@ struct nvme_io_test { uint32_t time; /* in seconds */ uint32_t num_threads; uint32_t flags; - uint32_t io_completed[NVME_TEST_MAX_THREADS]; + uint64_t io_completed[NVME_TEST_MAX_THREADS]; }; enum nvme_io_test_flags { diff --git a/sys/dev/nvme/nvme_test.c b/sys/dev/nvme/nvme_test.c index 89bcc00c0590..24f65cce9b98 100644 --- a/sys/dev/nvme/nvme_test.c +++ b/sys/dev/nvme/nvme_test.c @@ -53,7 +53,7 @@ struct nvme_io_test_thread { void *buf; uint32_t size; uint32_t time; - uint32_t io_completed; + uint64_t io_completed; }; struct nvme_io_test_internal { @@ -66,7 +66,7 @@ struct nvme_io_test_internal { uint32_t td_active; uint32_t td_idx; uint32_t flags; - uint32_t io_completed[NVME_TEST_MAX_THREADS]; + uint64_t io_completed[NVME_TEST_MAX_THREADS]; }; static void @@ -90,8 +90,8 @@ nvme_ns_bio_test(void *arg) struct cdev *dev; void *buf; struct timeval t; - uint64_t offset; - uint32_t idx, io_completed = 0; + uint64_t io_completed = 0, offset; + uint32_t idx; #if __FreeBSD_version >= 900017 int ref; #endif |