Add file reference counting
We must not close a file, while io is in progress to it. That
will make the queuing engines barf.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/fio.h b/fio.h
index e451f95..5bf8c43 100644
--- a/fio.h
+++ b/fio.h
@@ -219,8 +219,9 @@
};
enum fio_file_flags {
- FIO_FILE_OPEN = 1 << 0,
- FIO_FILE_UNLINK = 1 << 1,
+ FIO_FILE_OPEN = 1 << 0, /* file is open */
+ FIO_FILE_UNLINK = 1 << 1, /* unlink on close */
+ FIO_FILE_CLOSING = 1 << 2, /* file being closed */
};
/*
@@ -252,6 +253,7 @@
unsigned int num_maps;
unsigned int last_free_lookup;
+ int references;
enum fio_file_flags flags;
};
@@ -654,6 +656,8 @@
extern int __must_check generic_open_file(struct thread_data *, struct fio_file *);
extern void generic_close_file(struct thread_data *, struct fio_file *);
extern void add_file(struct thread_data *, const char *);
+extern void get_file(struct fio_file *);
+extern void put_file(struct thread_data *, struct fio_file *);
/*
* ETA/status stuff