Revamp file locking
[fio.git] / fio.h
diff --git a/fio.h b/fio.h
index 6b8ffe29512bffe563a28263e7bbebb1bd50cd67..b22009b9ffc933bdf4f5ce12c13916398f06a91a 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 *);