Track io_u state (free or in-flight)
That way we can catch proper use by fio, so we don't get stuck
in cleanup_pending_aio() if someone forgot to put_io_u() in an
error path.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/io_u.c b/io_u.c
index 23a64b0..d30ff4b 100644
--- a/io_u.c
+++ b/io_u.c
@@ -3,6 +3,7 @@
#include <string.h>
#include <signal.h>
#include <time.h>
+#include <assert.h>
#include "fio.h"
#include "os.h"
@@ -193,6 +194,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;
+
io_u->file = NULL;
list_del(&io_u->list);
list_add(&io_u->list, &td->io_u_freelist);
@@ -352,6 +356,9 @@
}
if (io_u) {
+ assert(io_u->flags & IO_U_F_FREE);
+ io_u->flags &= ~IO_U_F_FREE;
+
io_u->error = 0;
list_del(&io_u->list);
list_add(&io_u->list, &td->io_u_busylist);
@@ -441,6 +448,9 @@
{
unsigned long msec;
+ assert(io_u->flags & IO_U_F_FLIGHT);
+ io_u->flags &= ~IO_U_F_FLIGHT;
+
if (io_u->ddir == DDIR_SYNC) {
td->last_was_sync = 1;
return;