X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=io_u.c;h=55ac82659cc81670640ab04941849fb7d52772f2;hp=7f52a243fbdbc8e2b12706c1f45c52716729a8ab;hb=009bd847b5aeaca78e76de3a7066fe7d507a735f;hpb=d8005759746a2cb5c8269201911b1997aa714e80 diff --git a/io_u.c b/io_u.c index 7f52a243..55ac8265 100644 --- a/io_u.c +++ b/io_u.c @@ -188,7 +188,14 @@ static int get_next_offset(struct thread_data *td, struct io_u *io_u) b = (f->last_pos - f->file_offset) / td->o.min_bs[ddir]; } - io_u->offset = (b * td->o.min_bs[ddir]) + f->file_offset; + io_u->offset = b * td->o.min_bs[ddir]; + if (io_u->offset >= f->io_size) { + dprint(FD_IO, "get_next_offset: offset %llu >= io_size %llu\n", + io_u->offset, f->io_size); + return 1; + } + + io_u->offset += f->file_offset; if (io_u->offset >= f->real_file_size) { dprint(FD_IO, "get_next_offset: offset %llu >= size %llu\n", io_u->offset, f->real_file_size); @@ -650,6 +657,16 @@ set_file: if (!fill_io_u(td, io_u)) break; + /* + * optimization to prevent close/open of the same file. This + * way we preserve queueing etc. + */ + if (td->o.nr_files == 1 && td->o.time_based) { + put_file(td, f); + fio_file_reset(f); + goto set_file; + } + /* * td_io_close() does a put_file() as well, so no need to * do that here.