Multiple file handling fixes
[fio.git] / fio.h
diff --git a/fio.h b/fio.h
index 6b8ffe29512bffe563a28263e7bbebb1bd50cd67..e7e32cc75a48652286b45c7eb0207eb902a1baf6 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -46,6 +46,12 @@ enum td_ddir {
        TD_DDIR_RANDRW          = TD_DDIR_RW | TD_DDIR_RAND,
 };
 
+enum file_lock_mode {
+       FILE_LOCK_NONE,
+       FILE_LOCK_EXCLUSIVE,
+       FILE_LOCK_READWRITE,
+};
+
 /*
  * Use for maintaining statistics
  */
@@ -274,6 +280,7 @@ enum fio_file_flags {
        FIO_FILE_EXTEND         = 1 << 2,       /* needs extend */
        FIO_FILE_DONE           = 1 << 3,       /* io completed to this file */
        FIO_SIZE_KNOWN          = 1 << 4,       /* size has been set */
+       FIO_FILE_HASHED         = 1 << 5,       /* file is on hash */
 };
 
 /*
@@ -281,6 +288,7 @@ enum fio_file_flags {
  * this structure holds state information for a single file.
  */
 struct fio_file {
+       struct list_head hash_list;
        enum fio_filetype filetype;
 
        /*
@@ -307,6 +315,14 @@ struct fio_file {
 
        unsigned long long last_pos;
 
+       /*
+        * if io is protected by a semaphore, this is set
+        */
+       struct fio_mutex *lock;
+       void *lock_owner;
+       unsigned int lock_batch;
+       enum fio_ddir lock_ddir;
+
        /*
         * block map for random io
         */
@@ -405,6 +421,8 @@ struct thread_options {
 
        unsigned int nr_files;
        unsigned int open_files;
+       enum file_lock_mode file_lock_mode;
+       unsigned int lockfile_batch;
 
        unsigned int odirect;
        unsigned int invalidate_cache;
@@ -808,8 +826,9 @@ extern int __must_check generic_close_file(struct thread_data *, struct fio_file
 extern int add_file(struct thread_data *, const char *);
 extern void get_file(struct fio_file *);
 extern int __must_check put_file(struct thread_data *, struct fio_file *);
-extern void lock_file(struct thread_data *, struct fio_file *);
-extern void unlock_file(struct fio_file *);
+extern void lock_file(struct thread_data *, struct fio_file *, enum fio_ddir);
+extern void unlock_file(struct thread_data *, struct fio_file *);
+extern void unlock_file_all(struct thread_data *, struct fio_file *);
 extern int add_dir_files(struct thread_data *, const char *);
 extern int init_random_map(struct thread_data *);
 extern void dup_files(struct thread_data *, struct thread_data *);
@@ -942,7 +961,7 @@ extern void close_ioengine(struct thread_data *);
 #define for_each_td(td, i)     \
        for ((i) = 0, (td) = &threads[0]; (i) < (int) thread_number; (i)++, (td)++)
 #define for_each_file(td, f, i)        \
-       for ((i) = 0, (f) = (td)->files[0]; (i) < (td)->o.nr_files; (i)++, (f)++)
+       for ((i) = 0, (f) = (td)->files[0]; (i) < (td)->o.nr_files; (i)++, (f) = (td)->files[i])
 
 #define fio_assert(td, cond)   do {    \
        if (!(cond)) {                  \