8 #include <sys/resource.h>
20 unsigned long max_val;
21 unsigned long min_val;
22 unsigned long samples;
32 unsigned long nr_samples;
33 unsigned long max_samples;
34 struct io_sample *log;
38 struct list_head list;
39 unsigned long long offset;
48 #ifdef FIO_HAVE_LIBAIO
51 #ifdef FIO_HAVE_POSIXAIO
58 struct timeval start_time;
59 struct timeval issue_time;
63 unsigned long long offset;
71 struct list_head list;
74 #define FIO_HDR_MAGIC 0xf00baaef
82 struct verify_header {
83 unsigned int fio_magic;
85 unsigned int verify_type;
87 char md5_digest[MD5_HASH_WORDS * 4];
92 struct group_run_stats {
93 unsigned long max_run[2], min_run[2];
94 unsigned long max_bw[2], min_bw[2];
95 unsigned long io_mb[2];
112 size_t orig_buffer_size;
113 volatile int terminate;
114 volatile int runstate;
115 volatile int old_runstate;
118 unsigned int sequential;
122 unsigned int odirect;
123 unsigned int thinktime;
124 unsigned int fsync_blocks;
125 unsigned int start_delay;
126 unsigned int timeout;
127 unsigned int io_engine;
128 unsigned int create_file;
129 unsigned int overwrite;
130 unsigned int invalidate_cache;
131 unsigned int bw_avg_time;
132 unsigned int create_serialize;
133 unsigned int create_fsync;
135 unsigned long long file_size;
136 unsigned long long file_offset;
137 unsigned int sync_io;
138 unsigned int mem_type;
140 unsigned int stonewall;
141 unsigned int numjobs;
142 unsigned int use_thread;
143 unsigned int iodepth;
144 os_cpu_mask_t cpumask;
146 struct drand48_data bsrange_state;
147 struct drand48_data verify_state;
152 char io_engine_name[16];
153 int (*io_prep)(struct thread_data *, struct io_u *);
154 int (*io_queue)(struct thread_data *, struct io_u *);
155 int (*io_getevents)(struct thread_data *, int, int, struct timespec *);
156 struct io_u *(*io_event)(struct thread_data *, int);
157 int (*io_cancel)(struct thread_data *, struct io_u *);
158 void (*io_cleanup)(struct thread_data *);
159 int (*io_sync)(struct thread_data *);
161 unsigned int cur_depth;
162 struct list_head io_u_freelist;
163 struct list_head io_u_busylist;
166 unsigned int ratemin;
167 unsigned int ratecycle;
168 unsigned long rate_usec_cycle;
169 long rate_pending_usleep;
170 unsigned long rate_bytes;
171 struct timeval lastrate;
173 unsigned long runtime[2]; /* msec */
174 unsigned long long io_size;
175 unsigned long long total_io_size;
177 unsigned long io_blocks[2];
178 unsigned long io_bytes[2];
179 unsigned long this_io_bytes[2];
180 unsigned long last_bytes;
183 struct drand48_data random_state;
184 unsigned long *file_map;
185 unsigned int num_maps;
188 * bandwidth and latency stats
190 struct io_stat clat_stat[2]; /* completion latency */
191 struct io_stat slat_stat[2]; /* submission latency */
192 struct io_stat bw_stat[2]; /* bandwidth stats */
194 unsigned long stat_io_bytes[2];
195 struct timeval stat_sample_time[2];
197 struct io_log *slat_log;
198 struct io_log *clat_log;
199 struct io_log *bw_log;
201 struct timeval start; /* start of this loop */
202 struct timeval epoch; /* time job was started */
204 struct rusage ru_start;
205 struct rusage ru_end;
206 unsigned long usr_time;
207 unsigned long sys_time;
210 unsigned int do_disk_util;
211 unsigned int override_sync;
213 struct list_head io_hist_list;
216 #define td_verror(td, err) \
220 snprintf(td->verror, sizeof(td->verror) - 1, "file:%s:%d, error=%s", __FILE__, __LINE__, strerror(e)); \
223 extern int parse_jobs_ini(char *);
224 extern int parse_options(int, char **);
225 extern void finish_log(struct thread_data *, struct io_log *, const char *);
226 extern int init_random_state(struct thread_data *);
228 extern int rate_quit;
229 extern int write_lat_log;
230 extern int write_bw_log;
231 extern int exitall_on_terminate;
232 extern int thread_number;
236 extern struct thread_data *threads;
244 * What type of allocation to use for io buffers
247 MEM_MALLOC, /* ordinary malloc */
248 MEM_SHM, /* use shared memory segments */
249 MEM_MMAP, /* use anonynomous mmap */
253 * The type of object we are working on
262 FIO_MMAPIO = 1 << 1 | FIO_SYNCIO,
264 FIO_POSIXAIO = 1 << 3,
268 #define td_read(td) ((td)->ddir == DDIR_READ)
269 #define td_write(td) ((td)->ddir == DDIR_WRITE)
271 #define BLOCKS_PER_MAP (8 * sizeof(long))
272 #define TO_MAP_BLOCK(td, b) ((b) - ((td)->file_offset / (td)->min_bs))
273 #define RAND_MAP_IDX(td, b) (TO_MAP_BLOCK(td, b) / BLOCKS_PER_MAP)
274 #define RAND_MAP_BIT(td, b) (TO_MAP_BLOCK(td, b) & (BLOCKS_PER_MAP - 1))
276 #define MAX_JOBS (1024)
278 struct disk_util_stat {
281 unsigned long long sectors[2];
284 unsigned time_in_queue;
288 struct list_head list;
294 struct disk_util_stat dus;
295 struct disk_util_stat last_dus;
301 struct io_completion_data {
304 int error; /* output */
305 unsigned long bytes_done[2]; /* output */
308 #define DISK_UTIL_MSEC (250)