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
*/
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 */
};
/*
* this structure holds state information for a single file.
*/
struct fio_file {
+ struct list_head hash_list;
enum fio_filetype filetype;
/*
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
*/
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;
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 *);
#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)) { \