summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSitsofe Wheeler <sitsofe@yahoo.com>2020-05-19 22:41:49 +0100
committerSitsofe Wheeler <sitsofe@yahoo.com>2020-05-19 23:09:42 +0100
commiteda99d5530738bebdd355fa1df97d5d33d3b9f79 (patch)
tree0cc97354c107fbb33a459f7f9b724589ed68cda5 /lib
parente1ce5b385c65803b170e512a1b5256bbe99f98f0 (diff)
downloadfio-eda99d5530738bebdd355fa1df97d5d33d3b9f79.tar.gz
fio-eda99d5530738bebdd355fa1df97d5d33d3b9f79.tar.bz2
Fix 32-bit/LLP64 platform truncation issues
- After 140a6888 ("rate: Convert the rate and rate_min options to FIO_OPTS_ULL") landed 32-bit/LLP64 platforms need additional changes to cope with 64 bit I/O rate values - The seed is 64 bit but was being being truncated to 32 bits in td_fill_rand_seeds_internal() on bit/LLP64 platforms Prior to this commit when running an fio compiled with CC=clang-9 ./configure \ --extra-cflags="-fsanitize=undefined,implicit-integer-truncation " "-fno-builtin" using this job ./fio --ioengine=null --bs=1M --rate=6G --rate_min=5G --name=test --size=100G warnings like the following were produced init.c:996:27: runtime error: implicit conversion from type 'uint64_t' (aka 'unsigned long long') of value 5942511153023025289 (64-bit, unsigned) to type 'unsigned int' changed the value to 2914779273 (32-bit, unsigned) [..] backend.c:212:25: runtime error: implicit conversion from type 'unsigned long long' of value 12886999040 (64-bit, unsigned) to type 'unsigned long' changed the value to 2097152 (32-bit, unsigned) inside a 32-bit Ubuntu 18.04 docker container. Fixes: https://github.com/axboe/fio/issues/716
Diffstat (limited to 'lib')
-rw-r--r--lib/rand.c4
-rw-r--r--lib/rand.h2
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/rand.c b/lib/rand.c
index 69acb06c..5eb6e60a 100644
--- a/lib/rand.c
+++ b/lib/rand.c
@@ -85,12 +85,12 @@ void init_rand(struct frand_state *state, bool use64)
__init_rand64(&state->state64, 1);
}
-void init_rand_seed(struct frand_state *state, unsigned int seed, bool use64)
+void init_rand_seed(struct frand_state *state, uint64_t seed, bool use64)
{
state->use64 = use64;
if (!use64)
- __init_rand32(&state->state32, seed);
+ __init_rand32(&state->state32, (unsigned int) seed);
else
__init_rand64(&state->state64, seed);
}
diff --git a/lib/rand.h b/lib/rand.h
index 95d4f6d4..2ccc1b37 100644
--- a/lib/rand.h
+++ b/lib/rand.h
@@ -149,7 +149,7 @@ static inline uint64_t rand_between(struct frand_state *state, uint64_t start,
}
extern void init_rand(struct frand_state *, bool);
-extern void init_rand_seed(struct frand_state *, unsigned int seed, bool);
+extern void init_rand_seed(struct frand_state *, uint64_t seed, bool);
extern void __fill_random_buf(void *buf, unsigned int len, uint64_t seed);
extern uint64_t fill_random_buf(struct frand_state *, void *buf, unsigned int len);
extern void __fill_random_buf_percentage(uint64_t, void *, unsigned int, unsigned int, unsigned int, char *, unsigned int);