From: Jens Axboe Date: Thu, 14 Jan 2016 17:31:38 +0000 (-0700) Subject: io_u: ensure that we align new start offset properly for time_based X-Git-Tag: fio-2.4~5 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=19ddc35b9b97be5af371bb65e93a4864d1dce7b6;hp=65f41ccb386850671c0651f976cd33fdfbe0644d io_u: ensure that we align new start offset properly for time_based If io_size isn't a multiple of the block size, weird things can happen, which usually means that fio will exit with an unaligned IO error: fio: io_u error on file /dev/nvme0n1: Invalid argument: write offset=125830, buflen=1048576 where offset=125830 really should have been aligned to the block size. Ensure that we do that. Signed-off-by: Jens Axboe --- diff --git a/io_u.c b/io_u.c index 9628d5e3..8d349128 100644 --- a/io_u.c +++ b/io_u.c @@ -285,8 +285,15 @@ static int get_next_seq_offset(struct thread_data *td, struct fio_file *f, assert(ddir_rw(ddir)); if (f->last_pos[ddir] >= f->io_size + get_start_offset(td, f) && - o->time_based) - f->last_pos[ddir] = f->last_pos[ddir] - f->io_size; + o->time_based) { + struct thread_options *o = &td->o; + uint64_t io_size = f->io_size + (f->io_size % o->min_bs[ddir]); + + if (io_size > f->last_pos[ddir]) + f->last_pos[ddir] = 0; + else + f->last_pos[ddir] = f->last_pos[ddir] - io_size; + } if (f->last_pos[ddir] < f->real_file_size) { uint64_t pos;