From: Jens Axboe Date: Thu, 15 May 2008 08:19:46 +0000 (+0200) Subject: Fix bad interaction with file open/close and queuing X-Git-Tag: fio-1.21-rc1~16 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=009bd847b5aeaca78e76de3a7066fe7d507a735f Fix bad interaction with file open/close and queuing Signed-off-by: Jens Axboe --- diff --git a/fio.h b/fio.h index 5ee43e0a..47b6d488 100644 --- a/fio.h +++ b/fio.h @@ -980,6 +980,12 @@ extern void close_ioengine(struct thread_data *); } \ } while (0) +static inline void fio_file_reset(struct fio_file *f) +{ + f->last_free_lookup = 0; + f->last_pos = f->file_offset; +} + static inline void clear_error(struct thread_data *td) { td->error = 0; 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. diff --git a/ioengines.c b/ioengines.c index d3ee4b98..9e1c5563 100644 --- a/ioengines.c +++ b/ioengines.c @@ -327,8 +327,7 @@ int td_io_open_file(struct thread_data *td, struct fio_file *f) } } - f->last_free_lookup = 0; - f->last_pos = f->file_offset; + fio_file_reset(f); f->flags |= FIO_FILE_OPEN; f->flags &= ~FIO_FILE_CLOSING;