From 4d9521fd4d679f914ccf425f6c06864484352fea Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 14 Mar 2023 13:58:13 -0600 Subject: [PATCH] t/io_uring: avoid truncation of offset on 32-bit builds Signed-off-by: Jens Axboe --- t/io_uring.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/t/io_uring.c b/t/io_uring.c index 1ea0a9da..d39d7924 100644 --- a/t/io_uring.c +++ b/t/io_uring.c @@ -530,8 +530,11 @@ static unsigned long long get_offset(struct submitter *s, struct file *f) long r; if (random_io) { + unsigned long long block; + r = __rand64(&s->rand_state); - offset = (r % (f->max_blocks - 1)) * bs; + block = r % f->max_blocks; + offset = block * (unsigned long long) bs; } else { offset = f->cur_off; f->cur_off += bs; -- 2.25.1