From: Jens Axboe Date: Tue, 13 Mar 2018 17:49:55 +0000 (-0600) Subject: io_u: only rewind file position if it's non-zero X-Git-Tag: fio-3.6~40 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=69b98f11d62cb12482130fac79b8ebf00c0bb139;ds=sidebyside io_u: only rewind file position if it's non-zero This: bs=8k rw=read:-4k is supposed to read 0..8k, then add 8k and subtract 4k, ending up with a next read at 4k..12k and so forth. But we rewind too quickly, and the first IO fails as being out-of-bounds. Fixes: c22825bb537af ("Fix backwards reads with --size smaller than the file size") Signed-off-by: Jens Axboe --- diff --git a/io_u.c b/io_u.c index a37b723e..01b36938 100644 --- a/io_u.c +++ b/io_u.c @@ -430,7 +430,11 @@ static int get_next_seq_offset(struct thread_data *td, struct fio_file *f, if (f->last_pos[ddir] < f->real_file_size) { uint64_t pos; - if (f->last_pos[ddir] == f->file_offset && o->ddir_seq_add < 0) { + /* + * Only rewind if we already hit the end + */ + if (f->last_pos[ddir] == f->file_offset && + f->file_offset && o->ddir_seq_add < 0) { if (f->real_file_size > f->io_size) f->last_pos[ddir] = f->io_size; else