7 * The type of object we are working on
10 FIO_TYPE_FILE = 1, /* plain file */
11 FIO_TYPE_BD, /* block device */
12 FIO_TYPE_CHAR, /* character device */
13 FIO_TYPE_PIPE, /* pipe */
17 FIO_FILE_open = 1 << 0, /* file is open */
18 FIO_FILE_closing = 1 << 1, /* file being closed */
19 FIO_FILE_extend = 1 << 2, /* needs extend */
20 FIO_FILE_done = 1 << 3, /* io completed to this file */
21 FIO_FILE_size_known = 1 << 4, /* size has been set */
22 FIO_FILE_hashed = 1 << 5, /* file is on hash */
32 * Each thread_data structure has a number of files associated with it,
33 * this structure holds state information for a single file.
36 struct flist_head hash_list;
37 enum fio_filetype filetype;
40 * A file may not be a file descriptor, let the io engine decide
43 unsigned long file_data;
48 * filename and possible memory mapping
51 unsigned int major, minor;
58 * size of the file, offset into file, and io size from that offset
60 unsigned long long real_file_size;
61 unsigned long long file_offset;
62 unsigned long long io_size;
64 unsigned long long last_pos;
67 * if io is protected by a semaphore, this is set
69 struct fio_mutex *lock;
71 unsigned int lock_batch;
72 enum fio_ddir lock_ddir;
75 * block map for random io
77 unsigned int *file_map;
78 unsigned int num_maps;
79 unsigned int last_free_lookup;
82 enum fio_file_flags flags;
87 #define FILE_FLAG_FNS(name) \
88 static inline void fio_file_set_##name(struct fio_file *f) \
90 (f)->flags |= FIO_FILE_##name; \
92 static inline void fio_file_clear_##name(struct fio_file *f) \
94 (f)->flags &= ~FIO_FILE_##name; \
96 static inline int fio_file_##name(struct fio_file *f) \
98 return ((f)->flags & FIO_FILE_##name) != 0; \
102 FILE_FLAG_FNS(closing);
103 FILE_FLAG_FNS(extend);
105 FILE_FLAG_FNS(size_known);
106 FILE_FLAG_FNS(hashed);
110 * File setup/shutdown
113 extern void close_files(struct thread_data *);
114 extern void close_and_free_files(struct thread_data *);
115 extern int __must_check setup_files(struct thread_data *);
116 extern int __must_check file_invalidate_cache(struct thread_data *, struct fio_file *);
117 extern int __must_check generic_open_file(struct thread_data *, struct fio_file *);
118 extern int __must_check generic_close_file(struct thread_data *, struct fio_file *);
119 extern int __must_check generic_get_file_size(struct thread_data *, struct fio_file *);
120 extern int __must_check pre_read_files(struct thread_data *);
121 extern int add_file(struct thread_data *, const char *);
122 extern void get_file(struct fio_file *);
123 extern int __must_check put_file(struct thread_data *, struct fio_file *);
124 extern void lock_file(struct thread_data *, struct fio_file *, enum fio_ddir);
125 extern void unlock_file(struct thread_data *, struct fio_file *);
126 extern void unlock_file_all(struct thread_data *, struct fio_file *);
127 extern int add_dir_files(struct thread_data *, const char *);
128 extern int init_random_map(struct thread_data *);
129 extern void dup_files(struct thread_data *, struct thread_data *);
130 extern int get_fileno(struct thread_data *, const char *);
131 extern void free_release_files(struct thread_data *);