From: Jens Axboe Date: Thu, 26 Apr 2007 08:21:15 +0000 (+0200) Subject: Fix bug with file references X-Git-Tag: fio-1.16.1~1 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=2dbdab7e8fb0205c471f72effab1b2ae5f19bfac Fix bug with file references This could cause premature exit of fio with an error at the end of the run. Signed-off-by: Jens Axboe --- diff --git a/io_u.c b/io_u.c index 99f07288..7fe5242f 100644 --- a/io_u.c +++ b/io_u.c @@ -265,6 +265,9 @@ void put_io_u(struct thread_data *td, struct io_u *io_u) assert((io_u->flags & IO_U_F_FREE) == 0); io_u->flags |= IO_U_F_FREE; + if (io_u->file) + put_file(td, io_u->file); + io_u->file = NULL; list_del(&io_u->list); list_add(&io_u->list, &td->io_u_freelist); @@ -540,12 +543,14 @@ struct io_u *get_io_u(struct thread_data *td) set_file: io_u->file = f; + get_file(f); if (!fill_io_u(td, io_u)) break; /* - * No more to do for this file, close it + * td_io_close() does a put_file() as well, so no need to + * do that here. */ io_u->file = NULL; td_io_close_file(td, f); @@ -627,8 +632,6 @@ static void io_completed(struct thread_data *td, struct io_u *io_u, assert(io_u->flags & IO_U_F_FLIGHT); io_u->flags &= ~IO_U_F_FLIGHT; - put_file(td, io_u->file); - if (io_u->ddir == DDIR_SYNC) { td->last_was_sync = 1; return; diff --git a/ioengines.c b/ioengines.c index 34ae9167..28cdfd49 100644 --- a/ioengines.c +++ b/ioengines.c @@ -207,9 +207,6 @@ int td_io_queue(struct thread_data *td, struct io_u *io_u) ret = td->io_ops->queue(td, io_u); - if (ret == FIO_Q_QUEUED || ret == FIO_Q_COMPLETED) - get_file(io_u->file); - if (ret == FIO_Q_QUEUED) { int r;