t/io_uring: avoid truncation of offset on 32-bit builds
authorJens Axboe <axboe@kernel.dk>
Tue, 14 Mar 2023 19:58:13 +0000 (13:58 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 14 Mar 2023 19:58:13 +0000 (13:58 -0600)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
t/io_uring.c

index 1ea0a9da29b6444ab66d9794940677c5e87f2475..d39d7924b4e4149549c6b2f83e4639bc16111f87 100644 (file)
@@ -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;